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.12k stars 400 forks source link

[Bug] 出现错误,无法回答问题 #276

Closed AthanaD closed 2 months ago

AthanaD commented 2 months ago

Bug Description

image image

同样的NEWAPI管理,同样的问题和调用的模型,lobe可以,chatgpt-next不行

Steps to Reproduce

RT

Expected Behavior

RTrtrtrt

Screenshots

rt

Deployment Method

Desktop OS

No response

Desktop Browser

No response

Desktop Browser Version

No response

Smartphone Device

No response

Smartphone OS

No response

Smartphone Browser

No response

Smartphone Browser Version

No response

Additional Logs

No response

Issues-translate-bot commented 2 months ago

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


Title: [Bug] An error occurred and the question cannot be answered.

Hk-Gosuto commented 2 months ago

原版 ChatGPT-Next-Web 是否可用?

Issues-translate-bot commented 2 months ago

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


Is the original ChatGPT-Next-Web available?

AthanaD commented 2 months ago

部分模型无法用,常规模型可以用。我采用的https://github.com/Ink-Osier/DeepLXToV1Api创建的API接口及KEY,在lobe chat中可以用 好像404错误 日志中提示,200的是Lobe调用,404是本项目调用,模型名称为deeplx-EN及deeplx-ZH。之前的chatgpt-next项目可以调用。 INFO:root:Translation from to EN took: 0.9460744857788086 INFO:root:Received request: {'messages': [{'content': '总的来说,鲁迅(笔名)和周树人(本名)是同一个人,他的文学成就和思想深度对中国现代文学和社会变革产生了深远的影响。', 'role': 'user'}, {'content': 'In a nutshell, Lu Xun (pen name) and Zhou Shuren (real name) are the same person whose literary achievements and depth of thought have had a profound impact on modern Chinese literature and social change.', 'role': 'assistant'}, {'content': '用中文分析下:new-api | [SYS] 2024/06/06 - 19:58:34 | model ratio not found: deeplx-EN \nnew-api | [INFO] 2024/06/06 - 19:58:34 | 20240606195834392896377WKncyB5D | user 1 with unlimited token has enough quota 100000381162971, trusted and no need to pre-consume \ndeeplxtov1api | INFO:root:Received request: {'messages': [{'content': '总的来说,鲁迅(笔名)和周树人(本名)是同一个人,他的文学成就和思想深度对中国现代文学和社会变革产生了深远的影响。', 'role': 'user'}], 'stream': True, 'model': 'deeplx-EN'}\ndeeplxtov1api | INFO: 172.22.0.1:45598 - "POST /v1/chat/completions HTTP/1.1" 200 OK\ndeeplxtov1api | INFO:root:Translation from to EN took: 1.076103687286377\nnew-api | [INFO] 2024/06/06 - 19:58:37 | 20240606195834392896377WKncyB5D | record consume log: userId=1, 用户调用前余额=100000381162971, channelId=5, promptTokens=73, completionTokens=43, modelName=deeplx-EN, tokenName=, quota=10080, content=模型倍率 30.00,分组倍率 1.50,补全倍率 3.50 \nnew-api | [GIN] 2024/06/06 - 19:58:37 | 20240606195834392896377WKncyB5D | 200 | 3.229631289s | 129.146.121.123 | POST /v1/chat/completions\ndevincopilot | 172.22.0.1 - - [06/Jun/2024 19:58:58] "GET / HTTP/1.1" 404 -', 'role': 'user'}, {'content': 'Analyze in Chinese: new-api | [SYS] 2024/06/06 - 19:58:34 | model ratio not found: deeplx-EN\nnew-api | [INFO] 2024/06/06 - 19:58:34 | 20240606195834392896377WKncyB5D | user 1 with unlimited token has enough quota 100000381162971, trusted and no need to pre-consume\ndeeplxtov1api | INFO:root:Received request: {'messages': [{'content': 'In a nutshell, Lu Xun (pen name) and Zhou Shuren (real name) are the same person, whose literary achievements and depth of thought have had a profound impact on modern Chinese literature and social change.' , 'role': 'user'}], 'stream': True, 'model': 'deeplx-EN'}\ndeeplxtov1api | INFO: 172.22.0.1:45598 - "POST /v1/chat/completions HTTP/1.1" 200 OK\ndeeplxtov1api | INFO:root:Translation from to EN took: 1.076103687286377\nnew-api | [INFO] 2024/06/06 - 19:58:37 | 20240606195834392896377WKncyB5D | record consume log: userId=1, userBalanceBeforeCalls=100000381162971, channelId=5, promptTokens=73, completion promptTokens=73, completionTokens=43, modelName=deeplx-EN, tokenName=, quota=10080, content=Model multiplier 30.00, grouping multiplier 1.50, completion multiplier 3.50\nnew-api | [GIN] 2024/06/06 - 19:58:37 | 20240606195834392896377WKncyB5D | 200 | 3.229631289s | 129.146.121.123 | POST /v1/chat/completions\ndevincopilot | 172.22.0.1 - - [06/Jun/2024 19:58:58] "GET / HTTP/1.1" 404 -', 'role': 'assistant'}, {'content': '用中文', 'role': 'user'}], 'stream': True, 'model': 'deeplx-EN'} INFO: 172.22.0.1:44624 - "POST /v1/chat/completions HTTP/1.1" 200 OK INFO:root:Translation from to EN took: 0.5394253730773926

