Add provider filtering on model list
Browse files- app/components/chat/BaseChat.tsx +41 -14
app/components/chat/BaseChat.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import { classNames } from '~/utils/classNames';
|
|
| 10 |
import { MODEL_LIST } from '~/utils/constants';
|
| 11 |
import { Messages } from './Messages.client';
|
| 12 |
import { SendButton } from './SendButton.client';
|
|
|
|
| 13 |
|
| 14 |
import styles from './BaseChat.module.scss';
|
| 15 |
|
|
@@ -21,6 +22,40 @@ const EXAMPLE_PROMPTS = [
|
|
| 21 |
{ text: 'How do I center a div?' },
|
| 22 |
];
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
const TEXTAREA_MIN_HEIGHT = 76;
|
| 25 |
|
| 26 |
interface BaseChatProps {
|
|
@@ -110,20 +145,12 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
|
|
| 110 |
'sticky bottom-0': chatStarted,
|
| 111 |
})}
|
| 112 |
>
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
>
|
| 120 |
-
{MODEL_LIST.map((modelOption) => (
|
| 121 |
-
<option key={modelOption.name} value={modelOption.name}>
|
| 122 |
-
{modelOption.label}
|
| 123 |
-
</option>
|
| 124 |
-
))}
|
| 125 |
-
</select>
|
| 126 |
-
</div>
|
| 127 |
<div
|
| 128 |
className={classNames(
|
| 129 |
'shadow-sm border border-bolt-elements-borderColor bg-bolt-elements-prompt-background backdrop-filter backdrop-blur-[8px] rounded-lg overflow-hidden',
|
|
|
|
| 10 |
import { MODEL_LIST } from '~/utils/constants';
|
| 11 |
import { Messages } from './Messages.client';
|
| 12 |
import { SendButton } from './SendButton.client';
|
| 13 |
+
import { useState } from 'react';
|
| 14 |
|
| 15 |
import styles from './BaseChat.module.scss';
|
| 16 |
|
|
|
|
| 22 |
{ text: 'How do I center a div?' },
|
| 23 |
];
|
| 24 |
|
| 25 |
+
const providerList = [...new Set(MODEL_LIST.map((model) => model.provider))]
|
| 26 |
+
|
| 27 |
+
const ModelSelector = ({ model, setModel, modelList, providerList }) => {
|
| 28 |
+
const [provider, setProvider] = useState(null);
|
| 29 |
+
return (
|
| 30 |
+
<div className="mb-2">
|
| 31 |
+
<select
|
| 32 |
+
value={provider}
|
| 33 |
+
onChange={(e) => setProvider(e.target.value)}
|
| 34 |
+
className="w-full p-2 rounded-lg border border-bolt-elements-borderColor bg-bolt-elements-prompt-background text-bolt-elements-textPrimary focus:outline-none"
|
| 35 |
+
>
|
| 36 |
+
{providerList.map((provider) => (
|
| 37 |
+
<option key={provider} value={provider}>
|
| 38 |
+
{provider}
|
| 39 |
+
</option>
|
| 40 |
+
))}
|
| 41 |
+
|
| 42 |
+
</select>
|
| 43 |
+
<select
|
| 44 |
+
value={model}
|
| 45 |
+
provider={provider}
|
| 46 |
+
onChange={(e) => setModel(e.target.value)}
|
| 47 |
+
className="w-full p-2 rounded-lg border border-bolt-elements-borderColor bg-bolt-elements-prompt-background text-bolt-elements-textPrimary focus:outline-none"
|
| 48 |
+
>
|
| 49 |
+
{[...modelList].filter( e => e.provider == provider ).map((modelOption) => (
|
| 50 |
+
<option key={modelOption.name} value={modelOption.name}>
|
| 51 |
+
{modelOption.label}
|
| 52 |
+
</option>
|
| 53 |
+
))}
|
| 54 |
+
</select>
|
| 55 |
+
</div>
|
| 56 |
+
)
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
const TEXTAREA_MIN_HEIGHT = 76;
|
| 60 |
|
| 61 |
interface BaseChatProps {
|
|
|
|
| 145 |
'sticky bottom-0': chatStarted,
|
| 146 |
})}
|
| 147 |
>
|
| 148 |
+
<ModelSelector
|
| 149 |
+
model={model}
|
| 150 |
+
setModel={setModel}
|
| 151 |
+
modelList={MODEL_LIST}
|
| 152 |
+
providerList={providerList}
|
| 153 |
+
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
<div
|
| 155 |
className={classNames(
|
| 156 |
'shadow-sm border border-bolt-elements-borderColor bg-bolt-elements-prompt-background backdrop-filter backdrop-blur-[8px] rounded-lg overflow-hidden',
|