import { AnthropicCtodService } from './index.js'; import { PolymorphicMessage } from '../../broker/chat.js'; type AnthropicSdk = AnthropicCtodService['anthropicSdk']; export type Message = { role: string; content?: string; contents?: PolymorphicMessage[]; }; export type Config = { /** * @zh 選擇運行的模型。 * @en What model to use. */ model: string; maxTokens: number; temperature: number; thinking: boolean; }; export declare class AnthropicChatDataGenerator { private config; constructor(config: () => Config); /** * 移除 system 訊息 */ private translateMessages; getThinkingParams(): { readonly budget_tokens: number; readonly type: "enabled"; } | undefined; createChatAndStructureBody(messages: Message[], jsonSchema: any): Parameters[0]; parseChatAndStructureResult(result: Awaited>): string; createTalkBody(messages: Message[]): Parameters[0]; parseTalkResult(result: Awaited>): string; parseTalkThingsResult(result: Awaited>): string[]; createTalkStreamBody(messages: Message[]): Parameters[0]; } export declare class AnthropicChat { anthropic: AnthropicCtodService; dataGenerator: AnthropicChatDataGenerator; config: Config; constructor(anthropic: AnthropicCtodService); /** * @zh 改變對話的一些設定 * @en Change some settings of the conversation */ setConfig(options: Partial): void; /** * @zh 進行對話,並且以結構化的方式輸出 * @en Talk to the AI and output in a structured way */ chatAndStructure(messages: Message[], jsonSchema: any, options?: { abortController?: AbortController; }): Promise; chatAndStructureWithDetails(messages: Message[], jsonSchema: any, options?: { abortController?: AbortController; }): Promise<{ data: string; thinking: string[]; }>; /** * @zh 進行對話 * @en Talk to the AI */ talk(messages?: Message[]): Promise; /** * @zh 進行對話,並且回傳詳細內容 * @en Talk to the AI and return detailed content */ talkAndDetails(messages?: Message[]): Promise<{ text: string; thinking: string[]; }>; /** * @zh 進行對話,並且以串流的方式輸出 * @en Talk to the AI and output in a streaming way */ talkStream(params: { messages: Message[]; onMessage: (_message: string) => void; onThinking?: (_thinking: string) => void; onEnd: (_params: { isManualCancelled: boolean; }) => void; onError: (_error: any) => void; }): { isManualCancelled: () => boolean; cancel: () => void; }; } export type AnthropicChatTalkResponse = Awaited>; export {};