-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fixed BingChat to recent API changes. #41
base: main
Are you sure you want to change the base?
Conversation
… to provide all the Bing Cookies. Added codes to ensure the conversation is authenticated. Added retry mechanism on WebSocketException
Thank you for the pull request @gunpal5. However, it cannot be merged as is. There are a few points to address first:
|
Used JsonSerializerContext instead of reflection-based serialization Removed transient IDE files
@neon-sunset I made necessary changes you asked. Regarding cookie files, I am not sure which cookie Bing is using to authenticate the chat. only passing _U and/or KievRPSSecAuth are not enough. someone else might figure out the right cookies to pass as arguments in I would advise to add a new argument |
@neon-sunset It's been like a month, people need it. Please review and merge |
I understand that you would like to have this PR merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file does not belong to the PR
@@ -107,11 +115,15 @@ public async Task<BingChatConversation> CreateConversation() | |||
throw new BingChatException(message); | |||
} | |||
|
|||
var encryptedConversationSignature = rawResponse.Headers.GetValues("X-Sydney-EncryptedConversationSignature").FirstOrDefault(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this doesn't work without encryptedConversationSignature
, shouldn't it be First()
instead of FirstOrDefault()
?
{ | ||
_request = new BingChatRequest(clientId, conversationId, conversationSignature, tone); | ||
_encryptedConversationSignature = encryptedConversationSignature; | ||
this._cookies = cookies; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this._cookies = cookies; | |
_cookies = cookies; |
HubProtocol, | ||
HubEndpoint, | ||
new UriEndPoint(new Uri(uri)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to cache this property instead of creating it on each request.
return new BingChatClient(new BingChatClientOptions | ||
{ | ||
CookieU = string.IsNullOrWhiteSpace(cookie) ? null : cookie, | ||
CookieFilePath = string.IsNullOrEmpty(cookieFile)? null: cookieFile, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CookieFilePath = string.IsNullOrEmpty(cookieFile)? null: cookieFile, | |
CookieFilePath = string.IsNullOrEmpty(cookieFile) ? null : cookieFile, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert all changes in this file.
I'll need to give it another look over some time later with a proper IDE. |
} | ||
catch (WebSocketException) | ||
{ | ||
Thread.Sleep(100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You must never use Thread.Sleep(...)
in async
methods or methods that can be called from async. The correct way to do it is to use Task.Delay(...)
instead.
Fixed BingChat to recent API changes. Now it is absolutely necessary to provide all of the Bing Cookies.
Added codes to ensure the conversation is authenticated.
Added retry mechanism on WebSocketException
this PR provides fixes to issues #40 #39 #38 #36
To use command line tool:
set [BING_COOKIES_FILE=[<path to cookies file>]]