AI Personal Learning
and practical guidance

Qwen-Agent: Qwen-based framework for intelligent agent applications, including tool calls, code interpreters, RAGs and Chrome extensions.

General Introduction

Qwen-Agent is an intelligent agent application framework developed based on Qwen 2.0 and above with command following, tool usage, planning and memorization capabilities. The framework provides a variety of sample applications, such as browser helpers, code interpreters, and custom helpers, to help developers quickly build and deploy intelligent agent applications.Qwen-Agent supports a variety of functional modules, including function calls, code interpretation, RAG (Retrieval Augmentation Generation), and Chrome extensions, for a variety of complex application scenarios.

Qwen-Agent: Qwen-based framework for intelligent agent applications, including function calls, code interpreters, RAGs and Chrome extensions. -1


 

BrowserQwen, a browser-based extension for smart bodies

Qwen-Agent: a Qwen-based framework for intelligent agent applications, including tool calls, code interpreters, RAGs and Chrome extensions. -1

 

Function List

  • function call: Supports automation of complex tasks through function calls.
  • code interpreter: Provide code interpretation features to help users understand and execute code.
  • RAG (Retrieval Augmentation Generation): Supports large-scale document retrieval and generation for long-document quizzing tasks.
  • Chrome Extension: Provides browser extensions to enhance the user's browsing experience.
  • Customization Tools: Allow users to add custom tools to extend the functionality of the framework.

 

Using Help

Installation process

  1. Installing the stable version from PyPI::
    pip install -U "qwen-agent[gui,rag,code_interpreter,python_executor]"
    

    Or install the least dependent version:

    pip install -U qwen-agent
    

    Optional dependencies include:

    • [gui]: Support for Gradio-based GUIs
    • [rag]: Support for RAG
    • [code_interpreter]: Support for code interpreters
    • [python_executor]: Tool-integrated reasoning with support for Qwen2.5-Math
  2. Install the latest development version from source::
    git clone https://github.com/QwenLM/Qwen-Agent.git
    cd Qwen-Agent
    pip install -e . /[gui,rag,code_interpreter,python_executor]
    

    Or install the least dependent version:

    pip install -e . /
    

Functional operation flow

  1. Configuration Modeling Service::
    • Use the modeling service provided by AliCloud DashScope to set environment variables DASHSCOPE_API_KEY for your DashScope API key.
    • Alternatively, deploy and use your own modeling service, following the instructions in the README for Qwen2.
  2. Developing Custom Agents::
    Qwen-Agent provides base components, such as the components inherited from the BaseChatModel and the LLMs inherited from BaseTool tools, as well as high-level components such as those inherited from Agent The following is an example of creating an agent that can read a PDF file and use the tool. The following is an example of creating an agent that can read PDF files and use tools:

    from qwen_agent.agents import Assistant
    from qwen_agent.tools.base import BaseTool, register_tool
    @register_tool('my_image_gen')
    class MyImageGen(BaseTool).
    description = 'AI painting service that inputs a text description and returns a URL of an image painted based on the text information.'
    parameters = [{'name': 'prompt', 'type': 'string', 'description': 'Detailed description of the desired image content', 'required': True}]]
    def call(self, params: str, **kwargs) -> str.
    prompt = json5.loads(params)['prompt']
    prompt = urllib.parse.quote(prompt)
    return json5.dumps({'image_url': f'https://image.pollinations.ai/prompt/{prompt}'}, ensure_ascii=False)
    llm_cfg = {
    
    'model_server': 'dashscope',
    'generate_cfg': {'top_p': 0.8}
    }
    tools = ['my_image_gen', 'code_interpreter']
    files = ['. /examples/resource/doc.pdf']
    bot = Assistant(llm=llm_cfg, system_message='You are a helpful assistant.', function_list=tools, files=files)
    messages = []
    while True: query = input('user query')
    query = input('user query: ')
    messages.append({'role': 'user', 'content': query})
    response = bot.run(messages=messages)
    for res in response.
    print('bot response:', res)
    messages.extend(res)
    
  3. Quick Start Gradio Demo::
    from qwen_agent.gui import WebUI
    WebUI(bot).run()
    
AI Easy Learning

The layman's guide to getting started with AI

Help you learn how to utilize AI tools at a low cost and from a zero base.AI, like office software, is an essential skill for everyone. Mastering AI will give you an edge in your job search and half the effort in your future work and studies.

View Details>
May not be reproduced without permission:Chief AI Sharing Circle " Qwen-Agent: Qwen-based framework for intelligent agent applications, including tool calls, code interpreters, RAGs and Chrome extensions.

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish