autogen改变屏幕亮度

学习资料

官方的入门教程很容易入门,所以推荐使用官方的学习资料:autogen官方教程

小实践,修改屏幕亮度

准备:

  1. 修改屏幕亮度的python代码(参考:改变屏幕亮度
  2. 使用工具(autogen使用工具例子代码)
python 复制代码
import tempfile

from autogen import ConversableAgent,config_list_from_json
from autogen.coding import LocalCommandLineCodeExecutor
from autogen import register_function
import screen_brightness_control as sbc
from typing import Annotated,Literal
Operator = Literal["change"]

def change_brightness(value:int,operator: Annotated[Operator, "operator"]) ->str:
    sbc.set_brightness(value)
    return 'change successfully'

def main():
    config_list = config_list_from_json(env_or_file='OAI_CONFIG_LIST')
    temp_dir = tempfile.TemporaryDirectory()
    #定义assistant
    assistant_agent_system_message = "You are a helpful AI assistant. "
    "You can help with change brightness on my device. "
    "Return 'TERMINATE' when the task is done."
    assistant_agent = ConversableAgent(
        "assisant",
        llm_config={'config_list':config_list},
        system_message=assistant_agent_system_message,
        code_execution_config=False,
    )

    executor = LocalCommandLineCodeExecutor(
        timeout=10,
        work_dir=temp_dir.name,
    )

    user_proxy_agent = ConversableAgent(
        "user-proxy",
        code_execution_config={
            'executor': executor,
        },
        human_input_mode="ALWAYS",
    )

    #注册工具
    # Register the tool signature with the assistant agent.
    assistant_agent.register_for_llm(name="changeScreenbrightness", description="A tool to change screen brightness")(change_brightness)

    # Register the tool function with the user proxy agent.
    user_proxy_agent.register_for_execution(name="changeScreenbrightness")(change_brightness)

    chat_result = user_proxy_agent.initiate_chat(
        assistant_agent,
        message='Change brightness to 50'
    )
    

if __name__ == '__main__':
    main()

OAI_CONFIG_LIST文件的配置为:

python 复制代码
[
    {
        "model": "qwen-plus-latest", 
        "base_url":"https://dashscope.aliyuncs.com/compatible-mode/v1",
        "api_type":"qwen",
        "api_key":"你的key",
        "temperature": 0.7,
        "max_tokens":2000,
        "stream":0
    }
]

注意事项

  1. 这里使用的阿里的兼容openai的接口。是一个比较好的选择,因为autogen对openai的适配度高。
  2. 使用了下阿里百炼平台的llama3(要申请,有免费额度),但是不支持function call,所以改成了使用qwen-plus-latest。这个模型还可以,比qwen-turo聪明些。
相关推荐
JasonLiu19191 天前
论文推荐 |【Agent】自动化Agent设计系统
人工智能·自动化·llm·agent·智能体
zhoujian121384 天前
Windows11系统下SkyWalking环境搭建教程
经验分享·elasticsearch·agent·教程·skywalking
网安打工仔7 天前
探索RAG、AI Agents和Agentic RAG的架构、应用程序和主要区别
人工智能·大模型·transformer·大语言模型·agent·rag·ai agent
JasonLiu19198 天前
LLM Agent系列 | 端侧Agent路由器,合纵连横AI江湖,破局端侧大模型之困!
人工智能·llm·agent·智能体
AI_小站9 天前
30个GPT提示词天花板,一小时从大纲到终稿
大数据·人工智能·gpt·llm·agent·提示词·知识库
Linux猿12 天前
828华为云征文 | 云服务器Flexus X实例:开源项目 LangChain 部署,实例测试
langchain·华为云·agent·flexus云服务器x实例·华为云服务器
Linux猿15 天前
828华为云征文 | 云服务器Flexus X实例:部署 AgentOps,全方位监测智能体
人工智能·华为云·agent·autogen·flexus云服务器x实例·华为云服务器·agentops
z千鑫15 天前
【人工智能】如何利用AI轻松将java,c++等代码转换为Python语言?程序员必读
java·c++·人工智能·gpt·agent·ai编程·ai工具
Linux猿17 天前
828华为云征文 | 云服务器Flexus X实例:多智能体对话框架 AutoGen 部署和实例运行
华为云·agent·多智能体·autogen·flexus云服务器x实例·华为云服务器·autogen studio