diff --git a/README.md b/README.md index e69de29..05b34d1 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,74 @@ +# 基于reAct范式实现的agent + +本项目用于验证语音控制大屏后端模块。获取用户输入后,由LLM进行意图识别,并通过function calling调用相关函数,实现语音控制大屏。 +使用的LLM是阿里开源QwQ-32B,模型特点为有一定的推理能力并且运行速度快。DeepSeek-R1由于不是天生支持function calling所以不考虑。 + +# 环境搭建 + +1. clone 本项目 + +```shell +git clone http://1.14.96.249:3000/old-tom/reActLLMDemo.git +``` + +2. 安装依赖 + 推荐使用uv创建虚拟环境,python版本为3.12及以上 + +```shell +uv sync +``` + +3.向量库部署和初始化 (docker) + +```shell +docker run --name marqo -it --privileged -p 8882:8882 --add-host host.docker.internal:host-gateway marqoai/marqo:latest +``` + +初始化:执行[vector_db.py](vector_db.py) create_and_set_index()方法 + +测试:执行[vector_db.py](vector_db.py) query_vector_db() 方法,参数为任意字符串 + +4.配置文件 +[env.toml](env.toml) + +```toml +[base] +# 向量库相似度阈值 +similarity_threshold = 0.93 +# 模型供应商 +model_form = 'siliconflow' +####### 模型配置 ####### +[siliconflow] +# 硅基流动 +# 密钥 +api_key = '' +# 模型名称 +model = '' +# API地址 +base_url = '' +# 最大token数 +max_tokens = 4096 +# 温度系数 +temperature = 0.6 +# 是否流式返回 +streaming = true +``` + +# 本地测试 + +环境搭建完成后,本地运行[local_test.py](local_test.py) 即可在终端体验对话 + +# 服务端简单实现 + +服务端使用fastapi实现,启动[server.py](server.py) 即可, 完整接口文档请访问 http://ip:port/docs + +1. 建立sse连接,用于接收模型返回(流式) + [GET] http://ip:port/sse/{client_id} + + 参数:client_id: 客户端ID,用于区分不同客户端及历史聊天 + +2. 请求对话 + [GET] http://ip:port/chat/{client_id}?ask=xxx + + 参数:client_id: 客户端ID,用于区分不同客户端及历史聊天 ask: 请求内容 + \ No newline at end of file