set maxToken based on model

This commit is contained in:
2023-03-29 13:02:48 +08:00
parent 6406993e83
commit c31c6cd84a
2 changed files with 14 additions and 11 deletions

View File

@@ -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
)
)
);

View File

@@ -17,20 +17,21 @@ const Help = (props: { children: any; help: string }) => {
);
};
// model and their max token
export const options: Record<string, number> = {
"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<string, number> = {
"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 (
<Help help={props.help}>
<label className="m-2 p-2">Model</label>