-
Notifications
You must be signed in to change notification settings - Fork 899
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BYOM] Improves alerts for certain API response codes (#27194)
* improves insights for some api codes Introduces support for response codes 401 (incorrect api key), 429 (rate limit reached, or out of credits), and 529 (temporary server overload). In these scenarios, the user will be shown a new (or modified) alert for the specific scenario encountered. --------- Co-authored-by: Jay Harris <[email protected]>
- Loading branch information
1 parent
379a96e
commit f0cd735
Showing
12 changed files
with
202 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
components/ai_chat/resources/page/components/alerts/error_invalid_api_key.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* Copyright (c) 2023 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
import * as React from 'react' | ||
import Alert from '@brave/leo/react/alert' | ||
import Button from '@brave/leo/react/button' | ||
import { getLocale } from '$web-common/locale' | ||
import { useAIChat } from '../../state/ai_chat_context' | ||
import styles from './alerts.module.scss' | ||
|
||
interface ElementProps { | ||
onRetry?: () => void | ||
} | ||
|
||
export default function ErrorInvalidAPIKey(props: ElementProps) { | ||
const aiChatContext = useAIChat() | ||
|
||
const handleConfigureClick = () => { | ||
aiChatContext.uiHandler?.openAIChatSettings() | ||
} | ||
|
||
return ( | ||
<div className={styles.alert}> | ||
<Alert type='warning'> | ||
{getLocale('errorInvalidAPIKey')} | ||
<Button | ||
slot='actions' | ||
kind='filled' | ||
onClick={handleConfigureClick} | ||
> | ||
{getLocale('customModelModifyConfigurationLabel')} | ||
</Button> | ||
<Button | ||
slot='actions' | ||
kind='filled' | ||
onClick={props.onRetry} | ||
> | ||
{getLocale('retryButtonLabel')} | ||
</Button> | ||
</Alert> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
components/ai_chat/resources/page/components/alerts/error_service_overloaded.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* Copyright (c) 2023 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
import * as React from 'react' | ||
import Alert from '@brave/leo/react/alert' | ||
import Button from '@brave/leo/react/button' | ||
import { getLocale } from '$web-common/locale' | ||
import styles from './alerts.module.scss' | ||
|
||
interface ElementProps { | ||
onRetry?: () => void | ||
} | ||
|
||
export default function ErrorServiceOverloaded(props: ElementProps) { | ||
return ( | ||
<div className={styles.alert}> | ||
<Alert type='error'> | ||
{getLocale('errorServiceOverloaded')} | ||
<Button | ||
slot='actions' | ||
kind='filled' | ||
onClick={props.onRetry} | ||
> | ||
{getLocale('retryButtonLabel')} | ||
</Button> | ||
</Alert> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters