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

Fix: refresh context for UnauthorizedRequest from Bing #658

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

samanhappy
Copy link
Contributor

Resolve #629

When token is expired, Bing will return such message
{"type":2,"invocationId":"1","item":{"firstNewMessageIndex":null,"defaultChatName":null,"result":{"value":"UnauthorizedRequest","message":"Token issued by https://sydney.bing.com/sydney is invalid (IDX10223: Lifetime validation failed. The token is expired. ValidTo (UTC): '12/8/2023 3:48:23 AM', Current time (UTC): '12/8/2023 3:58:42 AM'.)","error":"UnauthorizedRequest","renewCert":true,"serviceVersion":"20231207.96"}}}

There should be other scenarios for UnauthorizedRequest, I'm not sure whether it's appropriate to use it for direct comparison, what is your opinion ? @sunner

Copy link

vercel bot commented Dec 8, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
chatall ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 8, 2023 11:38am

@samanhappy samanhappy changed the title Fix: refresh context for UnauthorizedRequest Fix: refresh context for UnauthorizedRequest from Bing Dec 8, 2023
@sunner
Copy link
Owner

sunner commented Dec 10, 2023

Perhaps, a relogin is required?

@samanhappy
Copy link
Contributor Author

For the UnauthorizedRequest scenario, either a relogin or the creation of a new conversation is necessary. Consider the following solution:

  1. Attempt to create a new conversation and retry the operation.
  2. If successful, proceed with the remaining steps.
  3. If the attempt fails, display an error message and advise the user to perform a relogin.

The crucial implementation step involves adding a retry flag to the context and utilizing it for both retry attempts and error display. This flag serves the additional purpose of preventing an infinite recursion loop in the chat.

If you agree with this approach, I will proceed with the implementation.

@sunner
Copy link
Owner

sunner commented Dec 17, 2023

Thank you @samanhappy for the detailed deep thinking. But IMO, the solution is too smart. I prefer showing the error message and let the user determine what to do next. Just as Bing Chat's behavior.

@samanhappy
Copy link
Contributor Author

When using Bing Chat, user won't get an UnauthorizedRequest message or have to relogin for expired token, so I think Bing Chat has implemented a similar solution.

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

Successfully merging this pull request may close these issues.

[BUG] Bing token is expired
2 participants