梳理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.mfbz.cn/a/286045.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

YOLOv8改进 | 注意力篇 | ACmix自注意力与卷积混合模型(提高FPS+检测效率)

一、本文介绍 本文给大家带来的改进机制是ACmix自注意力机制的改进版本&#xff0c;它的核心思想是&#xff0c;传统卷积操作和自注意力模块的大部分计算都可以通过1x1的卷积来实现。ACmix首先使用1x1卷积对输入特征图进行投影&#xff0c;生成一组中间特征&#xff0c;然后根…

vim学习记录

目录 历史记录前言相关资料配置windows互换ESC和Caps Lock按键 基本操作替换字符串 历史记录 2024年1月2日, 搭建好框架,开始学习; 前言 vim使用很久了,但是都是一些基本用法,主要是用于配置Linux,进行一些简单的编写文档和程序.没有进行过大型程序开发,没有达到熟练使用的程…

基础算法(8):高精度加减乘除

目录 1.高精度加法 模板&#xff1a; 例题&#xff1a; 2.高精度减法 模板&#xff1a; 例题&#xff1a; 3.高精度乘法 3.1 高精度乘低精度 模板&#xff1a; 例题&#xff1a; 3.2 高精度乘高精度 模板&#xff1a; 例题&#xff1a; ​编辑 4.高精度除法 模…

2024年山东省某市建筑类中级职称评审安利

2024年山东省某市建筑类中级职称评审安利 之所以安利山东烧烤市建筑类中级职称是因为2023年申报评审情况比较乐观。如果你2023年申报评审中级职称不顺利&#xff0c;等1-2年还没下来&#xff0c;可以考虑考虑山东省中级职称申报评审。叙后尘来给你们展开说说山东中级职称申报。…

科普帖:什么是函数即服务 (FaaS)?

您可能听说过SaaS&#xff0c;您可能听说过PaaS和IaaS&#xff0c;但您听说过函数即服务 (FaaS) 吗&#xff1f; FaaS市场正在快速增长。根据Allied Market Research的数据&#xff0c;2018年市场价值30.1亿美元 。预计到2026年&#xff0c;这一数字将增长到240亿美元——这意…

gitee创建仓库

描述 本文章记录了怎么在gitee上创建项目&#xff0c;以及使用vscode提代码到远程呢个仓库&#xff0c;如何创建一个新分支&#xff0c;并将新分支提交到远程仓库。 1、创建远程仓库 在创建远程仓库之前要先进行ssh密钥的设置 &#xff08;1&#xff09;打开黑窗口&#xff…

SpringBoot整合多数据源,并支持动态新增与切换

SpringBoot整合多数据源&#xff0c;并支持动态新增与切换 一、概述 在项目的开发过程中&#xff0c;遇到了需要从数据库中动态查询新的数据源信息并切换到该数据源做相应的查询操作&#xff0c;这样就产生了动态切换数据源的场景。为了能够灵活地指定具体的数据库&#xff0…

图解Kafka Producer常用性能优化配置参数

1 基本参数 bootstrap.servers&#xff1a;Kafka broker服务器地址列表&#xff0c;,分开&#xff0c;可不必写全&#xff0c;Kafka内部有自动感知Kafka broker的机制 client.dns.lookup&#xff1a;客户端寻找bootstrap地址的方式&#xff0c;支持两种方式&#xff1a; resol…

现在学鸿蒙开发有前途吗?能找到工作吗?

鸿蒙开发前景肯定是有的&#xff0c;我们可以从市场的情况来分析。 1、鸿蒙开发不兼容安卓 23年9月举办的华为新品发布会中&#xff0c;华为方面宣布开始启用原生鸿蒙应用&#xff0c;并不再提供安卓代码的兼容性。涵盖了资讯、社交、工具、金融、生活、美食、游戏等多品类的…

多技术融合在生态系统服务功能社会价值评估中的应用及论文写作、拓展分析

