feat: add multi-model support

This commit is contained in:
Yidadaa
2023-09-26 00:19:21 +08:00
parent b90dfb48ee
commit 5610f423d0
62 changed files with 1439 additions and 940 deletions

28
app/client/core.ts Normal file
View File

@@ -0,0 +1,28 @@
import { MaskConfig, ProviderConfig } from "../store";
import { shareToShareGPT } from "./common/share";
import { createOpenAiClient } from "./openai";
import { ChatControllerPool } from "./common/controller";
export const LLMClients = {
openai: createOpenAiClient,
};
export function createLLMClient(
config: ProviderConfig,
maskConfig: MaskConfig,
) {
return LLMClients[maskConfig.provider as any as keyof typeof LLMClients](
config,
maskConfig.modelConfig,
);
}
export function createApi() {
return {
createLLMClient,
shareToShareGPT,
controllerManager: ChatControllerPool,
};
}
export const api = createApi();