From c31c6cd84a360c1c75a0b93925f35f96d7a2ce8b Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Wed, 29 Mar 2023 13:02:48 +0800 Subject: [PATCH] set maxToken based on model --- src/app.tsx | 6 ++++-- src/settings.tsx | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index da39212..9f23e86 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -4,6 +4,7 @@ import "./global.css"; import { Message } from "./chatgpt"; import getDefaultParams from "./getDefaultParam"; import ChatBOX from "./chatbox"; +import { options } from "./settings"; export interface ChatStore { systemMessageContent: string; @@ -32,7 +33,7 @@ const newChatStore = ( postBeginIndex: 0, tokenMargin: 1024, totalTokens: 0, - maxTokens: 4096, + maxTokens: options[getDefaultParams("model", model)], apiKey: getDefaultParams("key", apiKey), apiEndpoint: getDefaultParams("api", apiEndpoint), streamMode: getDefaultParams("mode", streamMode), @@ -106,7 +107,8 @@ export function App() { chatStore.apiKey, chatStore.systemMessageContent, chatStore.apiEndpoint, - chatStore.streamMode + chatStore.streamMode, + chatStore.model ) ) ); diff --git a/src/settings.tsx b/src/settings.tsx index f5c0263..90e4dc7 100644 --- a/src/settings.tsx +++ b/src/settings.tsx @@ -17,20 +17,21 @@ const Help = (props: { children: any; help: string }) => { ); }; +// model and their max token +export const options: Record = { + "gpt-3.5-turbo": 4096, + "gpt-3.5-turbo-0301": 4096, + "gpt-4": 8192, + "gpt-4-0314": 8192, + "gpt-4-32k": 32768, + "gpt-4-32k-0314": 32768, +}; + const SelectModel = (props: { chatStore: ChatStore; setChatStore: (cs: ChatStore) => void; help: string; }) => { - // model and their max token - const options: Record = { - "gpt-3.5-turbo": 4096, - "gpt-3.5-turbo-0301": 4096, - "gpt-4": 8192, - "gpt-4-0314": 8192, - "gpt-4-32k": 32768, - "gpt-4-32k-0314": 32768, - }; return (