当前位置:   article > 正文

Langchain-Chatchat部署总结_langchain-chatchat 0.3

langchain-chatchat 0.3

项目地址:

https://github.com/chatchat-space/Langchain-Chatchat

整体安装比较方便,在阿里云购买云主机,购买的国外站点机器,

该项目运行最佳坏境为

  • Linux Ubuntu 22.04.5
  • Python 版本 == 3.11.7
  • CUDA 版本: == 12.1
  • torch==2.1.2

使用最轻量级部署方案

  1. git clone https://github.com/chatchat-space/Langchain-Chatchat.git
  2. cd Langchain-Chatchat/
  3. pip install -r requirements_lite.txt
  4. mv basic_config.py.example basic_config.py
  5. mv kb_config.py.example kb_config.py
  6. mv model_config.py.example model_config.py
  7. mv prompt_config.py.example prompt_config.py
  8. mv server_config.py.example server_config.py

修改model的大模型配置

    "openai-api": {
        "model_name": "gpt-3.5-turbo",
        "api_base_url": "https://api.chatanywhere.tech/v1",
        "api_key": "sk-45aHXQhjXoZJzXCZyuY2OjmAIhDHN9BnoN26nFTFdFgl7y1R",
        "openai_proxy": "https://api.chatanywhere.tech/v1",
    },

免费chatgpts国内代理,只能使用3.5

GitHub - chatanywhere/GPT_API_free: Free ChatGPT API Key,免费ChatGPT API,支持GPT4 API(免费),ChatGPT国内可用免费转发API,直连无需代理。可以搭配ChatBox等软件/插件使用,极大降低接口使用成本。国内即可无限制畅快聊天。

启动服务

python startup.py -a --lite

启动报错,缺少依赖包,需要安装依赖包,重新启动即可

pip install streamlit sentence_transformers markdownify strsimpy cachetools websockets

启动成功

==============================Langchain-Chatchat Configuration==============================

操作系统:Linux-5.15.0-92-generic-x86_64-with-glibc2.35.

python版本:3.11.7 (main, Feb 27 2024, 00:07:27) [GCC 11.4.0]

项目版本:v0.2.10

langchain版本:0.0.354. fastchat版本:0.2.36

当前使用的分词器:ChineseRecursiveTextSplitter

当前启动的LLM模型:['chatglm3-6b', 'zhipu-api', 'openai-api'] @ cpu

{'device': 'cuda',

'host': '0.0.0.0',

'infer_turbo': False,

'model_path': 'THUDM/chatglm3-6b',

'port': 20002}

{'api_key': '',

'device': 'auto',

'host': '0.0.0.0',

'infer_turbo': False,

'online_api': True,

'port': 21001,

'provider': 'ChatGLMWorker',

'version': 'glm-4',

'worker_class': <class 'server.model_workers.zhipu.ChatGLMWorker'>}

{'api_base_url': 'https://api.chatanywhere.tech/v1/chat/completions',

'api_key': 'sk-45aHXQhjXoZJzXCZyuY2OjmAIhDHN9BnoN26nFTFdFgl7y1R',

'device': 'auto',

'host': '0.0.0.0',

'infer_turbo': False,

'model_name': 'gpt-3.5-turbo',

'online_api': True,

'openai_proxy': 'https://api.chatanywhere.tech/v1/chat/completions',

'port': 20002}

当前Embbedings模型: bge-large-zh-v1.5 @ cpu

==============================Langchain-Chatchat Configuration==============================

2024-02-27 10:38:49,365 - startup.py[line:655] - INFO: 正在启动服务:

2024-02-27 10:38:49,365 - startup.py[line:656] - INFO: 如需查看 llm_api 日志,请前往 /opt/Langchain-Chatchat/logs

