赞
踩
本文将在 google 实验室中使用 Langchain-Chatchat 搭建一个知识库,还可以进行聊天等功能。
由于是在 google 实验室上面跑代码,所以本地电脑什么配置都无所谓!
效果图
运行起来后可以上传各种文档文件到知识库。
QQ 交流群: 854445223
github https://github.com/chatchat-space/Langchain-Chatchat
一种利用 langchain 思想实现的基于本地知识库的问答应用,目标期望建立一套对中文场景与开源模型支持友好、可离线运行的知识库问答解决方案。
笔记本环境中默认已经安装了 nodejs
、python
等环境。
新建文档
基本语法
!
” 符号就是可执行的命令语句!git clone https://github.com/chatchat-space/Langchain-Chatchat.git
repo_dir = "/content/Langchain-Chatchat"
%cd $repo_dir
google 实验室使用默认的模型 chatglm3-6b
跑不起来,换一个小一点的模型就行, 我这里用 Qwen-1_8B-Chat
a. 打开文件 Langchain-Chatchat/configs/model_config.py.example
第 22 行改为:
LLM_MODELS = ["Qwen-1_8B-Chat", "zhipu-api", "openai-api"]
b. 打开文件 Langchain-Chatchat/configs/server_config.py.example
第 9 行改为:
OPEN_CROSS_DOMAIN = True
b. 打开文件 Langchain-Chatchat/configs/server_config.py.example
第 17 行下面追加:
"share": True
# 安装全部依赖
!pip install -r requirements.txt
!pip install -r requirements_api.txt
!pip install -r requirements_webui.txt
!rm -r Qwen-1_8B-Chat
!git clone https://huggingface.co/Qwen/Qwen-1_8B-Chat
!rm -r bge-large-zh
!git clone https://huggingface.co/BAAI/bge-large-zh
# 删除多余的知识库文件
# 删除后自己将文件上传到 /content/Langchain-Chatchat/knowledge_base/samples/content/ 目录即可
!rm -R /content/Langchain-Chatchat/knowledge_base/samples/content/
!mkdir /content/Langchain-Chatchat/knowledge_base/samples/content/
由于google实验室不提供公网ip,所以是没有办法直接访问我们运行的服务的,这时候用内网穿透即可
!npm install -g localtunnel
在访问内网穿透插件提供的地址时需要填入才可以进行访问页面
!curl ipv4.icanhazip.com
!python ./startup.py -a & lt --port 8501
访问这个地址即可
QQ 交流群: 854445223
完整笔记:
https://colab.research.google.com/drive/1TDYSNVwrsmjhUq3b7MSVur4vrVb3A_kU?usp=sharing
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。