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: Write an OpenAI-compatible error when context overflows #1031

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

dustinbyrne
Copy link
Contributor

Previously the server would report an error stating Message exceeds token limit..

This error is now transformed into an OpenAI API compatible error, mimicking the same error returned by the official OpenAI API. This change allows Navie to properly reduce the token count before trying again.

Copy link
Contributor

@apotterri apotterri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a couple of cases where the value of stream doesn't seem like it matches the example description.

const response = await postAuthorized(chatCompletion.url, {
model: 'test-model',
messages,
stream: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stream shouldn't be here, should it? The example says, "when not streaming".

{ content: 'How are you?', role: 'assistant' },
{ content: 'I am good, thank you!', role: 'user' },
];
const response = await postAuthorized(chatCompletion.url, { model: 'test-model', messages });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this one seems like it needs stream: true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it looks like I had named the test cases backwards. This is fixed now 👍

@dustinbyrne dustinbyrne merged commit 7126fde into develop Oct 7, 2024
3 of 4 checks passed
@dustinbyrne dustinbyrne deleted the fix/context-length-error branch October 7, 2024 13:27
@appland-release
Copy link
Contributor

🎉 This PR is included in version 0.130.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

4 participants