/usr/local/lib/python3.11/site-packages/langchain_core/_api/deprecation.py:117: LangChainDeprecationWarning: 模型启动功能将于 Langchain-Chatchat 0.3.x重写,支持更多模式和加速启动,0.2.x中相关功能将废弃

  warn_deprecated(

2024-02-27 10:38:54 | INFO | model_worker | Register to controller

2024-02-27 10:38:54 | ERROR | stderr | INFO:     Started server process [24223]

2024-02-27 10:38:54 | ERROR | stderr | INFO:     Waiting for application startup.

2024-02-27 10:38:54 | ERROR | stderr | INFO:     Application startup complete.

2024-02-27 10:38:54 | ERROR | stderr | INFO:     Uvicorn running on http://0.0.0.0:20000 (Press CTRL+C to quit)

INFO:     Started server process [24241]

INFO:     Waiting for application startup.

INFO:     Application startup complete.

INFO:     Uvicorn running on http://0.0.0.0:7861 (Press CTRL+C to quit)

==============================Langchain-Chatchat Configuration==============================

操作系统:Linux-5.15.0-92-generic-x86_64-with-glibc2.35.

python版本:3.11.7 (main, Feb 27 2024, 00:07:27) [GCC 11.4.0]

项目版本:v0.2.10

langchain版本:0.0.354. fastchat版本:0.2.36

当前使用的分词器:ChineseRecursiveTextSplitter

当前启动的LLM模型:['chatglm3-6b', 'zhipu-api', 'openai-api'] @ cpu

{'device': 'cuda',

'host': '0.0.0.0',

'infer_turbo': False,

'model_path': 'THUDM/chatglm3-6b',

'port': 20002}

{'api_key': '',

'device': 'auto',

'host': '0.0.0.0',

'infer_turbo': False,

'online_api': True,

'port': 21001,

'provider': 'ChatGLMWorker',

'version': 'glm-4',

'worker_class': <class 'server.model_workers.zhipu.ChatGLMWorker'>}

{'api_base_url': 'https://api.chatanywhere.tech/v1/chat/completions',

'api_key': 'sk-45aHXQhjXoZJzXCZyuY2OjmAIhDHN9BnoN26nFTFdFgl7y1R',

'device': 'auto',

'host': '0.0.0.0',

'infer_turbo': False,

'model_name': 'gpt-3.5-turbo',

'online_api': True,

'openai_proxy': 'https://api.chatanywhere.tech/v1/chat/completions',

'port': 20002}

当前Embbedings模型: bge-large-zh-v1.5 @ cpu

服务端运行信息:

    OpenAI API Server: http://127.0.0.1:20000/v1

    Chatchat  API  Server: http://127.0.0.1:7861

    Chatchat WEBUI Server: http://0.0.0.0:8501

==============================Langchain-Chatchat Configuration==============================

Collecting usage statistics. To deactivate, set browser.gatherUsageStats to False.

  You can now view your Streamlit app in your browser.

  URL: http://0.0.0.0:8501 

访问地址http://eip:8501,成功打开webUI界面

打开如果有报错,一般是缺少依赖,解决依赖问题

pip install streamlit-aggrid  streamlit_modal streamlit_chatbox streamlit_option_menu

选择LLM对话,选择openai-api , 成功完成对话

常见报错 

2024-02-27 10:38:39 | ERROR | stderr | ERROR:    [Errno 98] error while attempting to bind on address ('0.0.0.0', 20000): address already in use

端口占用,先shutdown之间的进程

  1. chmod +x shutdown_all.sh
  2. ./shutdown_all.sh

 访问webUI缺少依赖包,继续下载

pip install streamlit-aggrid  streamlit_modal streamlit_chatbox streamlit_option_menu

参考资料

LLMs之RAG:LangChain-Chatchat(一款中文友好的全流程本地知识库问答应用)的简介(支持 FastChat 接入的ChatGLM-2/LLaMA-2等多款主流LLMs+多款embe-CSDN博客

https://blog.csdn.net/ssw_1990/category_12461946.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/692366
推荐阅读
相关标签
  

闽ICP备14008679号