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

Explicitly raise ContextWindowExceptions #228

Closed
krrishdholakia opened this issue Aug 29, 2023 · 5 comments
Closed

Explicitly raise ContextWindowExceptions #228

krrishdholakia opened this issue Aug 29, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@krrishdholakia
Copy link
Contributor

Your feature request in one line
Explicitly raise ContextWindowExceptions

Describe the solution you'd like
Raise an exception to specifically call out when a context window exceeded exception occurs. OpenAI can raise invalidrequest errors for several reasons - but the fallback strategy specifically for context window exceptions is different

@krrishdholakia krrishdholakia added enhancement New feature or request good first issue Good for newcomers labels Aug 29, 2023
@krrishdholakia krrishdholakia self-assigned this Aug 29, 2023
@krrishdholakia
Copy link
Contributor Author

cc: @yujonglee feel free to add any additional details

@yujonglee
Copy link
Contributor

In the OpenAI Docs, it said An InvalidRequestError indicates that your request was malformed or missing some required parameters, such as a token or an input. This could be due to a typo, a formatting error, or a logic error in your code.

And it can be context_length_exceeded too.

Like @krrishdholakia mentioned, one might want to retry with longer context window model only if InvalidRequestError is raised due to context_length_exceeded, and just raise exception for others(Since it is really invalid request).

It can be implemented as subclass of openai.error.InvalidRequestError.

@krrishdholakia
Copy link
Contributor Author

Investigating this more - not all providers return a detailed enough error message (e.g. baseten returns a 500 error). We can implement this on a case-by-case basis (i.e. for those that do return a specific max tokens / context window exceeded message) we can return this exception (this should be the 90% case tbh).

@krrishdholakia
Copy link
Contributor Author

@krrishdholakia
Copy link
Contributor Author

Should be available across all models from v0.1.504 onwards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants