missuo / FreeDuckDuckGo

Use DuckDuckGo for free with GPT-3.5-Turbo.
GNU General Public License v3.0
220 stars 70 forks source link

新建聊天能回答一个问题,再问就一直转圈,新建又能回一个 #6

Open AndyLin2020 opened 6 months ago

AndyLin2020 commented 6 months ago

image

[GIN] 2024/04/26 - 06:11:49 | 200 | 619.363904ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:14:25 | 200 | 620.438259ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:15:16 | 200 | 614.078189ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:15:36 | 200 | 619.040184ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:01 | 200 | 1.141081884s | 172.17.0.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:19 | 200 | 391.737389ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:47 | 200 | 1.374173187s | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:47 | 200 | 395.143206ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:57 | 200 | 389.18794ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:17:22 | 200 | 611.181902ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:17:50 | 200 | 1.455132947s | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:17:50 | 200 | 388.303886ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:18:03 | 200 | 390.574465ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:21:12 | 200 | 1.851210792s | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:21:14 | 200 | 633.835385ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:21:19 | 200 | 384.861983ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:21:33 | 200 | 405.651232ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:22:03 | 200 | 1.811933982s | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:22:03 | 200 | 395.354218ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:22:28 | 200 | 650.900638ms | 192.168.100.1 | POST "/v1/chat/completions"

missuo commented 6 months ago

目前确实存在一些问题,有空我再看看能不能修复,最近期末周确实非常忙,实在抱歉。

AndyLin2020 commented 6 months ago

目前确实存在一些问题,有空我再看看能不能修复,最近期末周确实非常忙,实在抱歉。

谢谢大神

gochendong commented 6 months ago

here is the error log {"action":"error","status":400,"type":"ERR_INVALID_VQD"} It seems x-vqd-4 in request header must be continuous, like a linked list

maimengmeng commented 6 months ago

image

[GIN] 2024/04/26 - 06:11:49 | 200 | 619.363904ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:14:25 | 200 | 620.438259ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:15:16 | 200 | 614.078189ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:15:36 | 200 | 619.040184ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:01 | 200 | 1.141081884s | 172.17.0.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:19 | 200 | 391.737389ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:47 | 200 | 1.374173187s | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:47 | 200 | 395.143206ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:57 | 200 | 389.18794ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:17:22 | 200 | 611.181902ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:17:50 | 200 | 1.455132947s | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:17:50 | 200 | 388.303886ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:18:03 | 200 | 390.574465ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:21:12 | 200 | 1.851210792s | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:21:14 | 200 | 633.835385ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:21:19 | 200 | 384.861983ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:21:33 | 200 | 405.651232ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:22:03 | 200 | 1.811933982s | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:22:03 | 200 | 395.354218ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:22:28 | 200 | 650.900638ms | 192.168.100.1 | POST "/v1/chat/completions"

+1,大神的这个项目成功解决了freegpt35在我的小鸡上不能用的问题。我也遇到了和楼主同样的问题,只有在next-web中,将附带历史消息数设为0,才能一问一答正常对话。另外作为API使用时,好像不能跨域使用

AndyLin2020 commented 6 months ago

就是不支持上下文。

ChatGPT: 根据DuckDuckGo的隐私保护措施,用户的聊天是完全匿名的,不会被记录。DuckDuckGo不会保存任何包含可识别信息的元数据,因此Open AI也无法追溯到任何特定个人。用户输入的个人信息也是匿名的,无法确定是用户自己输入还是其他人输入。Open AI已同意不使用通过DuckDuckGo进行的聊天来训练或改进模型。

weisonyoung commented 6 months ago

图像 [杜松子酒] 2024/04/26 - 06:11:49 | 200 | 200 619.363904ms | 192.168.100.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:14:25 | 200 | 200 620.438259 毫秒 | 192.168.100.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:15:16 | 200 | 200 614.078189ms | 192.168.100.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:15:36 | 200 | 200 619.040184ms | 192.168.100.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:16:01 | 200 | 200 1.141081884s | 172.17.0.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:16:19 | 200 | 200 391.737389 毫秒 | 192.168.100.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:16:47 | 200 | 200 1.374173187s | 192.168.100.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:16:47 | 200 | 200 395.143206 毫秒 | 192.168.100.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:16:57 | 200 | 200 389.18794 毫秒 | 192.168.100.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:17:22 | 200 | 200 611.181902ms | 192.168.100.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:17:50 | 200 | 200 1.455132947s | 192.168.100.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:17:50 | 200 | 200 388.303886ms | 192.168.100.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:18:03 | 200 | 200 390.574465 毫秒 | 192.168.100.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:21:12 | 200 | 200 1.851210792s | 192.168.100.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:21:14 | 200 | 200 633.835385 毫秒 | 192.168.100.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:21:19 | 200 | 200 384.861983ms | 192.168.100.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:21:33 | 200 | 200 405.651232 毫秒 | 192.168.100.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:22:03 | 200 | 200 1.811933982s | 192.168.100.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:22:03 | 200 | 200 395.354218 毫秒 | 192.168.100.1 |发布“/v1/chat/completions”[GIN] 2024/04/26 - 06:22:28 | 200 | 200 650.900638 毫秒 | 192.168.100.1 | POST “/v1/chat/completions”

