梳理Langchain-Chatchat-UI接口文档

  在 Langchain-Chatchat v0.1.17 版本及以前是有前后端分离的 Vue 项目的,但是 v0.2.0 后就没有了。所以本文使用的是 Langchain-Chatchat v0.1.17 版本中的 Vue 项目。经过一番折腾终于将 Langchain-Chatchat v0.1.17 版本前端 Vue 接口和 Langchain-Chatchat v0.2.8 后端 API 接口调通了。

一.运行 Langchain-Chatchat

1.拉取源码

  拉取 Langchain-Chatchat 源码(Langchain-Chatchat v0.2.8),如下所示:

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

2.安装依赖包

  安装依赖包,如下所示:

pip install -r .\requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

3.模型下载和配置

  模型下载和配置(加速参考文献[3]),如下所示:

python hf_download.py --model THUDM/ChatGLM3-6B --save_dir ./hf_hub
python hf_download.py --model BAAI/bge-large-zh --save_dir ./hf_hub

4.初始化知识库和配置文件

  初始化知识库和配置文件,如下所示:

$ python copy_config_example.py
$ python init_database.py --recreate-vs

  Langchain-Chatchat-0.2.8->configs->model_config.py->embed_model-> 设置 bge-large-zh 本地路径,如下所示:

  Langchain-Chatchat-0.2.8->configs->model_config.py->llm_model-> 设置 chatglm3-6b 本地路径,如下所示:

  Langchain-Chatchat-0.2.8->configs->model_config.py->VLLM_MODEL_DICT-> 设置 chatglm3-6b 本地路径,如下所示:

5.python startup.py -a

$ python startup.py -a

  手动安装 PyTorch 的 CUDA 版本,如下所示:

pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu118

  控制台输出的日志信息,如下所示:

