import OpenAI from "openai"; import McpTool from "./McpTool"; import { ChatCompletionMessageParam, ChatCompletionTool } from "openai/resources/index"; import LLMStreamChoiceDeltaTooCall from "./response/LLMStreamChoiceDeltaTooCall"; import McpClient from "./McpClient"; import { ChatCompletionNamedToolChoice } from "openai/resources/chat/index"; import LLMCallBackMessage from "./response/LLMCallBackMessage"; export default class LLMClient { static readonly CONTENT_THINKING = "thinking"; static readonly TYPE_FUNCTION = "function"; static readonly TYPE_STRING = "string"; static readonly REASON_STOP = "stop"; static readonly REASON_TOO_CALLS = "tool_calls"; static readonly ROLE_AI = "assistant"; static readonly ROLE_SYSTEM = "system"; static readonly ROLE_USER = "user"; static readonly ROLE_TOOL = "tool"; static readonly THINGKING_START_TAG = ""; static readonly THINGKING_END_TAG = ""; private static readonly TOOLS_CALLING_DESC; private static readonly TOOLS_CALLED_DESC; llm: OpenAI; mcpClient?: McpClient; modelName: string; mcpServer: string; tools: McpTool[]; initMcpState: boolean; thinkState: boolean; private logDebug; private toolChoice; constructor(mcpServer: string, mcpClientName: string, apiKey: string, baseUrl: string, modelName: string); initMcpServer(): Promise; chatStreamLLMV2(messages: ChatCompletionMessageParam[], onContentCallBack: (callBackMessage: LLMCallBackMessage) => void, onCallToolsCallBack: (_toolCalls: LLMStreamChoiceDeltaTooCall[]) => void, onCallToolResultCallBack: (name: string, result: any) => void, callBackMessage: LLMCallBackMessage, controllerRef: AbortController | null, loop?: number): Promise; private genLLMStream; private filterChoiceMessage; private dealFinishReason; private reBuildMessages; private buildMessageToolCall; private dealToolCalls; private dealTextContent; listTools(): McpTool[]; convert2OpenAiTools(tools: McpTool[]): ChatCompletionTool[]; getLogDebug(): boolean; setLogDebug(logDebug?: boolean): void; getToolChoice(): "required" | OpenAI.Chat.Completions.ChatCompletionNamedToolChoice | "none" | "auto"; setToolChoice(toolChoice: "none" | "auto" | "required" | ChatCompletionNamedToolChoice): void; }