✨ 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:
@@ -1,5 +1,5 @@
|
||||
import { Message } from '@/types/chat';
|
||||
import { OpenAIModel, OpenAIModelID } from '@/types/openai';
|
||||
import { OpenAIModel } from '@/types/openai';
|
||||
import { Prompt } from '@/types/prompt';
|
||||
import { IconPlayerStop, IconRepeat, IconSend } from '@tabler/icons-react';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
@@ -56,7 +56,7 @@ export const ChatInput: FC<Props> = ({
|
||||
|
||||
const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
||||
const value = e.target.value;
|
||||
const maxLength = model.id === OpenAIModelID.GPT_3_5 ? 12000 : 24000;
|
||||
const maxLength = model.maxLength;
|
||||
|
||||
if (value.length > maxLength) {
|
||||
alert(
|
||||
@@ -109,7 +109,10 @@ export const ChatInput: FC<Props> = ({
|
||||
const selectedPrompt = filteredPrompts[activePromptIndex];
|
||||
if (selectedPrompt) {
|
||||
setContent((prevContent) => {
|
||||
const newContent = prevContent?.replace(/\/\w*$/, selectedPrompt.content);
|
||||
const newContent = prevContent?.replace(
|
||||
/\/\w*$/,
|
||||
selectedPrompt.content,
|
||||
);
|
||||
return newContent;
|
||||
});
|
||||
handlePromptSelect(selectedPrompt);
|
||||
@@ -211,8 +214,9 @@ export const ChatInput: FC<Props> = ({
|
||||
if (textareaRef && textareaRef.current) {
|
||||
textareaRef.current.style.height = 'inherit';
|
||||
textareaRef.current.style.height = `${textareaRef.current?.scrollHeight}px`;
|
||||
textareaRef.current.style.overflow = `${textareaRef?.current?.scrollHeight > 400 ? 'auto' : 'hidden'
|
||||
}`;
|
||||
textareaRef.current.style.overflow = `${
|
||||
textareaRef?.current?.scrollHeight > 400 ? 'auto' : 'hidden'
|
||||
}`;
|
||||
}
|
||||
}, [content]);
|
||||
|
||||
@@ -257,15 +261,16 @@ export const ChatInput: FC<Props> = ({
|
||||
<div className="relative mx-2 flex w-full flex-grow flex-col rounded-md border border-black/10 bg-white shadow-[0_0_10px_rgba(0,0,0,0.10)] dark:border-gray-900/50 dark:bg-[#40414F] dark:text-white dark:shadow-[0_0_15px_rgba(0,0,0,0.10)] sm:mx-4">
|
||||
<textarea
|
||||
ref={textareaRef}
|
||||
className="m-0 w-full resize-none border-0 bg-transparent p-0 pr-8 pl-2 text-black dark:bg-transparent dark:text-white py-2 md:py-3 md:pl-4"
|
||||
className="m-0 w-full resize-none border-0 bg-transparent p-0 py-2 pr-8 pl-2 text-black dark:bg-transparent dark:text-white md:py-3 md:pl-4"
|
||||
style={{
|
||||
resize: 'none',
|
||||
bottom: `${textareaRef?.current?.scrollHeight}px`,
|
||||
maxHeight: '400px',
|
||||
overflow: `${textareaRef.current && textareaRef.current.scrollHeight > 400
|
||||
? 'auto'
|
||||
: 'hidden'
|
||||
}`,
|
||||
overflow: `${
|
||||
textareaRef.current && textareaRef.current.scrollHeight > 400
|
||||
? 'auto'
|
||||
: 'hidden'
|
||||
}`,
|
||||
}}
|
||||
placeholder={
|
||||
t('Type a message or type "/" to select a prompt...') || ''
|
||||
@@ -278,7 +283,7 @@ export const ChatInput: FC<Props> = ({
|
||||
onKeyDown={handleKeyDown}
|
||||
/>
|
||||
<button
|
||||
className="absolute right-2 top-2 rounded-sm p-1 text-neutral-800 hover:bg-neutral-200 hover:text-neutral-900 dark:bg-opacity-50 dark:text-neutral-100 dark:hover:text-neutral-200 opacity-60"
|
||||
className="absolute right-2 top-2 rounded-sm p-1 text-neutral-800 opacity-60 hover:bg-neutral-200 hover:text-neutral-900 dark:bg-opacity-50 dark:text-neutral-100 dark:hover:text-neutral-200"
|
||||
onClick={handleSend}
|
||||
>
|
||||
<IconSend size={18} />
|
||||
|
||||
Reference in New Issue
Block a user