Hk-Gosuto / ChatGPT-Next-Web-LangChain

一键拥有你自己的 ChatGPT 网页服务。 One-Click to deploy your own ChatGPT web UI.(基于 langchain 实现的插件版本 Plugin version implemented based on langchain)
https://n3xt.chat
MIT License
1.15k stars 386 forks source link

[Feature Request]: 关于RAG 功能的用法 #244

Closed laye0619 closed 7 months ago

laye0619 commented 7 months ago

Problem Description

请教一下大神,我已经按照https://github.com/Hk-Gosuto/ChatGPT-Next-Web-LangChain/blob/main/docs/rag-cn.md#rag-功能配置说明 的要求配置了,也申请了cloudflare r2并配置好了,我是本地docker部署,环境变量已经都加上了,想请教一下如何实现 这里面的功能,模型上我选择了gpt-4*的所有模型,除了vision- preview可以看到对话框跳出来上传图片按钮,其余并没有任何上传文件的按钮出现,请问这应该怎么使用

Solution Description

希望得到关于RAG 功能的用法的指导

Alternatives Considered

No response

Additional Context

No response

Issues-translate-bot commented 7 months ago

Bot detected the issue body's language is not English, translate it automatically.


Title: [Feature Request]: About the usage of RAG function

Hk-Gosuto commented 7 months ago

pull 一下最新的 gosuto/chatgpt-next-web-langchain:nightly 镜像,我是今天中午才上传的。

Issues-translate-bot commented 7 months ago

Bot detected the issue body's language is not English, translate it automatically.


Pull the latest gosuto/chatgpt-next-web-langchain:nightly model. I uploaded it just at noon today.

laye0619 commented 7 months ago

使用nightly镜像暂时还是没有上传按钮,使用最新的code部署在vercel上也是没有。请问使用openai官方接口 模型gpt-4-turbo-preview应该可以使用这个功能吗?

Issues-translate-bot commented 7 months ago

Bot detected the issue body's language is not English, translate it automatically.


There is still no upload button when using the nightly image, and there is no upload button when deploying on vercel using the latest code. Is it possible to use this function using the openai official interface model gpt-4-turbo-preview?

Hk-Gosuto commented 7 months ago

所有的 openai 模型,除了视觉模型都可以使用上传,检查一下环境变量 ENABLE_RAG 是否配置正确,docker 版本可以使用下面的命令测试:

docker run --rm -it -p 3000:3000 -e ENABLE_RAG=1 gosuto/chatgpt-next-web-langchain:nightly

image

laye0619 commented 7 months ago

十分感谢!修改了docker环境变量,之前加了NEXT_PUBLIC前缀,现在有了文件上传按钮。试了一下,上传了一个英文PDF,在R2中也确实可以看到了,但是问AI问题好像回答不了,自动去调用了Web- Browser插件了(如图)。我看到您的截图里面是会去调用rag-search插件,但是我在插件列表里面没有看到这个插件?

Screenshot 2024-04-09 at 09 42 06
Issues-translate-bot commented 7 months ago

Bot detected the issue body's language is not English, translate it automatically.


Thank you very much! The docker environment variable has been modified. The NEXT_PUBLIC prefix was added before, and now there is a file upload button. I tried it and uploaded an English PDF. It can indeed be viewed in R2, but it seems that it cannot answer the AI ​​questions and automatically calls the Web-Browser plug-in (as shown in the picture). I saw that your screenshot calls the rag-search plug-in, but I don’t see this plug-in in the plug-in list?

Screenshot 2024-04-09 at 09 42 06
Hk-Gosuto commented 7 months ago

可以先关闭其他插件或者使用 gpt4

Issues-translate-bot commented 7 months ago

Bot detected the issue body's language is not English, translate it automatically.


You can close other plug-ins first or use gpt4

laye0619 commented 7 months ago

可以先关闭其他插件或者使用 gpt4

关闭了其它插件,并使用gpt-4后,可以调用rag-search了,但是对于文件访问好像还是有些问题,我直接在对话框中点击文件是可以打开的,在r2中也是可以看到文件的:)

Screenshot 2024-04-09 at 09 57 42
Issues-translate-bot commented 7 months ago

Bot detected the issue body's language is not English, translate it automatically.


You can close other plug-ins first or use gpt4

After closing other plug-ins and using gpt-4, I can call rag-search, but there still seems to be some problems with file access. I can open it by clicking on the file directly in the dialog box, and I can also see the file in r2. :)

