From 325da54e4cc36a41fa1b07e2cfde3c059b577dde Mon Sep 17 00:00:00 2001 From: Jing Hua Date: Tue, 28 Mar 2023 16:04:31 +0800 Subject: [PATCH] fix: chat import model --- src/utils/chat.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/utils/chat.ts b/src/utils/chat.ts index 6e656e9..997c9c4 100644 --- a/src/utils/chat.ts +++ b/src/utils/chat.ts @@ -3,7 +3,11 @@ import html2canvas from 'html2canvas'; import { ChatInterface, ConfigInterface, MessageInterface } from '@type/chat'; import { roles } from '@type/chat'; import { Theme } from '@type/theme'; -import { _defaultChatConfig } from '@constants/chat'; +import { + defaultModel, + modelOptions, + _defaultChatConfig, +} from '@constants/chat'; export const validateAndFixChats = (chats: any): chats is ChatInterface[] => { if (!Array.isArray(chats)) return false; @@ -49,6 +53,9 @@ const validateAndFixChatConfig = (config: ConfigInterface) => { config.frequency_penalty = _defaultChatConfig.frequency_penalty; if (!(typeof config.frequency_penalty === 'number')) return false; + if (!config.model) config.model = defaultModel; + if (!modelOptions.includes(config.model)) return false; + return true; };