生态系统服务是人类从自然界中获得的直接或间接惠益&#xff0c;可分为供给服务、文化服务、调节服务和支持服务4类&#xff0c;对提升人类福祉具有重大意义&#xff0c;且被视为连接社会与生态系统的桥梁。自从启动千年生态系统评估项目&#xff08;Millennium Ecosystem Asse…

【Bootstrap学习 day8】

加载器 使用Bootstrap读取图标以表示元件加载状态&#xff0c;这些读取图标完全使用HTML,CSS。要创建spinner/加载器&#xff0c;可以使用.spinner-border类 <div class"spinner-border"></div>可以使用文本颜色类设置不同的颜色&#xff1a; <div …

关于Github部分下载的方法

一、问题 在Github中&#xff0c;我需要下载部分文件&#xff0c;而github只有下载最原始文件夹和单独文件的功能。 比如我想下载头四个文件&#xff0c;难以操作。 二、方法 推荐使用谷歌浏览器&#xff0c;进入扩展程序界面&#xff1a; 在应用商店获取GitZip for github…

Python数据科学应用从入门到精通--Python读取、合并SPSS数据文件

在很多情况下&#xff0c;我们需要调用SPSS软件产生的数据&#xff0c;下面通过示例来进行讲解。首先需要将本书提供的数据文件存储在安装spyder-py3的默认路径位置&#xff08;C:/Users/Administrator/.spyder-py3/&#xff0c;注意具体的安装路径可能与此不同&#xff09;&am…

PDF文档转换工具箱流量主小程序开发

PDF转换小助手&#xff0c;不仅是文件格式转换的利器&#xff0c;更是一位得力的助手。它精通PDF与各类文档间的自由转换&#xff0c;如Word、Excel、PowerPoint等。 转换选项丰富多样&#xff0c;满足您对文件保护、页面设置、图像品质等细致要求。处理大量文件&#xff1f;…

canvas绘制圆点示例

查看专栏目录 canvas示例教程100专栏&#xff0c;提供canvas的基础知识&#xff0c;高级动画&#xff0c;相关应用扩展等信息。canvas作为html的一部分&#xff0c;是图像图标地图可视化的一个重要的基础&#xff0c;学好了canvas&#xff0c;在其他的一些应用上将会起到非常重…

格式转换工具,一键转换文件格式

有时候&#xff0c;为了满足工作或学习的需要&#xff0c;我们需要将文件从一种格式转换为另一种格式。传统的单文件转换方式不仅费时&#xff0c;而且容易出错。有没有便捷的方法可以解决这个问题&#xff1f;答案是肯定的&#xff0c;那就是使用【文件批量改名高手】来批量操…

Python实现简单的JS逆向解密, 实现翻译软件+语音播报

嗨喽~大家好呀&#xff0c;这里是魔王呐 ❤ ~! python更多源码/资料/解答/教程等 点击此处跳转文末名片免费获取 环境使用: python 3.8 pycharm 第三方模块使用: requests --> pip install requests execjs --> pip install PyExecJS ttkbootstrap --> pip inst…

时隔五天,重温Redis基础总结

目录 字符串操作命令 Redis 字符串类型常用命令SET key value 设置指定key的值 ​编辑GET key 获取指定key的值 ​编辑SETEX key seconds value 设置指定key的值&#xff0c;并将 key 的过期时间设为 seconds 秒 SETNX key value 只有在key不存在时设置key的值 哈希操作命…

epoll原理及服务器代码实现

epoll 是 Linux 下用于实现高性能事件通知机制的系统调用。它相对于传统的 select 和 poll 具有更好的性能和可伸缩性&#xff0c;特别适用于需要处理大量并发连接的场景&#xff0c;比如网络编程中的服务器。 #include <sys/epoll.h> // 创建一个新的epoll实例。在内核中…

安全与认证Week3

Key Management 密钥管理 密钥交换、证书 密钥的类别 密钥管理方面 密钥分发问题 密钥分发方案 简单的密钥分发&#xff1a;允许安全通信&#xff0c;但不存在先前或之后的密钥。 带机密性和身份验证的密钥分发&#xff1a;提供更高级别的安全性。 混合密钥分发 公钥分发 公开…