Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0-beta 版 bing 报错 #79

Closed
denniszlei opened this issue Dec 11, 2024 · 16 comments
Closed

3.0-beta 版 bing 报错 #79

denniszlei opened this issue Dec 11, 2024 · 16 comments

Comments

@denniszlei
Copy link

成功部署3.0-beta,尝试了blackbox, cursor, lmsys,都很好,但是bing无法使用,一直报错 "websocket: close 1000 (normal)"。

vps环境:美国IP,套warp和裸连都试过;
accessToken:抓取header里面的Authrization: Bearer XXXXXX;
本地挂代理访问copilot.microsoft.com正常,chat正常;

具体报错如下:

{
    "error": {
        "message": "websocket: close 1000 (normal)"
    }
}

docker的log 如下:

2024-12-11 06:37:22 <chatgpt-adapter/core> gin/initializer.go:76 | [INFO] ------ START REQUEST 3a9bfe37-1a3f-44e8-8317-d2df9cf7c96d ---------
[GIN] 2024/12/11 - 06:37:53 | 500 | 30.364463329s |  192.168.XXX.XXX | POST     "/v1/chat/completions"
POST /v1/chat/completions HTTP/1.1
Host: 10.0.XXX.XXX:18085

Accept: */*
Accept-Encoding: gzip, deflate, br
Authorization: eyXXXXXXXX
Connection: keep-alive
Content-Length: 121
Content-Type: application/json
Postman-Token: c895afe3-b619-48ee-85f2-f46b85f9fde0
User-Agent: PostmanRuntime/7.42.0
2024-12-11 06:37:23 <chatgpt-adapter/relay/llm> bing/message.go:59 | [INFO] waitResponse ...
2024-12-11 06:37:53 <chatgpt-adapter/relay/llm> bing/message.go:153 | [ERRO] websocket: close 1000 (normal)
2024-12-11 06:37:53 <chatgpt-adapter/core> gin/initializer.go:83 | [INFO] ------ END REQUEST 3a9bfe37-1a3f-44e8-8317-d2df9cf7c96d ---------

分别截图如下:
Snipaste_2024-12-11_14-43-56
Snipaste_2024-12-11_14-46-31

@bincooo
Copy link
Owner

bincooo commented Dec 11, 2024

复现了,应该是加了验证

@reccea
Copy link

reccea commented Dec 23, 2024

这个问题有解决办法吗?

bincooo pushed a commit that referenced this issue Dec 28, 2024
@bincooo
Copy link
Owner

bincooo commented Dec 28, 2024

已更新,欢迎测验

@reccea
Copy link

reccea commented Dec 29, 2024

已更新,欢迎测验

docker能不能升级到3.0版?

@bincooo
Copy link
Owner

bincooo commented Dec 29, 2024

只有latest

建议自行构建,deploy目录有提供Dockerfile文件

@reccea
Copy link

reccea commented Dec 29, 2024

只有latest

建议自行构建,deploy目录有提供Dockerfile文件

在bing或copilot登陆后F12网络面板处 没找到/common/oauth2/v2.0/token
倒是找到 wss://copilot.microsoft.com/c/api/chat?api-version=2&accessToken=eyxxxxxx
用这里面的accessToken做为${authorization}后提示:{"error":{"message":"refresh token is unauthorized"}}
请问要怎么解决?

@bincooo
Copy link
Owner

bincooo commented Dec 29, 2024

试试脚本获取:

let token = '';
for (var i = 0; i < localStorage.length; i++) {
    const key = localStorage.key(i);
    if (token == '' && key.includes('login.windows.net-accesstoken')) {
    	const obj = JSON.parse(localStorage.getItem(key));
    	token += obj.clientId + '|' + obj.target.split('/')[0];
    }
    if (token != '' && key.includes('login.windows.net-refreshtoken')) {
    	const obj = JSON.parse(localStorage.getItem(key));
    	token += '|' + obj.secret;
    }
}
console.log('token:', token);

@denniszlei
Copy link
Author

试了一下,还是不行,有两个问题:

  1. 控制台脚本运行后,拿到的第二个字段Scope是User.Read openid profile email且第三串字段refreshtoken没抓到(可能是我的问题)。仔细观察,在 应用程序->本地存储 下面有两个几乎一样的key value对,前一串是貌似正确的scope id,后一个scope就是错误的User.Read openid profile email,手动复制正确的scope,并修改token内容,实际得到的最终token为14638111-XXXX-XXXX-XXXX-XXXXXXXX|140XXXXX-4XXX-4XXX-bXXX-3eXXXXXXXX|M.C560_BL2.0.U.-XXXXXX省略一大串,可以考虑网页脚本是否需要优化一下?
    image

  2. 构造完整url的回复还是401 Unauthorized,截图如下:
    image

docker log截图如下:
image

PS, 本地浏览器访问copilot.microsoft.com抓取token的时候用的是机场的ip,docker运行chatgpt-adapter用的是另外的vps,两个IP肯定不同,不晓得有没有影响,供参考。

@bincooo
Copy link
Owner

bincooo commented Dec 30, 2024

let token = '';
for (var i = 0; i < localStorage.length; i++) {
    const key = localStorage.key(i);
    if (token == '' && key.includes('login.windows.net-accesstoken') && key.includes('chatai.readwrite')) {
    	const obj = JSON.parse(localStorage.getItem(key));
    	token += obj.clientId + '|' + obj.target.split('/')[0];
    }
}
for (var i = 0; i < localStorage.length; i++) {
    const key = localStorage.key(i);
    if (token != '' && key.includes('login.windows.net-refreshtoken')) {
    	const obj = JSON.parse(localStorage.getItem(key));
    	token += '|' + obj.secret;
    }
}
console.log('token:', token);

@bincooo
Copy link
Owner

bincooo commented Dec 30, 2024

这是huggingface上部署的,你可以先到这里试试:https://huggingface.co/spaces/wIK5Ez2o/DEMO/blob/main/Dockerfile

@denniszlei
Copy link
Author

用你部署在huggingface上的服务没问题,棒~!

可能是因为我在甲骨文的arm上部署自己的docker镜像,发现chrome没有arm版就省略了# Install google# 下载过盾文件 两个步骤,直接运行的server-arm64,晚点找个x86试试,感谢。

@reccea
Copy link

reccea commented Dec 30, 2024

let token = '';
for (var i = 0; i < localStorage.length; i++) {
    const key = localStorage.key(i);
    if (token == '' && key.includes('login.windows.net-accesstoken') && key.includes('chatai.readwrite')) {
    	const obj = JSON.parse(localStorage.getItem(key));
    	token += obj.clientId + '|' + obj.target.split('/')[0];
    }
}
for (var i = 0; i < localStorage.length; i++) {
    const key = localStorage.key(i);
    if (token != '' && key.includes('login.windows.net-refreshtoken')) {
    	const obj = JSON.parse(localStorage.getItem(key));
    	token += '|' + obj.secret;
    }
}
console.log('token:', token);

用这个取到的token,M.Cxxxxxx ,用了这个值,还是提示: {"error":{"message":"refresh token is unauthorized"}}
这样还不对吗?

@bincooo
Copy link
Owner

bincooo commented Dec 30, 2024

let token = '';
for (var i = 0; i < localStorage.length; i++) {
    const key = localStorage.key(i);
    if (token == '' && key.includes('login.windows.net-accesstoken') && key.includes('chatai.readwrite')) {
    	const obj = JSON.parse(localStorage.getItem(key));
    	token += obj.clientId + '|' + obj.target.split('/')[0];
    }
}
for (var i = 0; i < localStorage.length; i++) {
    const key = localStorage.key(i);
    if (token != '' && key.includes('login.windows.net-refreshtoken')) {
    	const obj = JSON.parse(localStorage.getItem(key));
    	token += '|' + obj.secret;
    }
}
console.log('token:', token);

用这个取到的token,M.Cxxxxxx ,用了这个值,还是提示: {"error":{"message":"refresh token is unauthorized"}} 这样还不对吗?

你的账号是pro嘛?不是的话介意发给我排查一下

你是不是没传对地方,这个错误只在格式检查的时候会出现:
Screenshot 2024-12-30 at 19 11 52

你看看是否在 Authorization请求头正确传入?
Screenshot 2024-12-30 at 19 12 48

@reccea
Copy link

reccea commented Dec 30, 2024

let token = '';
for (var i = 0; i < localStorage.length; i++) {
    const key = localStorage.key(i);
    if (token == '' && key.includes('login.windows.net-accesstoken') && key.includes('chatai.readwrite')) {
    	const obj = JSON.parse(localStorage.getItem(key));
    	token += obj.clientId + '|' + obj.target.split('/')[0];
    }
}
for (var i = 0; i < localStorage.length; i++) {
    const key = localStorage.key(i);
    if (token != '' && key.includes('login.windows.net-refreshtoken')) {
    	const obj = JSON.parse(localStorage.getItem(key));
    	token += '|' + obj.secret;
    }
}
console.log('token:', token);

用这个取到的token,M.Cxxxxxx ,用了这个值,还是提示: {"error":{"message":"refresh token is unauthorized"}} 这样还不对吗?

你的账号是pro嘛?不是的话介意发给我排查一下

你是不是没传对地方,这个错误只在格式检查的时候会出现: Screenshot 2024-12-30 at 19 11 52

你看看是否在 Authorization请求头正确传入? Screenshot 2024-12-30 at 19 12 48

我知道原因了,你那个js取到的结果是:client_id | scope_id | refresh_token
我之前是把client_id | scope_id | 删除,只留了refresh_token当作${authorization},所以报那个错。如果把client_id | scope_id | refresh_token整个字符串当作${authorization},就可以正常运行。

@reccea
Copy link

reccea commented Dec 30, 2024

let token = '';
for (var i = 0; i < localStorage.length; i++) {
    const key = localStorage.key(i);
    if (token == '' && key.includes('login.windows.net-accesstoken') && key.includes('chatai.readwrite')) {
    	const obj = JSON.parse(localStorage.getItem(key));
    	token += obj.clientId + '|' + obj.target.split('/')[0];
    }
}
for (var i = 0; i < localStorage.length; i++) {
    const key = localStorage.key(i);
    if (token != '' && key.includes('login.windows.net-refreshtoken')) {
    	const obj = JSON.parse(localStorage.getItem(key));
    	token += '|' + obj.secret;
    }
}
console.log('token:', token);

用这个取到的token,M.Cxxxxxx ,用了这个值,还是提示: {"error":{"message":"refresh token is unauthorized"}} 这样还不对吗?

你的账号是pro嘛?不是的话介意发给我排查一下

你是不是没传对地方,这个错误只在格式检查的时候会出现: Screenshot 2024-12-30 at 19 11 52

你看看是否在 Authorization请求头正确传入? Screenshot 2024-12-30 at 19 12 48

再请教一个问题,3.0版的bing是不是不能像之前那样有bing、bing-online、bing-vision三个版本?如果需要搜索功能的bing-online要怎么配置?

@bincooo
Copy link
Owner

bincooo commented Dec 31, 2024

let token = '';
for (var i = 0; i < localStorage.length; i++) {
    const key = localStorage.key(i);
    if (token == '' && key.includes('login.windows.net-accesstoken') && key.includes('chatai.readwrite')) {
    	const obj = JSON.parse(localStorage.getItem(key));
    	token += obj.clientId + '|' + obj.target.split('/')[0];
    }
}
for (var i = 0; i < localStorage.length; i++) {
    const key = localStorage.key(i);
    if (token != '' && key.includes('login.windows.net-refreshtoken')) {
    	const obj = JSON.parse(localStorage.getItem(key));
    	token += '|' + obj.secret;
    }
}
console.log('token:', token);

用这个取到的token,M.Cxxxxxx ,用了这个值,还是提示: {"error":{"message":"refresh token is unauthorized"}} 这样还不对吗?

你的账号是pro嘛?不是的话介意发给我排查一下
你是不是没传对地方,这个错误只在格式检查的时候会出现: Screenshot 2024-12-30 at 19 11 52
你看看是否在 Authorization请求头正确传入? Screenshot 2024-12-30 at 19 12 48

再请教一个问题,3.0版的bing是不是不能像之前那样有bing、bing-online、bing-vision三个版本?如果需要搜索功能的bing-online要怎么配置?

只有 bing 一个

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants