Skip to content

Commit

Permalink
feat: add default value for openai host (#1336)
Browse files Browse the repository at this point in the history
  • Loading branch information
yingjiehe-xyz authored Feb 21, 2025
1 parent 57b0982 commit c812ee6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ui/desktop/src/components/settings/ProviderSetupModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Card } from '../ui/card';
import { Lock } from 'lucide-react';
import { Input } from '../ui/input';
import { Button } from '../ui/button';
import { required_keys } from './models/hardcoded_stuff';
import { required_keys, default_key_value } from './models/hardcoded_stuff';
import { isSecretKey } from './api_keys/utils';
import { OllamaBattleGame } from './OllamaBattleGame';

Expand All @@ -26,7 +26,9 @@ export function ProviderSetupModal({
onCancel,
forceBattle = false,
}: ProviderSetupModalProps) {
const [configValues, setConfigValues] = React.useState<{ [key: string]: string }>({});
const [configValues, setConfigValues] = React.useState<{ [key: string]: string }>(
default_key_value
);
const requiredKeys = required_keys[provider] || ['API Key'];
const headerText = title || `Setup ${provider}`;

Expand Down
1 change: 1 addition & 0 deletions ui/desktop/src/components/settings/api_keys/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export function isSecretKey(keyName: string): boolean {
const nonSecretKeys = [
'DATABRICKS_HOST',
'OLLAMA_HOST',
'OPENAI_HOST',
'AZURE_OPENAI_ENDPOINT',
'AZURE_OPENAI_DEPLOYMENT_NAME',
];
Expand Down
5 changes: 5 additions & 0 deletions ui/desktop/src/components/settings/models/hardcoded_stuff.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ export const required_keys = {
'Azure OpenAI': ['AZURE_OPENAI_API_KEY', 'AZURE_OPENAI_ENDPOINT', 'AZURE_OPENAI_DEPLOYMENT_NAME'],
};

export const default_key_value = {
OPENAI_HOST: 'https://api.openai.com',
OLLAMA_HOST: 'localhost',
};

export const supported_providers = [
'OpenAI',
'Anthropic',
Expand Down

0 comments on commit c812ee6

Please sign in to comment.