+1,大神的这个项目成功解决了freegpt35在我的小鸡上不能用的问题。我也遇到了和楼主同样的问题,只有在next-web中,将附带历史消息数设为0,才能一问一答正常对话。其他API作为使用时,希望不能跨域使用

Yes, I have also encountered this problem, but I have solved it. Adding the http request method of options in the main.go file can solve the cross-domain problem.

Niansuh commented 6 months ago

@weisonyoung give code please

weisonyoung commented 6 months ago

@weisonyoung give code please

https://github.com/weisonyoung/FreeDuckDuckGo/blob/main/main.go

weisonyoung commented 6 months ago

@weisonyoung give code please

r.OPTIONS("/v1/chat/completions", func(c *gin.Context) {
    c.JSON(http.StatusOK, gin.H{
        "message": "ok",
    })
})

image [GIN] 2024/04/26 - 06:11:49 | 200 | 619.363904ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:14:25 | 200 | 620.438259ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:15:16 | 200 | 614.078189ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:15:36 | 200 | 619.040184ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:01 | 200 | 1.141081884s | 172.17.0.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:19 | 200 | 391.737389ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:47 | 200 | 1.374173187s | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:47 | 200 | 395.143206ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:57 | 200 | 389.18794ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:17:22 | 200 | 611.181902ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:17:50 | 200 | 1.455132947s | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:17:50 | 200 | 388.303886ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:18:03 | 200 | 390.574465ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:21:12 | 200 | 1.851210792s | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:21:14 | 200 | 633.835385ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:21:19 | 200 | 384.861983ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:21:33 | 200 | 405.651232ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:22:03 | 200 | 1.811933982s | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:22:03 | 200 | 395.354218ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:22:28 | 200 | 650.900638ms | 192.168.100.1 | POST "/v1/chat/completions"

+1,大神的这个项目成功解决了freegpt35在我的小鸡上不能用的问题。我也遇到了和楼主同样的问题,只有在next-web中,将附带历史消息数设为0,才能一问一答正常对话。另外作为API使用时,好像不能跨域使用

你知道在nextChat中如何将默认的附带历史消息数设为0吗,我似乎没找到哪个环境变量中有定义

maimengmeng commented 6 months ago

@weisonyoung give code please

r.OPTIONS("/v1/chat/completions", func(c *gin.Context) {
  c.JSON(http.StatusOK, gin.H{
      "message": "ok",
  })
})

image [GIN] 2024/04/26 - 06:11:49 | 200 | 619.363904ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:14:25 | 200 | 620.438259ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:15:16 | 200 | 614.078189ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:15:36 | 200 | 619.040184ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:01 | 200 | 1.141081884s | 172.17.0.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:19 | 200 | 391.737389ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:47 | 200 | 1.374173187s | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:47 | 200 | 395.143206ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:16:57 | 200 | 389.18794ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:17:22 | 200 | 611.181902ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:17:50 | 200 | 1.455132947s | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:17:50 | 200 | 388.303886ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:18:03 | 200 | 390.574465ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:21:12 | 200 | 1.851210792s | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:21:14 | 200 | 633.835385ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:21:19 | 200 | 384.861983ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:21:33 | 200 | 405.651232ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:22:03 | 200 | 1.811933982s | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:22:03 | 200 | 395.354218ms | 192.168.100.1 | POST "/v1/chat/completions" [GIN] 2024/04/26 - 06:22:28 | 200 | 650.900638ms | 192.168.100.1 | POST "/v1/chat/completions"

+1,大神的这个项目成功解决了freegpt35在我的小鸡上不能用的问题。我也遇到了和楼主同样的问题,只有在next-web中,将附带历史消息数设为0,才能一问一答正常对话。另外作为API使用时,好像不能跨域使用

你知道在nextChat中如何将默认的附带历史消息数设为0吗,我似乎没找到哪个环境变量中有定义

在这里 微信截图_20240508075630

Niansuh commented 6 months ago

set 0 this line https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/blob/main/app/store/config.ts#L56

can you give me full code of FreeDuckDuckGo

weisonyoung commented 6 months ago

set 0 this line https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/blob/main/app/store/config.ts#L56

can you give me full code of FreeDuckDuckGo Of course :) https://github.com/weisonyoung/FreeDuckDuckGo/blob/main/main.go

Cp0204 commented 6 months ago

研究了下 https://duckduckgo.com/duckchat/v1/chat 的机制

每次请求会返回一个 x-vqd-4 ,下次提交要带上一次返回的 x-vqd-4

如果改动了上一轮对话,和给的 x-vqd-4 不对应,就会报 ERR_INVALID_VQD

x-vqd-4 有可能是对历史对话的某种加密验证串,也就意味着不能篡改对话,这个机制要适配API多轮对话挺难的

其中的 vqd ,我猜有可能就是 verify quest/question data 的意思

Cp0204 commented 6 months ago

继上,因为 openai 的 API 是直接可以提交多组对话的,而因为 x-vqd-4 的验证只能一轮一轮来。

