feat: add DEFAULT_MODEL environment variable (#280)

*  feat: add DEFAULT_MODEL environment variable

* set the model maxLength setting in the models definition

* set the model tokenLimit setting in the models definition
This commit is contained in:
Thomas LÉVEIL
2023-03-29 05:10:47 +02:00
committed by GitHub
parent 3f82710cdd
commit 00c6c72270
9 changed files with 94 additions and 38 deletions
+13 -4
View File
@@ -1,15 +1,22 @@
import { OpenAIModel } from '@/types/openai';
import { OpenAIModel, OpenAIModelID } from '@/types/openai';
import { useTranslation } from 'next-i18next';
import { FC } from 'react';
interface Props {
model: OpenAIModel;
models: OpenAIModel[];
defaultModelId: OpenAIModelID;
onModelChange: (model: OpenAIModel) => void;
}
export const ModelSelect: FC<Props> = ({ model, models, onModelChange }) => {
export const ModelSelect: FC<Props> = ({
model,
models,
defaultModelId,
onModelChange,
}) => {
const { t } = useTranslation('chat');
return (
<div className="flex flex-col">
<label className="mb-2 text-left text-neutral-700 dark:text-neutral-400">
@@ -19,7 +26,7 @@ export const ModelSelect: FC<Props> = ({ model, models, onModelChange }) => {
<select
className="w-full bg-transparent p-2"
placeholder={t('Select a model') || ''}
value={model.id}
value={model?.id || defaultModelId}
onChange={(e) => {
onModelChange(
models.find(
@@ -34,7 +41,9 @@ export const ModelSelect: FC<Props> = ({ model, models, onModelChange }) => {
value={model.id}
className="dark:bg-[#343541] dark:text-white"
>
{model.name}
{model.id === defaultModelId
? `Default (${model.name})`
: model.name}
</option>
))}
</select>