Hk-Gosuto commented 2 months ago

你是直接在页面上配置的自定义接口是吧,那里有本身浏览器的限制,比如你的接口协议需要跟你页面协议一致(页面是https的那定义的接口也要是https的),服务器必须支持访问域名的CORS策略(我看了以下,那个项目应该是没配置相关的fastapi中间件)。 如果不想有上述麻烦可以直接配置环境变量中的 BASE_URLCUSTOM_MODELS

Issues-translate-bot commented 2 months ago

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


You configured the custom interface directly on the page, right? There are limitations of the browser itself. For example, your interface protocol needs to be consistent with your page protocol (if the page is https, the defined interface must also be https). The server must Support CORS policy for accessing domain names (I read the following, that project should not be configured with related fastapi middleware). If you don’t want to have the above trouble, you can directly configure BASE_URL and CUSTOM_MODELS in the environment variables.

AthanaD commented 2 months ago

你是直接在页面上配置的自定义接口是吧,那里有本身浏览器的限制,比如你的接口协议需要跟你页面协议一致(页面是https的那定义的接口也要是https的),服务器必须支持访问域名的CORS策略(我看了以下,那个项目应该是没配置相关的fastapi中间件)。 如果不想有上述麻烦可以直接配置环境变量中的 BASE_URLCUSTOM_MODELS

我的配置都是好的,而且我在nginx及cloudflare里边已经设置了cors规则,我是采用new-api令牌直接打开自动带有接口及密钥的,还是出错,现在发现很多模型出错,包括claude3系列、deeplx系列、gpts系列等 image