也有方法,在服务端保存每组对话的 x-vqd-4,当客户端提交匹配时,就拿出来带上给 duck

这个方法仍然存在bug,就是例如NextWeb会压缩总结历史(等于篡改了历史对话),也会ERR_INVALID_VQD

Niansuh commented 6 months ago

set 0 this line https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/blob/main/app/store/config.ts#L56 can you give me full code of FreeDuckDuckGo Of course :) https://github.com/weisonyoung/FreeDuckDuckGo/blob/main/main.go

Thanks Bro if i edit this chat message to zero it will work fine good

also edit like this commit

https://github.com/NiansuhAI/LLMs/commit/9e85299abff1b89d7bc2dbcdf6f089dc2d59cdca

learnLi commented 6 months ago

只能像newbing的内容拼接方式,把所有内容拼接到messages[0].content = "user:xxx;\r\n assistant:xxx;\r\n” duckgo的x-vqd-4只能给第一轮使用,后面如果要原味的上下文,需要附带上一次响应中响应头返回的x-vqd-4才可以继续。

Cp0204 commented 6 months ago

只能像newbing的内容拼接方式,把所有内容拼接到messages[0].content = "user:xxx;\r\n assistant:xxx;\r\n” duckgo的x-vqd-4只能给第一轮使用,后面如果要原味的上下文,需要附带上一次响应中响应头返回的x-vqd-4才可以继续。

这个方法也不错,至少简单地解决了上文内容提交的问题

vicoqi commented 6 months ago

the same problem i encountered

Cp0204 commented 6 months ago

Hi, I have improved these issues, but I don't want them to be abused, so I'll just post them here.

docker run -d \ --name freeduckpy\ -p 3456:3456 \ -e MY_TOKEN=123456 \ -e HTTP_PROXY=http://127.0.0.1:10808 \ -e HTTPS_PROXY=http://127.0.0.1:10808 \ ghcr.io/cp0204/freeduckpy:main

Please don't share this anywhere else or I may remove it. Only offer it to people who are trying very hard to find a solution, like you who flipped here.

If it has been helpful to you, please give me an emoji to let me know that it exists meaningfully.

weisonyoung commented 5 months ago

Hi, I have improved these issues, but I don't want them to be abused, so I'll just post them here.

docker run -d --name freeduckpy -p 3456:3456 -e MY_TOKEN=123456 -e HTTP_PROXY=http://127.0.0.1:10808 -e HTTPS_PROXY=http://127.0.0.1:10808 ghcr.io/cp0204/freeduckpy:main

Thx :)

weisonyoung commented 5 months ago

Hi, I have improved these issues, but I don't want them to be abused, so I'll just post them here.

docker run -d --name freeduckpy -p 3456:3456 -e MY_TOKEN=123456 -e HTTP_PROXY=http://127.0.0.1:10808 -e HTTPS_PROXY=http://127.0.0.1:10808 ghcr.io/cp0204/freeduckpy:main

Hi brother, gpt seems to have made some changes, and it has been invalid for the past two days. {"error":"Failed to get vqd4"}

Cp0204 commented 5 months ago

Hi, I have improved these issues, but I don't want them to be abused, so I'll just post them here. docker run -d --name freeduckpy -p 3456:3456 -e MY_TOKEN=123456 -e HTTP_PROXY=http://127.0.0.1:10808 -e HTTPS_PROXY=http://127.0.0.1:10808 ghcr.io/cp0204/freeduckpy:main

Hi brother, gpt seems to have made some changes, and it has been invalid for the past two days. {"error":"Failed to get vqd4"}

It's fixed, please pull the latest image and try again

Cp0204 commented 5 months ago

I've just updated new version to support more models

MODELS = { "gpt-3.5-turbo-0125", "claude-3-haiku-20240307", "meta-llama/Llama-3-70b-chat-hf", "mistralai/Mixtral-8x7B-Instruct-v0.1", }

weisonyoung commented 5 months ago

claude-3-haiku-20240307

Thanks, brother. I get an error when using the claude-3-haiku-20240307 model.

"<!doctype html> 404 Not Found

Not Found

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

"

GPT3.5 works fine, which is enough for me. Thanks again.

Cp0204 commented 5 months ago

claude-3-haiku-20240307

Thanks, brother. I get an error when using the claude-3-haiku-20240307 model.

"<!doctype html> 404 Not Found

Not Found

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

" GPT3.5 works fine, which is enough for me. Thanks again.

Sorry, I wasn't clear, I didn't adapt the claude api separately.

I got lazy 🤪 and used different models by changing the model fields directly using the openai api format

Cp0204 commented 5 months ago

@weisonyoung

I have done some adaptation work, now you can use the Claude API, both ways are possible

I got lazy 🤪 and used different models by changing the model fields directly using the openai api format

weisonyoung commented 5 months ago

@weisonyoung

我已经做了一些适配工作,现在你可以使用Claude API,两种方式都可以

我太懒了🤪,直接使用 openai api 格式更改模型字段来使用不同的模型

so cool !!!