diff --git a/app/components/chat/APIKeyManager.tsx b/app/components/chat/APIKeyManager.tsx index a35724c8c..5b2c85e46 100644 --- a/app/components/chat/APIKeyManager.tsx +++ b/app/components/chat/APIKeyManager.tsx @@ -1,13 +1,20 @@ import React, { useState } from 'react'; import { IconButton } from '~/components/ui/IconButton'; +import type { ProviderInfo } from '~/types/model'; interface APIKeyManagerProps { - provider: string; + provider: ProviderInfo; apiKey: string; setApiKey: (key: string) => void; + getApiKeyLink?: string; + labelForGetApiKey?: string; } -export const APIKeyManager: React.FC = ({ provider, apiKey, setApiKey }) => { +export const APIKeyManager: React.FC = ({ + provider, + apiKey, + setApiKey, + }) => { const [isEditing, setIsEditing] = useState(false); const [tempKey, setTempKey] = useState(apiKey); @@ -18,7 +25,7 @@ export const APIKeyManager: React.FC = ({ provider, apiKey, return (
- {provider} API Key: + {provider?.name} API Key: {isEditing ? ( <> = ({ provider, apiKey, setIsEditing(true)} title="Edit API Key">
+ + {provider?.getApiKeyLink && window.open(provider?.getApiKeyLink)} title="Edit API Key"> + {provider?.labelForGetApiKey || 'Get API Key'} +
+ } )}
diff --git a/app/components/chat/BaseChat.tsx b/app/components/chat/BaseChat.tsx index f7fe80a08..80183bafd 100644 --- a/app/components/chat/BaseChat.tsx +++ b/app/components/chat/BaseChat.tsx @@ -7,7 +7,7 @@ import { Menu } from '~/components/sidebar/Menu.client'; import { IconButton } from '~/components/ui/IconButton'; import { Workbench } from '~/components/workbench/Workbench.client'; import { classNames } from '~/utils/classNames'; -import { MODEL_LIST, DEFAULT_PROVIDER } from '~/utils/constants'; +import { MODEL_LIST, DEFAULT_PROVIDER, PROVIDER_LIST, initializeModelList } from '~/utils/constants'; import { Messages } from './Messages.client'; import { SendButton } from './SendButton.client'; import { useState } from 'react'; @@ -15,6 +15,7 @@ import { APIKeyManager } from './APIKeyManager'; import Cookies from 'js-cookie'; import styles from './BaseChat.module.scss'; +import type { ProviderInfo } from '~/utils/types'; const EXAMPLE_PROMPTS = [ { text: 'Build a todo app in React using Tailwind' }, @@ -24,42 +25,35 @@ const EXAMPLE_PROMPTS = [ { text: 'How do I center a div?' }, ]; -const providerList = [...new Set(MODEL_LIST.map((model) => model.provider))]; +const providerList = PROVIDER_LIST; const ModelSelector = ({ model, setModel, provider, setProvider, modelList, providerList }) => { return (