import sys; print('Python %s on %s' % (sys.version, sys.platform))
Connected to pydev debugger (build 232.9559.58)
L:\20231106_ConversationSystem\ChatCopilot\Langchain\Langchain-Chatchat-0.2.8\venv\Scripts\python.exe "D:/Program Files/JetBrains/PyCharm 2023.1.3/plugins/python/helpers/pydev/pydevd.py" --multiprocess --qt-support=auto --client 127.0.0.1 --port 36490 --file L:\20231106_ConversationSystem\RasaLangchain\Langchain\Langchain-Chatchat-0.2.8\startup.py -a 
==============================Langchain-Chatchat Configuration==============================
操作系统:Windows-10-10.0.19044-SP0.
python版本:3.10.9 (tags/v3.10.9:1dd9be6, Dec  6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)]
项目版本:v0.2.8
langchain版本:0.0.344. fastchat版本:0.2.34
当前使用的分词器:ChineseRecursiveTextSplitter
<strong>当前启动的LLM模型:['chatglm3-6b', 'zhipu-api', 'openai-api'] @ cuda</strong>
{'device': 'cuda','host': '127.0.0.1','infer_turbo': False,'model_path': 'L:\\20230713_HuggingFaceModel\\GLM3\\chatglm3-6b','model_path_exists': True,'port': 20002}
{'api_key': '','device': 'auto','host': '127.0.0.1','infer_turbo': False,'online_api': True,'port': 21001,'provider': 'ChatGLMWorker','version': 'chatglm_turbo','worker_class': <class 'server.model_workers.zhipu.ChatGLMWorker'>}
{'api_base_url': 'https://api.openai.com/v1','api_key': '','device': 'auto','host': '127.0.0.1','infer_turbo': False,'model_name': 'gpt-3.5-turbo','online_api': True,'openai_proxy': '','port': 20002}
<strong>当前Embbedings模型: bge-large-zh @ cuda</strong>
==============================Langchain-Chatchat Configuration==============================
2023-12-24 08:18:36,235 - startup.py[line:650] - INFO: 正在启动服务:
2023-12-24 08:18:36,236 - startup.py[line:651] - INFO: 如需查看 llm_api 日志,请前往 L:\20231106_ConversationSystem\RasaLangchain\Langchain\Langchain-Chatchat-0.2.8\logs
2023-12-24 08:19:30 | INFO | model_worker | Register to controller
2023-12-24 08:19:37 | ERROR | stderr | INFO:     Started server process [126488]
2023-12-24 08:19:37 | ERROR | stderr | INFO:     Waiting for application startup.
2023-12-24 08:19:37 | ERROR | stderr | INFO:     Application startup complete.
2023-12-24 08:19:37 | ERROR | stderr | INFO:     Uvicorn running on http://127.0.0.1:20000 (Press CTRL+C to quit)
2023-12-24 08:21:18 | INFO | model_worker | Loading the model ['chatglm3-6b'] on worker bc7ce098 ...
Loading checkpoint shards:   0%|          | 0/7 [00:00<?, ?it/s]
Loading checkpoint shards:  14%|█▍        | 1/7 [01:08<06:51, 68.62s/it]
Loading checkpoint shards:  29%|██▊       | 2/7 [02:16<05:42, 68.43s/it]
Loading checkpoint shards:  43%|████▎     | 3/7 [03:24<04:31, 67.83s/it]
Loading checkpoint shards:  57%|█████▋    | 4/7 [04:28<03:19, 66.62s/it]
Loading checkpoint shards:  71%|███████▏  | 5/7 [05:36<02:14, 67.16s/it]
Loading checkpoint shards:  86%|████████▌ | 6/7 [06:48<01:08, 68.75s/it]
Loading checkpoint shards: 100%|██████████| 7/7 [07:29<00:00, 59.44s/it]
Loading checkpoint shards: 100%|██████████| 7/7 [07:29<00:00, 64.15s/it]
2023-12-24 08:29:30 | ERROR | stderr | 
2023-12-24 08:30:45 | INFO | model_worker | Register to controller
INFO:     Started server process [125172]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:7861 (Press CTRL+C to quit)
==============================Langchain-Chatchat Configuration==============================
操作系统:Windows-10-10.0.19044-SP0.
python版本:3.10.9 (tags/v3.10.9:1dd9be6, Dec  6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)]
项目版本:v0.2.8
langchain版本:0.0.344. fastchat版本:0.2.34
当前使用的分词器:ChineseRecursiveTextSplitter
当前启动的LLM模型:['chatglm3-6b', 'zhipu-api', 'openai-api'] @ cuda
{'device': 'cuda','host': '127.0.0.1','infer_turbo': False,'model_path': 'L:\\20230713_HuggingFaceModel\\GLM3\\chatglm3-6b','model_path_exists': True,'port': 20002}
{'api_key': '','device': 'auto','host': '127.0.0.1','infer_turbo': False,'online_api': True,'port': 21001,'provider': 'ChatGLMWorker','version': 'chatglm_turbo','worker_class': <class 'server.model_workers.zhipu.ChatGLMWorker'>}
{'api_base_url': 'https://api.openai.com/v1','api_key': '','device': 'auto','host': '127.0.0.1','infer_turbo': False,'model_name': 'gpt-3.5-turbo','online_api': True,'openai_proxy': '','port': 20002}
当前Embbedings模型: bge-large-zh @ cuda
<strong>服务端运行信息:</strong>
<strong>    OpenAI API Server: http://127.0.0.1:20000/v1</strong>
<strong>    Chatchat  API  Server: http://127.0.0.1:7861</strong>
<strong>    Chatchat WEBUI Server: http://127.0.0.1:8501</strong>
==============================Langchain-Chatchat Configuration==============================You can now view your Streamlit app in your browser.URL: http://127.0.0.1:8501
2023-12-24 08:37:51,151 - _client.py[line:1027] - INFO: HTTP Request: POST http://127.0.0.1:20001/list_models "HTTP/1.1 200 OK"
INFO:     127.0.0.1:31565 - "POST /llm_model/list_running_models HTTP/1.1" 200 OK
2023-12-24 08:37:51,188 - _client.py[line:1027] - INFO: HTTP Request: POST http://127.0.0.1:7861/llm_model/list_running_models "HTTP/1.1 200 OK"
2023-12-24 08:37:51,331 - _client.py[line:1027] - INFO: HTTP Request: POST http://127.0.0.1:20001/list_models "HTTP/1.1 200 OK"
2023-12-24 08:37:51,337 - _client.py[line:1027] - INFO: HTTP Request: POST http://127.0.0.1:7861/llm_model/list_running_models "HTTP/1.1 200 OK"
INFO:     127.0.0.1:31565 - "POST /llm_model/list_running_models HTTP/1.1" 200 OK
INFO:     127.0.0.1:31565 - "POST /llm_model/list_config_models HTTP/1.1" 200 OK
2023-12-24 08:37:51,413 - _client.py[line:1027] - INFO: HTTP Request: POST http://127.0.0.1:7861/llm_model/list_config_models "HTTP/1.1 200 OK"

(1)OpenAI API Server: http://127.0.0.1/v1

(2)Chatchat API Server: http://127.0.0.1

这个是 Langchain-Chatchat v0.2.8 版本后端 API 接口文档,如下所示:

(3)Chatchat WEBUI Server: http://127.0.0.1

  对话模式包括:LLM 对话,知识库问答,文件对话,搜索引擎问答,自定义 Agent 问答。

二.运行 Langchain-Chatchat-UI

  在 Langchain-Chatchat v0.1.17 版本及以前是有前后端分离的 Vue 项目的,但是 v0.2.0 后就没有了。所以本文使用的是 Langchain-Chatchat v0.1.17 版本中的 Vue 项目。运行前端项目基本命令就是 npm installnpm run dev

