Fixes #13. Missing verify button for OpenAI API key. (#15)

This commit is contained in:
Michael Cartner
2024-01-31 15:34:56 +01:00
committed by GitHub
parent 57932fef3c
commit eae223a817

View File

@@ -16,6 +16,7 @@ import { Text } from '@noodl-core-ui/components/typography/Text';
import { Title, TitleSize } from '@noodl-core-ui/components/typography/Title'; import { Title, TitleSize } from '@noodl-core-ui/components/typography/Title';
import { ToastLayer } from '../../../ToastLayer/ToastLayer'; import { ToastLayer } from '../../../ToastLayer/ToastLayer';
import { PropertyPanelButton } from '@noodl-core-ui/components/property-panel/PropertyPanelButton';
export const AI_ASSISTANT_ENABLED_SUGGESTIONS_KEY = 'aiAssistant.enabledSuggestions'; export const AI_ASSISTANT_ENABLED_SUGGESTIONS_KEY = 'aiAssistant.enabledSuggestions';
@@ -31,15 +32,14 @@ export function OpenAiSection() {
const haveGpt4 = !!models['gpt-4']; const haveGpt4 = !!models['gpt-4'];
if (haveGpt4) { if (haveGpt4) {
OpenAiStore.setIsAiApiKeyVerified(true); OpenAiStore.setIsAiApiKeyVerified(true);
ToastLayer.showSuccess('Open AI, API Key is valid with GPT-4!'); ToastLayer.showSuccess('OpenAI API Key is valid with GPT-4!');
} else { } else {
OpenAiStore.setIsAiApiKeyVerified(false); OpenAiStore.setIsAiApiKeyVerified(false);
ToastLayer.showError('Open AI, API Key is missing gpt-4 model Support!'); ToastLayer.showError('OpenAI API Key is missing gpt-4 model Support!');
} }
} else { } else {
OpenAiStore.setIsAiApiKeyVerified(false); OpenAiStore.setIsAiApiKeyVerified(false);
ToastLayer.showError('Open AI, API Key is invalid!'); ToastLayer.showError('OpenAI API Key is invalid!');
}
} }
return ( return (
@@ -95,6 +95,20 @@ export function OpenAiSection() {
}} }}
/> />
</PropertyPanelRow> </PropertyPanelRow>
<PropertyPanelRow label="API Key" isChanged={false}>
<PropertyPanelButton
properties={{
isPrimary: true,
buttonLabel: 'Verify API Key',
onClick() {
onVerifyApiKey();
}
}}
/>
</PropertyPanelRow>
<Box hasYSpacing>
<Text>Verify your OpenAI API key to start using AI Commands.</Text>
</Box>
</> </>
)} )}