Skip to content

Commit

Permalink
Merge branch 'main' into alexw/tlk-801-when-i-fill-in-the-env-variabl…
Browse files Browse the repository at this point in the history
…es-i-dont-know-if-its-been
  • Loading branch information
malexw committed Dec 20, 2024
2 parents 33be802 + 8a5c4c8 commit f24eaeb
Show file tree
Hide file tree
Showing 6 changed files with 536 additions and 538 deletions.
19 changes: 18 additions & 1 deletion src/interfaces/assistants_web/src/cohere-client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,24 @@ export class CohereClient {
body: requestBody,
signal,
openWhenHidden: true, // When false, the requests will be paused when the tab is hidden and resume/retry when the tab is visible again
onopen: onOpen,
onopen: async (response: Response) => {
if (
response.status !== 200 &&
response.headers.get('content-type')?.includes('application/json')
) {
await response
.json()
.catch((e) => {
throw new CohereNetworkError('Failed to decode error message JSON', response.status);
})
.then((data) => {
throw new CohereNetworkError(data.detail, response.status);
});
}
if (onOpen) {
onOpen(response);
}
},
onmessage: onMessage,
onclose: onClose,
onerror: onError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const MessageContent: React.FC<Props> = ({ isLast, message, onRetry }) =>
<MessageInfo type="error">
{message.error}
{isLast && (
<button className="underline underline-offset-1" type="button" onClick={onRetry}>
<button className="ml-2 underline underline-offset-1" type="button" onClick={onRetry}>
Retry?
</button>
)}
Expand Down
Loading

0 comments on commit f24eaeb

Please sign in to comment.