1.不能找到模块 node:path

  当执行 npm run dev 时报错,显示 Error: Cannot find module 'node:path'。如下所示:

  以前用的 Vue2+Node 14.17.0,更换为 node-v16.16.0 就好了。执行命令,如下所示:

npm install npm@6 -g
npm cache clear --force
npm install
npm run dev

2.将前端 Vue 项目跑起来

  这个是 Langchain-Chatchat v0.1.17 版本前端 Vue 的界面(Langchain-Chatchat v0.2.8 后端 API 接口有所调整,需要更新前端接口才能将其运行起来),如下所示:

3.遇到的问题

(1)搜索引擎接口

http://localhost:8090/api/chat/search_engine_chat

(2)知识库检索接口

http://localhost:8090/api/chat/file_chat

报错:未找到临时知识库 samples,请先上传文件,但是知识库是已经存在的。

原因:应该调用 knowledge_base_chat 知识库对话接口,而 file_chat 是与临时文件进行对话的接口。

  调用 knowledge_base_chat 成功后的信息,如下所示:

(3)文件上传接口

http://localhost:8090/api/knowledge_base/upload_docs

  说明:经过一番折腾终于将 Langchain-Chatchat v0.1.17 版本前端 Vue 接口和 Langchain-Chatchat v0.2.8 后端 API 接口调通了(前端界面暂不开源,若有问题可以交流)。

参考文献

[1] https://nodejs.org/download/release/v16.16.0/

[2] https://github.com/chatchat-space/Langchain-Chatchat

[3] https://github.com/LetheSec/HuggingFace-Download-Accelerator

[4] https://pytorch.org/get-started/previous-versions/

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/590898.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

数据预处理:标准化和归一化

标准化和归一化简介 1、数据预处理概述2、数据标准化3、数据归一化4、标准化和归一化怎么选1、数据预处理概述 在选择了合适模型的前提下,机器学习可谓是“训练台上3分钟,数据数量和质量台下10年功”。数据的收集与准备是机器学习中的重要一步,是构建一个好的预测模型大厦的…

jenkins+pytest+allure

jenkinspytestallure allure下载地址 Releases allure-framework/allure2 GitHub allure环境变量配置 allure --version 查看版本(确定是否配置完成) python安装allure插件 pip install allure-pytest pytest的运行指令 pytest -sv test_demo.py 开发完毕后将代码上传到…

深入理解@Resource与@Autowired:用法与区别解析

Resource&#xff1a; Resource 是Java EE提供的注解&#xff0c;也可以在Spring中使用。它是按照名称进行注入的&#xff0c;默认通过属性名&#xff08;通常是类名的小驼峰命名方式&#xff09;或者name属性来匹配。如果找不到符合名称的bean&#xff0c;则会抛出异常。在使…

轻量应用服务器阿里云61元、腾讯云62元,你选哪个?

阿里云和腾讯云又降价了&#xff0c;刚刚说完阿里云87元和腾讯云88元&#xff0c;又降级了&#xff0c;阿里云2核2G3M轻量应用服务器61元一年&#xff0c;腾讯云轻量2核2G3M服务器62元一年&#xff0c;你选哪个&#xff1f;阿里云不限制月流量&#xff0c;腾讯云限制200GB月流量…

2024 年 9 款简单好用的 Windows 分区管理器软件

了解适用于 Windows 11 和 Windows 7 的 Windows 分区管理器的概念。本教程还列出了分区管理器软件&#xff1a; 购买新电脑&#xff1f;担心磁盘存储空间不足&#xff1f;你听说过分区吗&#xff1f;如果没有&#xff0c;这篇文章就是为你准备的。 在本文中&#xff0c;我们…

Linux:apache优化(7)—— 访问控制

作用&#xff1a;为apache服务提供的页面设置客户端访问权限&#xff0c;为某个组或者某个用户加密访问&#xff1b; /usr/local/httpd/bin/htpasswd -c /usr/local/httpd/conf/htpasswd tarro1 #添加admin用户&#xff0c;可以在两个路径中间添加-c是新建文件删除原文件&#…

SPI通信协议:串行外设接口的精髓

SPI通信协议&#xff1a;串行外设接口的精髓 SPI&#xff08;Serial Peripheral Interface&#xff09;通信协议是一种常见且广泛应用于串行通信的标准&#xff0c;特别适用于连接微控制器与外围设备。本文将深入介绍SPI通信协议的基本原理、工作方式、硬件连接、应用领域以及…

Linux系统驱动要如何学习

1.你将获得&#xff1a; 快速上手 Linux 操作系统&#xff1b; 掌握Linux 内核工作原理&#xff1b; 掌握Linux 内核调试手段&#xff1b; 掌握复杂驱动&#xff1a;USB、PCIE、V4L2等 这门课程旨在为你打开Linux内核驱动的大门&#xff0c;让你在探索Linux内核的旅程中获得前…