` new-api: image: calciumion/new-api:latest container_name: new-api restart: always command: --log-dir /app/logs networks: mynet: ipv4_address: x.x.x.x ports:

Hk-Gosuto commented 2 months ago

cloudflare 转发我记得是有一些问题,你可以搜索一下以前的 issues,还有就是你说的其他模型调用会出错的问题,因为你是用的中转服务,而中转服务会将接口统一为 openai 的路由规则,原项目对 Claude Gemini 这类模型的路由做了处理,导致中转的接口但凡模型名匹配上了都会强制使用对应服务的接口路由。

关于多提供方模型的路由不一致的问题可以看下我今天新加的环境变量:https://github.com/Hk-Gosuto/ChatGPT-Next-Web-LangChain?tab=readme-ov-file#next_public_use_openai_endpoint_for_all_models-%E5%8F%AF%E9%80%89 不过 docker 镜像还没跑,你可以本地用源码跑一下试试。

关于DeepLXToV1Api转发的接口调用错误,我在本地通过源码运行了一个加了CORS中间件的版本,在页面配置接口和环境变量两种形式都是可以正常调用的。

Issues-translate-bot commented 2 months ago

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


I remember that there are some problems with cloudflare forwarding. You can search for previous issues, and there is also the problem that you mentioned that other model calls will go wrong, because you are using a transit service, and the transit service will unify the interface into openai routing. According to the rules, the original project processed the routing of models such as Claude Gemini, which resulted in the transit interface being forced to use the interface routing of the corresponding service whenever the model name matched.

Regarding the issue of inconsistent routing of multi-provider models, you can take a look at the environment variables I added today: https://github.com/Hk-Gosuto/ChatGPT-Next-Web-LangChain?tab=readme-ov-file#next_public_use_openai_endpoint_for_all_models -%E5%8F%AF%E9%80%89 However, the docker image has not been run yet. You can try running it locally using the source code.

Regarding the interface call error forwarded by DeepLXToV1Api, I ran a version with CORS middleware locally through the source code. Both the interface and environment variables configured on the page can be called normally.

AthanaD commented 2 months ago

cloudflare 转发我记得是有一些问题,你可以搜索一下以前的 issues,还有就是你说的其他模型调用会出错的问题,因为你是用的中转服务,而中转服务会将接口统一为 openai 的路由规则,原项目对 Claude Gemini 这类模型的路由做了处理,导致中转的接口但凡模型名匹配上了都会强制使用对应服务的接口路由。

关于多提供方模型的路由不一致的问题可以看下我今天新加的环境变量:https://github.com/Hk-Gosuto/ChatGPT-Next-Web-LangChain?tab=readme-ov-file#next_public_use_openai_endpoint_for_all_models-%E5%8F%AF%E9%80%89 不过 docker 镜像还没跑,你可以本地用源码跑一下试试。

关于DeepLXToV1Api转发的接口调用错误,我在本地通过源码运行了一个加了CORS中间件的版本,在页面配置接口和环境变量两种形式都是可以正常调用的。 通过postman是可以直接调用的,就是通过chatgpt-next部分模型会出现错误,我在nginx及cloudflare里边都增加了cors规则的,我加了你说的- NEXT_PUBLIC_USE_OPENAI_ENDPOINT_FOR_ALL_MODELS=1变量还是不行。之前一直可以用,最近不晓得更新到哪版了不能用了。

Request URL: https://xxxx.com/v1/chat/completions Referrer Policy: strict-origin-when-cross-origin Accept: application/json, text/event-stream Authorization: Bearer sk-xxxxxx Content-Type: application/json Referer: https://ai.xxxx.com/ Sec-Ch-Ua: "Google Chrome";v="125", "Chromium";v="125", "Not.A/Brand";v="24" Sec-Ch-Ua-Mobile: ?0 Sec-Ch-Ua-Platform: "Windows" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 X-Requested-With: XMLHttpRequest image

[User Input] after template: 中国在哪里 page-a0c40468e4720506.js:1 [Request] openai payload: {messages: Array(1), stream: true, model: 'deeplx-EN', temperature: 0.5, presence_penalty: 0, …}frequency_penalty: 0messages: [{…}]model: "deeplx-EN"presence_penalty: 0stream: truetemperature: 0.5top_p: 1[[Prototype]]: Object page-a0c40468e4720506.js:1 [Proxy Endpoint] https://xxxx.com v1/chat/completions /#/:1 Access to fetch at 'https://xxxx.com/v1/chat/completions' from origin 'https://ai.xxxx.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values ', ', but only one is allowed. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. main.js?attr=0YUU-I8bHiJJsWXXXXXl6j2zzAtVpiZ8bps4vWDVPV8QsZJc:4114

   POST https://xxxx.com/v1/chat/completions net::ERR_FAILED

fetchCallImpl @ main.js?attr=0YUU-I8bHiJJsW2-Z9lMssV78Y5ZxSSeFoXXXXXSIsCl6j2zzAtVpiZ8bps4vWDVPV8QsZJc:4114 fetch @ main.js?attr=0YUU-I8bHiJJsW2-Z9lMssXXXXXV78Y5ZxeFoIsCl6j2zzAtVpiZ8bps4vWDVPV8QsZJc:4120 create @ 3616-0b8d0915abf28a7b.js:64 (anonymous) @ 3616-0b8d0915abf28a7b.js:64 fetchEventSource @ 3616-0b8d0915abf28a7b.js:64 chat @ page-a0c40468e4720506.js:1 onUserInput @ page-a0c40468e4720506.js:1 doSubmit @ 8696.cebab47a00152e04.js:1 onKeyDown @ 8696.cebab47a00152e04.js:1 fi @ fd9d1056-f2f795bbdbec88ac.js:9 li @ fd9d1056-f2f795bbdbec88ac.js:9 (anonymous) @ fd9d1056-f2f795bbdbec88ac.js:9 fn @ fd9d1056-f2f795bbdbec88ac.js:9 sm @ fd9d1056-f2f795bbdbec88ac.js:9 (anonymous) @ fd9d1056-f2f795bbdbec88ac.js:9 Xj @ fd9d1056-f2f795bbdbec88ac.js:9 Jk @ fd9d1056-f2f795bbdbec88ac.js:9 Tl @ fd9d1056-f2f795bbdbec88ac.js:9 Rl @ fd9d1056-f2f795bbdbec88ac.js:9 Ql @ fd9d1056-f2f795bbdbec88ac.js:9 2472-a3c580a96754bcde.js:1 [Chat] failed TypeError: Failed to fetch at fetchCallImpl (main.js?attr=0YUU-I8bHiJJsW2-Z9lMssVSSS78Y5ZxeFoIsCl6j2zzAtVpiZ8bps4vWDVPV8QsZJc:4114:21) at fetch (main.js?attr=0YUU-I8bHiJJsW2-Z9lMssV78Y5ZxeWFoIsCl6DDDSWj2zzAtVpiZ8bps4vWDVPV8QsZJc:4120:60) at create (3616-0b8d0915abf28a7b.js:64:24291) at 3616-0b8d0915abf28a7b.js:64:25404 at new Promise () at fetchEventSource (3616-0b8d0915abf28a7b.js:64:23705) at ChatGPTApi.chat (page-a0c40468e4720506.js:1:41514) at Object.onUserInput (page-a0c40468e4720506.js:1:271001) at doSubmit (8696.cebab47a00152e04.js:1:61115) at onKeyDown (8696.cebab47a00152e04.js:1:73277) window.console.error @ 2472-a3c580a96754bcde.js:1 onError @ page-a0c40468e4720506.js:1 onerror @ page-a0c40468e4720506.js:1 create @ 3616-0b8d0915abf28a7b.js:64 await in create (async) (anonymous) @ 3616-0b8d0915abf28a7b.js:64 fetchEventSource @ 3616-0b8d0915abf28a7b.js:64 chat @ page-a0c40468e4720506.js:1 onUserInput @ page-a0c40468e4720506.js:1 doSubmit @ 8696.cebab47a00152e04.js:1 onKeyDown @ 8696.cebab47a00152e04.js:1 fi @ fd9d1056-f2f795bbdbec88ac.js:9 li @ fd9d1056-f2f795bbdbec88ac.js:9 (anonymous) @ fd9d1056-f2f795bbdbec88ac.js:9 fn @ fd9d1056-f2f795bbdbec88ac.js:9 sm @ fd9d1056-f2f795bbdbec88ac.js:9 (anonymous) @ fd9d1056-f2f795bbdbec88ac.js:9 Xj @ fd9d1056-f2f795bbdbec88ac.js:9 Jk @ fd9d1056-f2f795bbdbec88ac.js:9 Tl @ fd9d1056-f2f795bbdbec88ac.js:9 Rl @ fd9d1056-f2f795bbdbec88ac.js:9 Ql @ fd9d1056-f2f795bbdbec88ac.js:9 3616-0b8d0915abf28a7b.js:64

   Uncaught (in promise) TypeError: Failed to fetch
at fetchCallImpl (main.js?attr=0YUU-I8bHiJJsW2-Z9WWSDSlMssV78Y5ZxeFoIsCl6j2zzAtVpiZ8bps4vWDVPV8QsZJc:4114:21)
at fetch (main.js?attr=0YUU-I8bHiJJsW2-Z9lMssV78Y5ZxeFoIsDSFSCl6j2zzAtVpiZ8bps4vWDVPV8QsZJc:4120:60)
at create (3616-0b8d0915abf28a7b.js:64:24291)
at 3616-0b8d0915abf28a7b.js:64:25404
at new Promise (<anonymous>)
at fetchEventSource (3616-0b8d0915abf28a7b.js:64:23705)
at ChatGPTApi.chat (page-a0c40468e4720506.js:1:41514)
at Object.onUserInput (page-a0c40468e4720506.js:1:271001)
at doSubmit (8696.cebab47a00152e04.js:1:61115)
at onKeyDown (8696.cebab47a00152e04.js:1:73277)

fetchCallImpl @ main.js?attr=0YUU-I8bHiJJsW2-Z9lMssV78SFFDY5ZxeFoIsCl6j2zzAtVpiZ8bps4vWDVPV8QsZJc:4114 fetch @ main.js?attr=0YUU-I8bHiJJsW2-Z9lMssV78Y5ZxeFoIsSFSCl6j2zzAtVpiZ8bps4vWDVPV8QsZJc:4120 create @ 3616-0b8d0915abf28a7b.js:64 (anonymous) @ 3616-0b8d0915abf28a7b.js:64 fetchEventSource @ 3616-0b8d0915abf28a7b.js:64 chat @ page-a0c40468e4720506.js:1 onUserInput @ page-a0c40468e4720506.js:1 doSubmit @ 8696.cebab47a00152e04.js:1 onKeyDown @ 8696.cebab47a00152e04.js:1 fi @ fd9d1056-f2f795bbdbec88ac.js:9 li @ fd9d1056-f2f795bbdbec88ac.js:9 (anonymous) @ fd9d1056-f2f795bbdbec88ac.js:9 fn @ fd9d1056-f2f795bbdbec88ac.js:9 sm @ fd9d1056-f2f795bbdbec88ac.js:9 (anonymous) @ fd9d1056-f2f795bbdbec88ac.js:9 Xj @ fd9d1056-f2f795bbdbec88ac.js:9 Jk @ fd9d1056-f2f795bbdbec88ac.js:9 Tl @ fd9d1056-f2f795bbdbec88ac.js:9 Rl @ fd9d1056-f2f795bbdbec88ac.js:9 Ql @ fd9d1056-f2f795bbdbec88ac.js:9 await in Ql (async) (anonymous) @ 3616-0b8d0915abf28a7b.js:64 fetchEventSource @ 3616-0b8d0915abf28a7b.js:64 chat @ page-a0c40468e4720506.js:1 onUserInput @ page-a0c40468e4720506.js:1 doSubmit @ 8696.cebab47a00152e04.js:1 onKeyDown @ 8696.cebab47a00152e04.js:1 fi @ fd9d1056-f2f795bbdbec88ac.js:9 li @ fd9d1056-f2f795bbdbec88ac.js:9 (anonymous) @ fd9d1056-f2f795bbdbec88ac.js:9 fn @ fd9d1056-f2f795bbdbec88ac.js:9 sm @ fd9d1056-f2f795bbdbec88ac.js:9 (anonymous) @ fd9d1056-f2f795bbdbec88ac.js:9 Xj @ fd9d1056-f2f795bbdbec88ac.js:9 Jk @ fd9d1056-f2f795bbdbec88ac.js:9 Tl @ fd9d1056-f2f795bbdbec88ac.js:9 Rl @ fd9d1056-f2f795bbdbec88ac.js:9 Ql @ fd9d1056-f2f795bbdbec88ac.js:9 page-a0c40468e4720506.js:1 [Response Animation] finished 2472-a3c580a96754bcde.js:1 [Chat] failed Error: empty response from server at animateResponseText (page-a0c40468e4720506.js:1:41210) window.console.error @ 2472-a3c580a96754bcde.js:1 onError @ page-a0c40468e4720506.js:1 animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1 requestAnimationFrame (async) animateResponseText @ page-a0c40468e4720506.js:1

image image

AthanaD commented 2 months ago

已经在大佬指点下解决了,nginx里边的跨域名cors以下内容全部注释即可:

add_header 'Access-Control-Allow-Origin' '*' always;