补全utools.ai相关声明文件

This commit is contained in:
fofolee 2025-04-23 23:13:45 +08:00
parent d1b117186f
commit d4e58e58be

View File

@ -667,6 +667,134 @@ interface UToolsApi {
isLinux(): boolean;
ubrowser: UBrowser;
/**
* AI Function Calling
* @param option AI
* @param streamCallback ()
* @returns PromiseLike
*/
ai(option: AiOption): PromiseLike<Message>;
ai(
option: AiOption,
streamCallback: (chunk: Message) => void
): PromiseLike<void>;
/**
* AI
* @returns AI
*/
allAiModels(): Promise<AiModel[]>;
}
/**
* AI
*/
interface AiOption {
/**
* AI , 使 deepseek-v3
*/
model?: string;
/**
*
*/
messages: Message[];
/**
*
*/
tools?: Tool[];
}
/**
* AI
*/
interface Message {
/**
*
* system
* user
* assistantAI
*/
role: "system" | "user" | "assistant";
/**
*
*/
content?: string;
/**
*
*/
reasoning_content?: string;
}
/**
* AI
*/
interface Tool {
/**
*
* function
*/
type: "function";
/**
*
*/
function?: {
/**
*
*/
name: string;
/**
*
*/
description: string;
/**
*
*/
parameters: {
type: "object";
properties: Record<string, any>;
};
/**
*
*/
required?: string[];
};
}
/**
* AI
*/
interface AiModel {
/**
* AI ID utools.ai model
*/
id: string;
/**
* AI
*/
label: string;
/**
* AI
*/
description: string;
/**
* AI
*/
icon: string;
/**
* AI
*/
cost: number;
}
/**
* Promise abort()
*/
interface PromiseLike<T> extends Promise<T> {
/**
* AI
*/
abort(): void;
}
declare var utools: UToolsApi;