feat: add model config to settings

This commit is contained in:
Yifei Zhang
2023-03-21 16:20:32 +00:00
parent 4af8c26d02
commit 2f112ecc54
7 changed files with 517 additions and 258 deletions

View File

@@ -1,7 +1,7 @@
import type { ChatRequest, ChatReponse } from "./api/chat/typing";
import { Message } from "./store";
import { filterConfig, isValidModel, Message, ModelConfig } from "./store";
const TIME_OUT_MS = 30000
const TIME_OUT_MS = 30000;
const makeRequestParam = (
messages: Message[],
@@ -44,6 +44,7 @@ export async function requestChatStream(
messages: Message[],
options?: {
filterBot?: boolean;
modelConfig?: ModelConfig;
onMessage: (message: string, done: boolean) => void;
onError: (error: Error) => void;
}
@@ -53,6 +54,13 @@ export async function requestChatStream(
filterBot: options?.filterBot,
});
// valid and assign model config
if (options?.modelConfig) {
Object.assign(req, filterConfig(options.modelConfig));
}
console.log("[Request] ", req);
const controller = new AbortController();
const reqTimeoutId = setTimeout(() => controller.abort(), TIME_OUT_MS);