mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-10-10 07:23:23 +08:00
新增AI操作分类,支持AI对话(预设翻译、总结、shell生成)
This commit is contained in:
96
src/plugins/monaco/types/quickcomposer.d.ts
vendored
96
src/plugins/monaco/types/quickcomposer.d.ts
vendored
@@ -2512,4 +2512,100 @@ interface quickcomposerApi {
|
||||
*/
|
||||
waitForElement(selector: string, timeout?: number): Promise<void>;
|
||||
};
|
||||
|
||||
/**
|
||||
* AI 相关功能
|
||||
*/
|
||||
ai: {
|
||||
/**
|
||||
* 与 AI 进行对话
|
||||
* @param apiConfig API配置
|
||||
* @param content 对话内容
|
||||
* @example
|
||||
* // OpenAI 示例
|
||||
* const response = await quickcomposer.ai.chat(
|
||||
* {
|
||||
* modelType: "openai",
|
||||
* apiUrl: "https://api.openai.com/v1/chat/completions",
|
||||
* apiToken: "your-api-token",
|
||||
* model: "gpt-3.5-turbo"
|
||||
* },
|
||||
* {
|
||||
* prompt: "你好",
|
||||
* presetPrompt: "" // 使用预设提示词:translate/shell/summarize
|
||||
* }
|
||||
* );
|
||||
*
|
||||
* // Ollama 示例
|
||||
* const response = await quickcomposer.ai.chat(
|
||||
* {
|
||||
* modelType: "ollama",
|
||||
* apiUrl: "http://localhost:11434/api/generate",
|
||||
* model: "qwen2.5:32b"
|
||||
* },
|
||||
* {
|
||||
* prompt: "查找进程名为chrome的进程并关闭",
|
||||
* presetPrompt: "shell"
|
||||
* }
|
||||
* );
|
||||
*/
|
||||
chat(
|
||||
apiConfig: {
|
||||
/** 模型类型:openai/ollama */
|
||||
modelType: "openai" | "ollama";
|
||||
/** API地址 */
|
||||
apiUrl: string;
|
||||
/** API令牌(仅 OpenAI 需要) */
|
||||
apiToken?: string;
|
||||
/** 模型名称 */
|
||||
model: string;
|
||||
},
|
||||
content: {
|
||||
/** 提示词 */
|
||||
prompt: string;
|
||||
/** 预设提示词类型 */
|
||||
presetPrompt?: "" | "translate" | "shell" | "summarize";
|
||||
}
|
||||
): Promise<{
|
||||
/** 是否成功 */
|
||||
success: boolean;
|
||||
/** AI 响应内容 */
|
||||
result?: string;
|
||||
/** 错误信息 */
|
||||
error?: string;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* 获取 API 支持的模型列表
|
||||
* @param apiConfig API配置
|
||||
* @example
|
||||
* // OpenAI 示例
|
||||
* const models = await quickcomposer.ai.getModels({
|
||||
* modelType: "openai",
|
||||
* apiUrl: "https://api.openai.com/v1/models",
|
||||
* apiToken: "your-api-token"
|
||||
* });
|
||||
*
|
||||
* // Ollama 示例
|
||||
* const models = await quickcomposer.ai.getModels({
|
||||
* modelType: "ollama",
|
||||
* apiUrl: "http://localhost:11434"
|
||||
* });
|
||||
*/
|
||||
getModels(apiConfig: {
|
||||
/** 模型类型:openai/ollama */
|
||||
modelType: "openai" | "ollama";
|
||||
/** API地址 */
|
||||
apiUrl: string;
|
||||
/** API令牌(仅 OpenAI 需要) */
|
||||
apiToken?: string;
|
||||
}): Promise<{
|
||||
/** 是否成功 */
|
||||
success: boolean;
|
||||
/** 模型名称列表 */
|
||||
result?: string[];
|
||||
/** 错误信息 */
|
||||
error?: string;
|
||||
}>;
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user