feat: 使用langchain实现插件功能

This commit is contained in:
Hk-Gosuto
2023-07-22 15:38:44 +08:00
parent 9223f95726
commit 2bb421b8bf
12 changed files with 906 additions and 128 deletions

View File

@@ -13,7 +13,6 @@ export type ChatModel = ModelType;
export interface RequestMessage {
role: MessageRole;
content: string;
toolPrompt?: string;
}
export interface LLMConfig {
@@ -28,7 +27,7 @@ export interface LLMConfig {
export interface ChatOptions {
messages: RequestMessage[];
config: LLMConfig;
onToolUpdate?: (toolName: string, toolInput: string) => void;
onUpdate?: (message: string, chunk: string) => void;
onFinish: (message: string) => void;
onError?: (err: Error) => void;
@@ -47,6 +46,7 @@ export interface LLMModel {
export abstract class LLMApi {
abstract chat(options: ChatOptions): Promise<void>;
abstract toolAgentChat(options: ChatOptions): Promise<void>;
abstract usage(): Promise<LLMUsage>;
abstract models(): Promise<LLMModel[]>;
}