C++常用工具函数-1

1、转为16进制 unsigned long temp 16&#xff1b; std::cout<< "temp2"<<std::setbase(16)<< temp << std::endl; 2、数组转指针操作 unsigned char W[4*8*15]; // the expanded key unsigned int * Wb reinterpret_cast<unsigned…

QT的信号与槽

QT的信号与槽 文章目录 QT的信号与槽前言一、QT 打印"hello QT"的dome二、信号和槽机制&#xff1f;二、信号与槽的用法1、QT5的方式1. 无参的信号与槽的dome2.带参的信号与槽dome 2、QT4的方式3、C11的语法 Lambda表达式1、函数对象参数2、操作符重载函数参数3、可修…

LAYABOX:2024新年寄语

2024新年寄语 过去的一年&#xff0c;尽管许多行业面临严峻挑战和发展压力&#xff0c;小游戏领域却逆势上扬&#xff0c;年产值首次突破400亿元大关&#xff0c;众多优质小游戏企业收获颇丰。 对此&#xff0c;祝福大家&#xff0c;2024一定更好&#xff01; 过去的一年&#…

伺服电机的控制模式

一、伺服电机基本的控制模式 伺服电机的基本控制模式有位置模式、速度模式、转矩模式 二、位置模式 位置模式对速度和位置都有严格的控制&#xff0c;通过控制发送脉冲的频率&#xff0c;来确定电机的转动杆速度大小&#xff0c;通过控制发送脉冲的个数来确定转动的角度。位置…

CMake入门教程【基础篇】CMake编译平台

文章目录 简介Visual Studio支持示例 其他编译器和生成器支持MinGW示例 IDE集成Eclipse示例 实验性和特殊平台支持总结 简介 CMake是一个非常强大的跨平台自动化构建工具&#xff0c;它支持生成多种类型的项目文件&#xff0c;覆盖了广泛的开发环境和编译器。在这篇博客中&…

33--反射

1、反射(Reflection)的概念 1.1 反射的出现背景 Java程序中&#xff0c;所有的对象都有两种类型&#xff1a;编译时类型和运行时类型&#xff0c;而很多时候对象的编译时类型和运行时类型不一致。 Object obj new String("hello"); obj.getClass(); 例如&#xf…

【话题】ChatGPT等大语言模型为什么没有智能2

我们接着上一次的讨论&#xff0c;继续探索大模型的存在的问题。正巧CSDN最近在搞文章活动&#xff0c;我们来看看大模型“幻觉”。当然&#xff0c;本文可能有很多我自己的“幻觉”&#xff0c;欢迎批评指正。如果这么说的话&#xff0c;其实很容易得出一个小结论——大模型如…

DS1302N的时钟逻辑

时钟也是一个实时的串口&#xff0c;也是很简单的&#xff0c;不过要注意以下的要点&#xff1a; 要点&#xff1a; &#xff08;1&#xff09;里面有很多数据&#xff0c;所以需要定义一个结构体变量&#xff0c;将其中的数据写进去。 &#xff08;2&#xff09;写进去的数…

.Net Core 防御XSS攻击

网络安全攻击方式有很多种&#xff0c;其中包括XSS攻击、SQL注入攻击、URL篡改等。那么XSS攻击到底是什么?XSS攻击有哪几种类型? XSS攻击又称为跨站脚本&#xff0c;XSS的重点不在于跨站点&#xff0c;而是在于脚本的执行。XSS是一种经常出现在Web应用程序中的计算机安全漏洞…

算法基础之计数问题

计数问题 核心思想&#xff1a; 数位dp / 累加 累加 ​ 分情况讨论 &#xff1a; xxx 000 ~ abc –1 yyy 000 ~ 999 共 abc * 1000 种 特别地&#xff0c;当枚举数字0时 (找第4位为0的数) 前三位不能从000开始了 否则没这个数不合法(有前导零) xxx abc 2.1. d < 1 , 不…

UnityShader(四)一个最简单的顶点/片元着色器

目录 顶点/片元着色器的基本结构&#xff1a; 简单的例子 增加模型数据 顶点着色器和片元着色器之间的通信 顶点/片元着色器的基本结构&#xff1a; Shader "MyShaderName"{Properties{//属性}SubShader{//针对显卡A的SubShaderPass{//设置渲染状态和标签//开始C…

C++正则表达式全攻略:从基础到高级应用

C正则表达式全攻略&#xff1a;从基础到高级应用 一、基础知识二、正则表达式的基本匹配三、C中使用正则表达式四、高级正则表达式五、实践示例六、性能优化6.1、编译正则表达式6.2、避免过度使用回溯6.3、优化匹配算法 七、总结 一、基础知识 正则表达式是一种用于匹配、搜索…