set maxToken based on model
This commit is contained in:
@@ -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
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -17,13 +17,8 @@ const Help = (props: { children: any; help: string }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const SelectModel = (props: {
|
||||
chatStore: ChatStore;
|
||||
setChatStore: (cs: ChatStore) => void;
|
||||
help: string;
|
||||
}) => {
|
||||
// model and their max token
|
||||
const options: Record<string, number> = {
|
||||
export const options: Record<string, number> = {
|
||||
"gpt-3.5-turbo": 4096,
|
||||
"gpt-3.5-turbo-0301": 4096,
|
||||
"gpt-4": 8192,
|
||||
@@ -31,6 +26,12 @@ const SelectModel = (props: {
|
||||
"gpt-4-32k": 32768,
|
||||
"gpt-4-32k-0314": 32768,
|
||||
};
|
||||
|
||||
const SelectModel = (props: {
|
||||
chatStore: ChatStore;
|
||||
setChatStore: (cs: ChatStore) => void;
|
||||
help: string;
|
||||
}) => {
|
||||
return (
|
||||
<Help help={props.help}>
|
||||
<label className="m-2 p-2">Model</label>
|
||||
|
||||
Reference in New Issue
Block a user