feat: 支持全局配置插件

This commit is contained in:
Hk-Gosuto
2023-08-16 13:38:15 +08:00
parent dd0b451a7c
commit 76eb2afd06
11 changed files with 147 additions and 8 deletions

View File

@@ -23,6 +23,11 @@ export interface LLMConfig {
frequency_penalty?: number;
}
export interface LLMAgentConfig {
maxIterations: number;
returnIntermediateSteps: boolean;
}
export interface ChatOptions {
messages: RequestMessage[];
config: LLMConfig;
@@ -33,6 +38,17 @@ export interface ChatOptions {
onController?: (controller: AbortController) => void;
}
export interface AgentChatOptions {
messages: RequestMessage[];
config: LLMConfig;
agentConfig: LLMAgentConfig;
onToolUpdate?: (toolName: string, toolInput: string) => void;
onUpdate?: (message: string, chunk: string) => void;
onFinish: (message: string) => void;
onError?: (err: Error) => void;
onController?: (controller: AbortController) => void;
}
export interface LLMUsage {
used: number;
total: number;
@@ -45,7 +61,7 @@ export interface LLMModel {
export abstract class LLMApi {
abstract chat(options: ChatOptions): Promise<void>;
abstract toolAgentChat(options: ChatOptions): Promise<void>;
abstract toolAgentChat(options: AgentChatOptions): Promise<void>;
abstract usage(): Promise<LLMUsage>;
abstract models(): Promise<LLMModel[]>;
}