Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisUser committed Feb 11, 2023
1 parent 2ef09fb commit f9f0e4c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const HomePage: React.FC = () => {
setLengthIssueText('')
const message = composeRequestMessage(selectedSubject, favourites, selectedQuantity)
const completionResponse = await sendCompletionRequest(userAPIKey, message)
if (completionResponse && completionResponse.error && completionResponse.error.status !== 200) {
if (completionResponse && completionResponse.error && completionResponse.error.response && completionResponse.error.response.status !== 200) {
switch (completionResponse.error.response.status) {
case 401: // Unauthorized: API key is wrong
throw new Error('It seems that your API key might be wrong, please double-check it.')
Expand All @@ -40,6 +40,7 @@ const HomePage: React.FC = () => {
}
}
if (completionResponse && completionResponse.response) {
if (!completionResponse.response.responseMessage) throw new Error('System was unable to satisfy your request, please retry.')
if (completionResponse.response.reason && completionResponse.response.reason === 'length')
setLengthIssueText(`This completion was interrupted because it was limited to ${MAX_TOKENS} characters.`)
setFinalResponse(formatResponseMessage(completionResponse.response.responseMessage))
Expand Down

0 comments on commit f9f0e4c

Please sign in to comment.