bsdayo / bingchat Goto Github PK
View Code? Open in Web Editor NEW.NET API wrapper, and an amazing interactive CLI for Microsoft's new AI-powered Bing Chat.
License: MIT License
.NET API wrapper, and an amazing interactive CLI for Microsoft's new AI-powered Bing Chat.
License: MIT License
How do I figure out how many more requests I can make during a chat session?
BingChat.BingChatException
HResult=0x80131500
Message=UnauthorizedRequest: The conversationSignature is not set and is required to ensure that you have permission to use our APIs. IsAuthenticated=False. App ID=
Source=BingChat
StackTrace:
於 BingChat.BingChatConversation.BuildAnswer(ChatResponse response)
於 BingChat.BingChatConversation.d__5.MoveNext()
於 BingChat.BingChatConversation.d__5.MoveNext()
於 BingChat.BingChatClient.d__3.MoveNext()
於 Program.<
此例外狀況原先在此呼叫堆疊擲回:
[外部程式碼]
Program.
我已經嘗試過作者所教UnauthorizedRequest的所有方法,除了proxy(但是我並非是在bing不支援的地區),而且我昨天都還能一次大量的傳送訊息,或如過超量使用其他的帳號,但今天晚上卻都不行使用了,僅能問一點點問題,就會遇到UnauthorizedRequest,我該怎麼辦?
謝謝!
I have tried all the methods mentioned by the author to resolve the UnauthorizedRequest issue, except for using a proxy (however, I am not in a region where Bing is unsupported). Also, yesterday I was able to send a large number of queries, even exceeded the limit using other accounts. However, tonight, I'm unable to use the service as usual. I can only ask a few questions before encountering the UnauthorizedRequest error. What should I do?
(而且奇怪的是,我有些edge帳號,可能因為問太多問題而被禁,然而其中有一個我根本沒問幾個問題(應該不到20)也被禁?我問的問題並沒有違反bing chat的條款?而且在嘗試使用正常的帳號也不行使用,非常奇怪?)
Thank you!
System.NullReferenceException: Object reference not set to an instance of an object
at BingChat.BingChatConversation.g__GetAnswer|3_1(BingChatConversationResponse response)
at BingChat.BingChatConversation.<>c__DisplayClass3_0.g__OnMessageReceived|2(String text)
--- End of stack trace from previous location ---
at HelloWold.Program.ComposeAnswerAsync(String request)
at System.Threading.Tasks.Task.<>c.b__128_1(Object state)
at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
at System.Threading.Thread.StartCallback()
Hi @bsdayo , I have noticed you pushed an update that this library is now in maintenance mode.
I would like to help with this (well, at least solve a couple of old issues with formatting).
When I issue the following query directly in bing chat I get a nicely formated json result. When I use BingChat class it returns only as text. It would be nice to have the option to have the results returned exactly as output by bing chat rather than converted to text.
string query = $"what are the book sereis related to {keyword}, return results in json format with the variables title, description, author and number of books in series";
English information sources are always applied when searching for non-English content.
Haven't looked closely but guess that accept-language
header and/or _tarLang
, _EDGE_CD
, WLS
and SRCHHPGUSR
cookies are related to this.
I have added BingChat to my project and copied my bing.com's "_U" cookie value, but when I try to run var answer = await client.AskAsync("Whats the weather like?"); I get this error: BingChat.BingChatException: 'Success: .'
How would I go about fixing this?
As of now, it can take more than 60 seconds to get final response if the user query requires BingChat to search for information or conduct any other intermediate actions
Adjust API surface to allow the user to either stream intermediate response state or opt in to await the final response.
Because Bing Chat implementation is world-class, it does not bother with trivialities such as efficiency, saving bandwidth or having an event type to send response parts over websocket (and cancel previous output where BC refuses to honor user prompt) and instead just re-sends the whole thing instead (see below).
This creates an issue where we can't just expose IAsyncEnumerable<string>
because it can confuse the users of the library by sending the same message with extra words appended, making for cumbersome user experience. Thus, I'm creating this issue for feedback while I'm trying out a couple of prototypes to encapsulate the response into a public type ConversationResponse
(placeholder) so that the users can either explicitly .GetCompletedResponse()
or .ReadIntermediateMessages()
(also placeholders).
Ideally, I want to make it more user-friendly than what WSS API exposes by detecting whether we're still receiving the continuations of the previous response message or if BingChat decided to completely rewrite it so that the user can just Console.Write(msg)
until it is done.
Let me know what you think.
Example WSS output (cut out for brevity):
t":"Generating answers for you...","hiddenText":"Generating answers for you...","
18:32:33.849
{"type":1,"target":"update","arguments":[{"cursor":{"j":"$['cb8f7fa8-4055-4452-9a
18:32:33.858
{"type":1,"target":"update","arguments":[{"messages":[{"text":"The","author":"bot
18:32:33.864
{"type":1,"target":"update","arguments":[{"messages":[{"text":"The weather","auth
18:32:33.864
{"type":1,"target":"update","arguments":[{"messages":[{"text":"The weather in","a
18:32:33.864
{"type":1,"target":"update","arguments":[{"messages":[{"text":"The weather in Ky"
After all, it is possible to chat with Bing in other browsers and without logging in.
I am trying to understand how to show Bing that you have solved a catcha when you are not logged in and there is no _U cookie.
Does anyone know what cookies or headers are set when a captcha is solved?
Publishing BingChat.Cli
as tool would allow for dotnet tool install -g BingChat.Cli
without having to build it and add to $PATH manually.
(also, version 0.8.0 when?😅)
Hi, in the roadmap description it says that it is possible to set a timeout. Unfortunately I didn't find any option in this context in the current version of the library. Is this implementation not checked in yet? I would be interested in how long you have until the chat session expires if you don't make a request and is it possible to configure this timeout?
compatibilidad con net framework 4.6.2
I can often catch this exception.
InternalError: Unhandled Dependency Failure: DeepLeo
The text is part of the response message, which the websocket client received from the server. (see below)
{
"type": 2,
"invocationId": "1",
"item": {
"firstNewMessageIndex": null,
"defaultChatName": null,
"conversationId": "51D|BingProdUnAuthenticatedUsers|E7D ... 284",
"requestId": "88e6dd8c-2cae-49e4-aef4-223d27f69487",
"telemetry": { },
"result": {
"value": "InternalError",
"message": "Unhandled Dependency Failure: DeepLeo",
"error": "Unhandled Dependency Failure: DeepLeo\n ---> ServiceClient failure for DeepLeo",
"exception": "Microsoft.TuringBot.Common.ServiceInternalError: Unhandled Dependency Failure: DeepLeo\r\n ---> Microsoft.TuringBot.Common.ServiceClientException: ServiceClient failure for DeepLeo\r\n ---> System.Net.Http.HttpRequestException: Failed to call \"DeepLeo\" at \"SelectedByPapyrusLoadBalancer\"...(some call stack information)...",
"serviceVersion": "20230518.47"
}
}
}
It seems to appear once in every 5 questions on average. If I asked the same question again, it can answer. I'm not sure if it's just for me, or if it's a network issue.
If you have any solutions or clues, please let me know. Thank you.
Is someone else getting this Error?
UnauthorizedRequest
"The conversationSignature is not set and is required to ensure that you have permission to use our APIs. IsAuthenticated=False. App ID="
Edit: If I comparing the current payload on Bing, it seems that "ConversationSignature" is not send in the payload anymore and it is also missing in the new conversation response. I removed the attribute from the payload, but still get this error. So, the create call still works, only when creating the websocket connection there are problems. I can't figure out why this doesn't work with the modified payload. Is anyone here more familiar with websockets?
when I run it I receive
BingChat.BingChatException
HResult=0x80131500
Message=CaptchaChallenge: User needs to solve CAPTCHA to continue.
Source=BingChat
StackTrace:
at BingChat.BingChatConversation.BuildAnswer(ChatResponse response)
at BingChat.BingChatConversation.d__5.MoveNext()
at BingChat.BingChatConversation.d__5.MoveNext()
at BingChat.BingChatClient.d__3.MoveNext()
at BingChat_test.Program.
We should have the ability to be able to specify which tone/mode is used for conversation.
This mode can be changed using a cookie called 'cdxtone'.
I noticed that the CLI reply containes citation numbers, like "[^1^]", but does not contain the source attribution link. It looks a bit strange. I'm not sure if this is intentional.
Does it need an option to control whether citations are displayed or hidden?
- displayed: For users who want to read the source page for detailed information.
- hidden: For users who want to chat or get direct answers.
Message
UnauthorizedRequest: Sorry, you need to login first to access this service.. If you confirm that the correct cookie is set and you still keep seeing this, maybe Bing doesn't serve your region. You can use a proxy and try again.
I have added "bing.com" to my VPN pac list, and I can access Bing AI in Edge browser.
I have set the cookie and proxy in code like tihs. The exception still exist.
HttpClient.DefaultProxy = new WebProxy("127.0.0.1:8807"); //local proxy
var client = new BingChatClient(new BingChatClientOptions
{
Cookie = File.ReadAllText(cookiePath),
});
var conversation = await client.CreateConversation();
After sending a message, the following error is thrown:
Error: Object reference not set to an instance of an object.
Then the program crashes.
Bing AI responds to user message.
dotnet run --project src/BingChat.Cli/BingChat.Cli.csproj
Welcome to Bing Chat!
Enter message to chat with Bing, or enter /help to get command help.
[REDACTED]
Creating new conversation...
Error: Object reference not set to an instance of an object.
Very interesting API though. Curious to see if it can get through the censoring.
BingChat.BingChatException
HResult=0x80131500
Message=UnauthorizedRequest: The conversationSignature is not set and is required to ensure that you have permission to use our APIs. IsAuthenticated=False. App ID=
Source=BingChat
StackTrace:
於 BingChat.BingChatConversation.BuildAnswer(ChatResponse response)
於 BingChat.BingChatConversation.d__5.MoveNext()
於 BingChat.BingChatConversation.d__5.MoveNext()
於 BingChat.BingChatClient.d__3.MoveNext()
於 Program.<
我已經嘗試過作者所教UnauthorizedRequest的所有方法,除了proxy(但是我並非是在bing不支援的地區),而且我昨天都還能一次大量的傳送訊息,或如過超量使用其他的帳號,但今天晚上卻都不行使用了,僅能問一點點問題,就會遇到UnauthorizedRequest,我該怎麼辦?
謝謝!
I have tried all the methods mentioned by the author to resolve the UnauthorizedRequest issue, except for using a proxy (however, I am not in a region where Bing is unsupported). Also, yesterday I was able to send a large number of queries, even exceeded the limit using other accounts. However, tonight, I'm unable to use the service as usual. I can only ask a few questions before encountering the UnauthorizedRequest error. What should I do?
Thank you!
Since the public release of New Bing the cookie field is no longer required. For the mean time just putting anything in the CookieU field allows you to chat but there should be the option to leave the cookie as null
System.Net.WebSockets.WebSocketException: The server returned status code '200' when status code '101' was expected.
at async Task System.Net.WebSockets.WebSocketHandle.ConnectAsync(Uri uri, CancellationToken cancellationToken,
ClientWebSocketOptions options)
at async Task System.Net.WebSockets.ClientWebSocket.ConnectAsyncCore(Uri uri, CancellationToken cancellationToken)
at async ValueTask Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport.
DefaultWebSocketFactory(WebSocketConnectionContext context, CancellationToken cancellationToken)
at async Task Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport.StartAsync(Uri url,
TransferFormat transferFormat, CancellationToken cancellationToken)
at async Task Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartTransport(Uri connectUrl,
HttpTransportType transportType, TransferFormat transferFormat, CancellationToken cancellationToken)
at async Task Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.SelectAndStartTransport(TransferFormat
transferFormat, CancellationToken cancellationToken)
at async Task Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartAsyncCore(TransferFormat transferFormat
, CancellationToken cancellationToken)
at async Task Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartAsync(TransferFormat transferFormat,
CancellationToken cancellationToken)
at async ValueTask Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionFactory.ConnectAsync(
EndPoint endPoint, CancellationToken cancellationToken)
at async ValueTask Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionFactory.ConnectAsync(
EndPoint endPoint, CancellationToken cancellationToken)
at async Task Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncCore(CancellationToken cancellationToken)
at async Task Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncInner(CancellationToken cancellationToken)
at async Task Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsync(CancellationToken cancellationToken)
at async Task BingChat.BingChatConversation.Connect(CancellationToken ct) in
/home/runner/work/BingChat/BingChat/src/BingChat/BingChatConversation.cs:181
at async IAsyncEnumerable BingChat.BingChatConversation.StreamAsync(string message, CancellationToken ct) in
/home/runner/work/BingChat/BingChat/src/BingChat/BingChatConversation.cs:74
at async IAsyncEnumerable BingChat.BingChatConversation.StreamAsync(string message, CancellationToken ct)
at void BingChat.Cli.Utils.<>c__DisplayClass3_0.<b__0>d.MoveNext() in
/home/runner/work/BingChat/BingChat/src/dotnet-bingchat/Utils.cs:79
at void BingChat.Cli.Utils.<>c__DisplayClass3_0.<b__0>d.MoveNext() in
/home/runner/work/BingChat/BingChat/src/dotnet-bingchat/Utils.cs:79
at void Spectre.Console.LiveDisplay.<>c__DisplayClass17_0.<b__0>d.MoveNext() in
//src/Spectre.Console/Live/LiveDisplay.cs:80
at void Spectre.Console.LiveDisplay.<>c__DisplayClass18_0`1.<b__0>d.MoveNext() in
//src/Spectre.Console/Live/LiveDisplay.cs:110
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.