sync upstream code

This commit is contained in:
Hk-Gosuto
2023-07-06 00:19:05 +08:00
parent 94a50f92e1
commit 04d3c1f315
12 changed files with 169 additions and 8 deletions

View File

@@ -2,6 +2,7 @@ import { getClientConfig } from "../config/client";
import { ACCESS_CODE_PREFIX } from "../constant";
import { ChatMessage, ModelType, useAccessStore } from "../store";
import { ChatGPTApi } from "./platforms/openai";
import { DuckDuckGoSearch } from "./tools/ddg_search";
export const ROLES = ["system", "user", "assistant"] as const;
export type MessageRole = (typeof ROLES)[number];
@@ -12,6 +13,7 @@ export type ChatModel = ModelType;
export interface RequestMessage {
role: MessageRole;
content: string;
toolPrompt?: string;
}
export interface LLMConfig {
@@ -70,11 +72,19 @@ interface ChatProvider {
usage: () => void;
}
export abstract class ToolApi {
abstract call(input: string): Promise<string>;
abstract name: string;
abstract description: string;
}
export class ClientApi {
public llm: LLMApi;
public searchTool: ToolApi;
constructor() {
this.llm = new ChatGPTApi();
this.searchTool = new DuckDuckGoSearch();
}
config() {}