Skip to content

Commit

Permalink
add the project description to setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tuhahaha authored and JianxinMa committed Apr 17, 2024
1 parent 3f51838 commit 8d0a539
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 42 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ repos:
rev: v0.32.0
hooks:
- id: yapf
args: ["--style={based_on_style: google, column_limit: 300, indent_width: 4}"]
- repo: https://github.com/pre-commit/pre-commit-hooks.git
rev: v4.3.0
hooks:
Expand Down
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[中文](./README_CN.md) | English
[中文](https://github.com/QwenLM/Qwen-Agent/blob/main/README_CN.md) | English

<p align="center">
<img src="https://qianwen-res.oss-cn-beijing.aliyuncs.com/assets/qwen_agent/logo-qwen-agent.png" width="400"/>
Expand All @@ -13,8 +13,13 @@ It also comes with example applications such as Browser Assistant, Code Interpre

## Installation

- Install the stable version from PyPI:
```bash
pip install -U qwen-agent
```

- Alternatively, you can install the latest development version from the source:
```bash
# Install dependencies.
git clone https://github.com/QwenLM/Qwen-Agent.git
cd Qwen-Agent
pip install -e ./
Expand All @@ -26,10 +31,10 @@ You can either use the model service provided by Alibaba
Cloud's [DashScope](https://help.aliyun.com/zh/dashscope/developer-reference/quick-start), or deploy and use your own
model service using the open-source Qwen models.

If you choose to use the model service offered by DashScope, please ensure that you set the environment
- If you choose to use the model service offered by DashScope, please ensure that you set the environment
variable `DASHSCOPE_API_KEY` to your unique DashScope API key.

Alternatively, if you prefer to deploy and use your own model service, please follow the instructions provided in the README of Qwen1.5 for deploying an OpenAI-compatible API service.
- Alternatively, if you prefer to deploy and use your own model service, please follow the instructions provided in the README of Qwen1.5 for deploying an OpenAI-compatible API service.
Specifically, consult the [vLLM](https://github.com/QwenLM/Qwen1.5?tab=readme-ov-file#vllm) section for high-throughput GPU deployment or the [Ollama](https://github.com/QwenLM/Qwen1.5?tab=readme-ov-file#ollama) section for local CPU (+GPU) deployment.

## Developing Your Own Agent
Expand Down Expand Up @@ -120,18 +125,12 @@ while True:
```

In addition to using built-in agent implentations such as `class Assistant`, you can also develop your own agent implemetation by inheriting from `class Agent`.
Please refer to the [examples](./examples) directory for more usage examples.
Please refer to the [examples](https://github.com/QwenLM/Qwen-Agent/blob/main/examples) directory for more usage examples.

# BrowserQwen
# Application: BrowserQwen

BrowserQwen is a browser assistant application built upon Qwen-Agent. Please refer to its [documentation](browser_qwen.md) for more
details.
BrowserQwen is a browser assistant built upon Qwen-Agent. Please refer to its [documentation](https://github.com/QwenLM/Qwen-Agent/blob/main/browser_qwen.md) for details.

# Disclaimer

This project is currently under active development, and backward compatibility may occasionally be broken.

> [!Warning]
> <div align="center">
> The code interpreter is not sandboxed, and it executes code in your own environment. Please do not ask Qwen to perform dangerous tasks, and do not directly use the code interpreter for production purposes.
> </div>
The code interpreter is not sandboxed, and it executes code in your own environment. Please do not ask Qwen to perform dangerous tasks, and do not directly use the code interpreter for production purposes.
22 changes: 11 additions & 11 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ Qwen-Agent是一个开发框架。开发者可基于本框架开发Agent应用

## 安装

- 安装稳定的版本:
```bash
pip install -U qwen-agent
```

- 或者,直接从源代码安装最新的版本:
```bash
# 安装依赖
git clone https://github.com/QwenLM/Qwen-Agent.git
cd Qwen-Agent
pip install -e ./
Expand All @@ -22,9 +27,9 @@ pip install -e ./

Qwen-Agent支持接入阿里云[DashScope](https://help.aliyun.com/zh/dashscope/developer-reference/quick-start)服务提供的Qwen模型服务,也支持通过OpenAI API方式接入开源的Qwen模型服务。

如果希望接入DashScope提供的模型服务,只需配置相应的环境变量`DASHSCOPE_API_KEY`为您的DashScope API Key。
- 如果希望接入DashScope提供的模型服务,只需配置相应的环境变量`DASHSCOPE_API_KEY`为您的DashScope API Key。

但如果您希望部署并使用您自己的模型服务,请按照Qwen1.5的README中提供的指导进行操作,以部署一个兼容OpenAI接口协议的API服务。
- 或者,如果您希望部署并使用您自己的模型服务,请按照Qwen1.5的README中提供的指导进行操作,以部署一个兼容OpenAI接口协议的API服务。
具体来说,请参阅[vLLM](https://github.com/QwenLM/Qwen1.5?tab=readme-ov-file#vllm)一节了解高并发的GPU部署方式,或者查看[Ollama](https://github.com/QwenLM/Qwen1.5?tab=readme-ov-file#ollama)一节了解本地CPU(+GPU)部署。

## 快速开发
Expand Down Expand Up @@ -115,15 +120,10 @@ while True:

除了使用框架自带的智能体实现(如`class Assistant`),您也可以通过继承`class Agent`来自行开发您的智能体实现。更多使用示例,请参阅[examples](./examples)目录。

# BrowserQwen
# 应用:BrowserQwen

BrowserQwen 是一款基于 Qwen-Agent 构建的浏览器助手应用程序。如需了解更多详情,请参阅其[文档](browser_qwen_cn.md)
BrowserQwen 是一款基于 Qwen-Agent 构建的浏览器助手。如需了解详情,请参阅其[文档](browser_qwen_cn.md)

# 免责声明

本项目正处于快速迭代中,可能会偶尔出现不兼容旧版本的情况。

> [!Warning]
> <div align="center">
> 代码解释器未进行沙盒隔离,会在部署环境中执行代码。请避免向Qwen发出危险指令,切勿将该代码解释器直接用于生产目的。
> </div>
代码解释器未进行沙盒隔离,会在部署环境中执行代码。请避免向Qwen发出危险指令,切勿将该代码解释器直接用于生产目的。
2 changes: 1 addition & 1 deletion benchmark/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from models.base import HFModel # noqa
from models.dashscope import QwenDashscopeVLModel
from models.dashscope import QwenDashscopeVLModel # noqa
from models.llm import LLM # noqa
from models.qwen import Qwen, QwenVL # noqa
1 change: 1 addition & 0 deletions benchmark/models/dashscope.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import os
import time
from http import HTTPStatus

Expand Down
1 change: 1 addition & 0 deletions qwen_agent/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__version__ = '0.0.2'
from .agent import Agent

__all__ = ['Agent']
1 change: 0 additions & 1 deletion qwen_agent/llm/oai.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import copy
import os
from pprint import pformat
from typing import Dict, Iterator, List, Optional
Expand Down
5 changes: 5 additions & 0 deletions qwen_agent/memory/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ def _run(self,
# Gen keyword
*_, last = self.keygen.run([Message(USER, query)])
keyword = last[-1].content
keyword = keyword.strip()
if keyword.startswith('```json'):
keyword = keyword[len('```json'):]
if keyword.endswith('```'):
keyword = keyword[:-3]
try:
logger.info(keyword)
keyword_dict = json5.loads(keyword)
Expand Down
12 changes: 4 additions & 8 deletions run_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def parse_args():
'--model_server',
type=str,
default='dashscope',
help=
'Set it to `dashscope` if you are using the model service provided by DashScope.'
help='Set it to `dashscope` if you are using the model service provided by DashScope.'
' Set it to the base_url (aka api_base) if using an OpenAI API-compatible service such as vLLM or Ollama.'
' Default: dashscope',
)
Expand All @@ -33,8 +32,7 @@ def parse_args():
'--llm',
type=str,
default='qwen-plus',
help=
'Set it to one of {"qwen-max", "qwen-plus", "qwen-turbo"} if using DashScope.'
help='Set it to one of {"qwen-max", "qwen-plus", "qwen-turbo"} if using DashScope.'
' Set it to the model name using an OpenAI API-compatible model service.'
' Default: qwen-plus',
)
Expand All @@ -44,16 +42,14 @@ def parse_args():
type=str,
default='127.0.0.1',
choices=['127.0.0.1', '0.0.0.0'],
help=
'Set to 0.0.0.0 if you want to allow other machines to access the server. Default: 127.0.0.1',
help='Set to 0.0.0.0 if you want to allow other machines to access the server. Default: 127.0.0.1',
)
parser.add_argument(
'-t',
'--max_ref_token',
type=int,
default=4000,
help=
'The number of tokens reserved for the reference materials when doing retrieval-augmanted generation (RAG). Default: 4000',
help='The number of tokens reserved for the reference materials when doing retrieval-augmanted generation (RAG). Default: 4000',
)
parser.add_argument(
'-w',
Expand Down
37 changes: 32 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,48 @@
import re

from setuptools import find_packages, setup


def get_version() -> str:
with open('qwen_agent/__init__.py', encoding='utf-8') as f:
version = re.search(
r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
f.read(),
re.MULTILINE,
).group(1)
return version


def read_requirements():
with open('requirements.txt') as req:
content = req.read()
requirements = content.split('\n')
return requirements


def read_description() -> str:
with open('README.md', 'r', encoding='UTF-8') as f:
long_description = f.read()
return long_description


setup(
name='qwen_agent',
version='0.0.1',
name='qwen-agent',
version=get_version(),
author='Qwen Team',
author_email='[email protected]',
description='Qwen-Agent: Enhancing LLMs with Agent Workflows, RAG, Function Calling, and Code Interpreter.',
long_description=read_description(),
long_description_content_type='text/markdown',
keywords=['LLM', 'Agent', 'Function Calling', 'RAG', 'Code Interpreter'],
packages=find_packages(
exclude=['examples', 'examples.*', 'qwen_server', 'qwen_server.*']),
package_data={
'qwen_agent':
['utils/qwen.tiktoken', 'tools/resource/*.ttf', 'tools/resource/*.py'],
'qwen_agent': [
'utils/qwen.tiktoken', 'tools/resource/*.ttf',
'tools/resource/*.py', 'gui/assets/*.css', 'gui/assets/*.jpeg'
],
},
install_requires=read_requirements(),
url='https://github.com/QwenLM/Qwen-Agent')
url='https://github.com/QwenLM/Qwen-Agent',
)
3 changes: 1 addition & 2 deletions tests/agents/test_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def test_assistant_files():
Message('user', [
ContentItem(text='总结一个文章标题'),
ContentItem(
file=
'https://help.aliyun.com/zh/dashscope/developer-reference/api-details?disableWebsiteRedirect=true'
file='https://help.aliyun.com/zh/dashscope/developer-reference/api-details?disableWebsiteRedirect=true'
)
])
]
Expand Down

0 comments on commit 8d0a539

Please sign in to comment.