feat: #1000 ready to support client-side only

This commit is contained in:
Yidadaa
2023-06-14 00:37:42 +08:00
parent e6b49a60c0
commit 50cd33dbb2
13 changed files with 133 additions and 36 deletions

View File

@@ -1,5 +1,5 @@
import { ACCESS_CODE_PREFIX } from "../constant";
import { ChatMessage, ModelConfig, ModelType, useAccessStore } from "../store";
import { ChatMessage, ModelType, useAccessStore } from "../store";
import { ChatGPTApi } from "./platforms/openai";
export const ROLES = ["system", "user", "assistant"] as const;
@@ -42,6 +42,27 @@ export abstract class LLMApi {
abstract usage(): Promise<LLMUsage>;
}
type ProviderName = "openai" | "azure" | "claude" | "palm";
interface Model {
name: string;
provider: ProviderName;
ctxlen: number;
}
interface ChatProvider {
name: ProviderName;
apiConfig: {
baseUrl: string;
apiKey: string;
summaryModel: Model;
};
models: Model[];
chat: () => void;
usage: () => void;
}
export class ClientApi {
public llm: LLMApi;