Hk-Gosuto commented 7 months ago

检查一下 qdrant 仪表盘确认一下向量库是否有正确被创建 image

Issues-translate-bot commented 7 months ago

Bot detected the issue body's language is not English, translate it automatically.


Check the qdrant dashboard to confirm that the vector library was created correctly image

laye0619 commented 7 months ago

打开Dashboard后没有看到Collection

Screenshot 2024-04-09 at 10 08 37
Hk-Gosuto commented 7 months ago

向量库没有正确被创建,检查一下程序日志看看是否有相关错误信息。

Issues-translate-bot commented 7 months ago

Bot detected the issue body's language is not English, translate it automatically.


The vector library was not created correctly. Check the program log to see if there are any related error messages.

laye0619 commented 7 months ago

使用docker部署的查询文件就没有创建向量库,但是使用vercel部署的就可以创建向量库,可是返回了这个错误

Screenshot 2024-04-09 at 10 31 27
Issues-translate-bot commented 7 months ago

Bot detected the issue body's language is not English, translate it automatically.


The query file deployed using docker did not create a vector library, but the vector library was created using vercel, but this error was returned. ![Uploading Screenshot 2024-04-09 at 10.31.27.png…]()

Hk-Gosuto commented 7 months ago

因为 Qdrant SDK 需要 nodejs 环境,如果要在 vercel 使用必须配置环境变量 NEXT_PUBLIC_ENABLE_NODEJS_PLUGIN=1。 不过需要注意的是,在 vercel 使用 nodejs 运行时会有接口超时风险,还是建议在 docker 下使用。

Issues-translate-bot commented 7 months ago

Bot detected the issue body's language is not English, translate it automatically.


Because Qdrant SDK requires nodejs environment, if you want to use it in vercel, you must configure the environment variable NEXT_PUBLIC_ENABLE_NODEJS_PLUGIN=1. However, it should be noted that there is a risk of interface timeout when running vercel using nodejs. It is still recommended to use it under docker.

laye0619 commented 7 months ago

明白了,设置了环境变量,可以使用了,十分感谢!

Issues-translate-bot commented 7 months ago

Bot detected the issue body's language is not English, translate it automatically.


I understand, I have set the environment variable and it is ready to use. Thank you very much!

laxfer commented 6 months ago

可以先关闭其他插件或者使用 gpt4

这块我用到了一种解决办法,就是在插件开关这里增加了另一种状态,也就是RAG模式,切换到RAG模式后,其他插件并不会起作用,/app/store/chat.ts 里面增加了判断 if ( config.pluginConfig.enable && session.mask.usePlugins !== 'disabled' && (allPlugins.length > 0 || isEnableRAG) && isFunctionCalling( modelConfig.model ) ) { console.log("[ToolAgent] start"); // 如果是RAG插件模式,只调用RAG插件,排除其他插件的干扰 const pluginToolNames = session.mask.usePlugins === 'rag' ? ["rag-search"] : session.mask.usePlugins === 'enabled' ? allPlugins.map((m) => m.toolName) : [];

      const agentCall = () => {
        api.llm.toolAgentChat({

这种解决办法,可以用,还有就是只有开启RAG模式的情况下,才会显示文件上传的按,在切换到最新的gpt-4-turbo, gpt-4-turbo-2024-04-09这两种模型的时候,会同时显示图片上传和文件上传的按钮。 微信截图_20240416152719

laxfer commented 6 months ago

经过反复测试,RAG模式下,其他插件都会存在干扰,所以,在RAG模式下,就不会再加载别的插件

Issues-translate-bot commented 6 months ago

Bot detected the issue body's language is not English, translate it automatically.


After repeated testing, in RAG mode, other plug-ins will interfere, so in RAG mode, other plug-ins will not be loaded.

Hk-Gosuto commented 6 months ago

经过反复测试,RAG模式下,其他插件都会存在干扰,所以,在RAG模式下,就不会再加载别的插件

这个功能目前写的比较粗糙,后面我打算试试上传文件后在 system prompt 中增加一些上下文让模型优先使用 RAG 检索来回答问题。

Issues-translate-bot commented 6 months ago

Bot detected the issue body's language is not English, translate it automatically.


After repeated testing, other plug-ins will interfere with RAG mode. Therefore, no other plug-ins will be loaded in RAG mode.

This function is currently relatively rough in writing. Later I plan to try adding some context to the system prompt after uploading the file so that the model can use RAG retrieval first to answer questions.