# chat_robot **Repository Path**: toolsmanhehe/chat_robot ## Basic Information - **Project Name**: chat_robot - **Description**: 基于mindIE Server服务搭建的聊天机器人案例 - **Primary Language**: Unknown - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2025-01-02 - **Last Updated**: 2025-03-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # chat_rebot #### 介绍 chat_rebot 是一个由深圳市迅龙软件有限公司为OrangePi AI Studio/OrangePi AI Studio Pro 开发的使用本地大模型搭建的聊天机器人案例。本案例通过调用MindIE Server提供的接口,实现本地对话功能。前端页面由[ascend-llm-web](https://gitee.com/yinghuo302/ascend-llm-web)项目修改而来。 当前支持的功能有:回答用户提问,支持上下文问答(具体长度视模型而定)。 #### 当前支持的模型 | 模型名称 | 模型下载地址 | | ------------------------ | ---------------------------------------------------------------- | | Baichuan2-7B | https://huggingface.co/baichuan-inc/Baichuan2-7B-Chat | | chatglm2-6b | https://huggingface.co/THUDM/chatglm2-6b | | DeepSeek-R1-Distill-Qwen-14B | https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-14B | | DeepSeek-R1-Distill-Qwen-7B | https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B | | glm-4-9b-chat | https://huggingface.co/THUDM/glm-4-9b-chat | #### 使用说明 1. 参考用户手册,确保模型推理正常。 2. 修改[MindIE Server配置文件](/usr/local/Ascend/mindie/latest/mindie-service/conf/config.json)。我们需要用到配置文件中的以下几个配置: - httpsEnabled: 是否开启HTTPS通信安全认证,目前暂不支持https,请设置为false,默认值:true。 - ipAddress: 业务面IP地址,保持默认即可,默认值:127.0.0.1。 - port: 业务面端口号,保持默认即可,默认值:1025。 - modelName: 模型名称,默认值:llama_65b。 - modelWeightPath: 模型权重路径,默认值:/data/atb_testdata/weights/llama1-65b-safetensors。 3. 启动MindIE Server服务: ```bash cd /usr/local/Ascend/mindie/latest/mindie-service ./bin/mindieservice_daemon ``` 4. 安装依赖: ```bash pip3 install -r requirements.txt -i https://mirrors.huaweicloud.com/repository/pypi/simple ``` 5. 启动chat_rebot服务: ```bash python3 main.py ``` 6. 根据打印的信息,浏览器访问http://{ip_address}:{port},即可使用chat_rebot服务。 #### 新增模型的方法 1. 复制chatglm2-6b.py为{modelName}.py。 2. 修改{modelName}.py中两处 `http://127.0.0.1:1025`为实际server服务器的ip和端口。 3. 使用`python3 {modelName}.py`测试推理是否正常。 4. 使用`python3 main.py`启动chat_rebot主程序,验证相关功能是否正常。 #### 异常处理 1. mindIE会对模型权重文件路径进行安全校验,需要和执行用户的属组和权限保持一致。如root用户启动,模型权重文件夹及内部文件的所有者必须是root用户。修改所有者的方法如下: ```bash chown -R root:root /models/your_model_name ``` 2. 模型的config.json文件的权限必须是640,否则无法启动MindIE Server服务。修改的方法如下: ```bash chmod 640 /models/your_model_name/config.json ``` 3. 如果在第一步修改配置文件的时候,ipAddress或port不是默认值,需要修改main.py文件和对应模型的配置文件(以chatglm2-6b为例)的以下内容。 * [main.py](./main.py) ```python response = requests.get('http://{ipAddress}:{port}/v1/models') ``` - [chatglm2-6b.py](./chatglm2-6b.py) ```python response = requests.get('http://{ipAddress}:{port}/v1/models') self.url = "http://{ipAddress}:{port}/v1/chat/completions" ``` 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request