From a2cca141740989dcc3312cd2002b2c25e30a808b Mon Sep 17 00:00:00 2001 From: eduardruzga Date: Mon, 11 Nov 2024 23:47:12 +0200 Subject: [PATCH] Refactor/standartize model providers, add "get provider key" for those who have it for first time users --- app/components/chat/APIKeyManager.tsx | 6 +- app/components/chat/BaseChat.tsx | 21 +-- app/utils/constants.ts | 178 ++++++++++++++++++-------- 3 files changed, 134 insertions(+), 71 deletions(-) diff --git a/app/components/chat/APIKeyManager.tsx b/app/components/chat/APIKeyManager.tsx index a35724c..1343ece 100644 --- a/app/components/chat/APIKeyManager.tsx +++ b/app/components/chat/APIKeyManager.tsx @@ -1,8 +1,9 @@ import React, { useState } from 'react'; import { IconButton } from '~/components/ui/IconButton'; +import type { ProviderInfo } from '~/utils/constants'; interface APIKeyManagerProps { - provider: string; + provider: ProviderInfo; apiKey: string; setApiKey: (key: string) => void; } @@ -18,7 +19,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 ? {provider?.labelForGetApiKey || "Get API Key"} : "" } )}
diff --git a/app/components/chat/BaseChat.tsx b/app/components/chat/BaseChat.tsx index f331147..134b4f8 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 } from '~/utils/constants'; import { Messages } from './Messages.client'; import { SendButton } from './SendButton.client'; import { useState } from 'react'; @@ -24,12 +24,12 @@ 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 (
-