分享一个开源的快速构建AI智能体应用框架Qwen-Agent

分享一个开源的快速构建AI智能体应用框架Qwen-Agent

800_auto

Qwen-Agent 构建在 Qwen2 之上,提供了一个用于开发 LLM 应用的框架。该框架具备功能调用、代码解释器、RAG 和 Chrome 扩展程序等特性。

项目包含了多个示例应用,如浏览器助手、代码解释器和自定义助手。用户可以通过 PyPI 安装稳定版本,也可以从源代码安装最新的开发版本。

项目还提供了使用 DashScope 提供的模型服务或自行部署的模型服务选项(例如ollama)。

开发者可以通过注册自定义工具来扩展框架的功能,并且可以创建自己的代理(Agent)来处理特定的任务。项目还提供了一个快速的 RAG 解决方案,用于处理超长文档的问答,并在两个挑战性的基准测试中超过了原生的长上下文模型。此外,项目还包括了一个名为 BrowserQwen 的浏览器助手,它是基于 Qwen-Agent 构建的。项目的代码解释器部分没有沙盒保护,因此不建议用于生产环境。

安装:

pip install -U qwen-agent

示例,创建一个agent进行文生图

import pprint
import urllib.parse
import json5
from qwen_agent.agents import Assistant
from qwen_agent.tools.base import BaseTool, register_tool


# Step 1 (Optional): Add a custom tool named `my_image_gen`.
@register_tool('my_image_gen')
class MyImageGen(BaseTool):
    # The `description` tells the agent the functionality of this tool.
    description = 'AI painting (image generation) service, input text description, and return the image URL drawn based on text information.'
    # The `parameters` tell the agent what input parameters the tool has.
    parameters = [{
        'name': 'prompt',
        'type': 'string',
        'description': 'Detailed description of the desired image content, in English',
       ...

点击查看剩余70%

{{collectdata}}

网友评论