feat: add default value for openai host (#1336)

This commit is contained in:
Yingjie He
2025-02-21 14:12:35 -08:00
committed by GitHub
parent 57b0982b00
commit c812ee6af1
3 changed files with 10 additions and 2 deletions

View File

@@ -3,7 +3,7 @@ import { Card } from '../ui/card';
import { Lock } from 'lucide-react'; import { Lock } from 'lucide-react';
import { Input } from '../ui/input'; import { Input } from '../ui/input';
import { Button } from '../ui/button'; 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 { isSecretKey } from './api_keys/utils';
import { OllamaBattleGame } from './OllamaBattleGame'; import { OllamaBattleGame } from './OllamaBattleGame';
@@ -26,7 +26,9 @@ export function ProviderSetupModal({
onCancel, onCancel,
forceBattle = false, forceBattle = false,
}: ProviderSetupModalProps) { }: 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 requiredKeys = required_keys[provider] || ['API Key'];
const headerText = title || `Setup ${provider}`; const headerText = title || `Setup ${provider}`;

View File

@@ -6,6 +6,7 @@ export function isSecretKey(keyName: string): boolean {
const nonSecretKeys = [ const nonSecretKeys = [
'DATABRICKS_HOST', 'DATABRICKS_HOST',
'OLLAMA_HOST', 'OLLAMA_HOST',
'OPENAI_HOST',
'AZURE_OPENAI_ENDPOINT', 'AZURE_OPENAI_ENDPOINT',
'AZURE_OPENAI_DEPLOYMENT_NAME', 'AZURE_OPENAI_DEPLOYMENT_NAME',
]; ];

View File

@@ -75,6 +75,11 @@ export const required_keys = {
'Azure OpenAI': ['AZURE_OPENAI_API_KEY', 'AZURE_OPENAI_ENDPOINT', 'AZURE_OPENAI_DEPLOYMENT_NAME'], '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 = [ export const supported_providers = [
'OpenAI', 'OpenAI',
'Anthropic', 'Anthropic',