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

Edit the errors and warnings mentioning OpenAI #1322

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/server/lib/Assistance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,19 +276,19 @@ export class OpenAIAssistant implements Assistant {
const errorCode = result.error?.code;
const errorMessage = result.error?.message;
if (errorCode === "context_length_exceeded" || result.choices?.[0].finish_reason === "length") {
log.warn("OpenAI context length exceeded: ", errorMessage);
log.warn("AI context length exceeded: ", errorMessage);
if (messages.length <= 2) {
throw new TokensExceededFirstMessageError();
} else {
throw new TokensExceededLaterMessageError();
}
}
if (errorCode === "insufficient_quota") {
log.error("OpenAI billing quota exceeded!!!");
log.error("AI service provider billing quota exceeded!!!");
throw new QuotaExceededError();
}
if (apiResponse.status !== 200) {
throw new Error(`OpenAI API returned status ${apiResponse.status}: ${resultText}`);
throw new Error(`AI service provider API returned status ${apiResponse.status}: ${resultText}`);
}
return result.choices[0].message.content;
}
Expand Down
2 changes: 1 addition & 1 deletion test/server/lib/Assistance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ describe('Assistance', function () {
checkSendForCompletion(),
"Sorry, the assistant is unavailable right now. " +
"Try again in a few minutes. \n" +
'(Error: OpenAI API returned status 500: {"status":500})',
'(Error: AI service provider API returned status 500: {"status":500})',
);
assert.equal(fakeFetch.callCount, 3);
});
Expand Down