import { Schema } from "koishi"; /** 模型切换策略 */ export declare enum ModelSwitchingStrategy { Failover = "failover",// 故障转移 (默认) RoundRobin = "round-robin" } /** 内容验证失败时的处理动作 */ export declare enum ContentFailureAction { FailoverToNext = "failover_to_next",// 立即切换到下一个模型 AugmentAndRetry = "augment_and_retry" } /** 定义超时策略 */ export interface TimeoutPolicy { /** 首次响应超时 (秒) */ firstTokenTimeout?: number; /** 总请求超时 (秒) */ totalTimeout: number; } /** 定义重试策略 */ export interface RetryPolicy { /** 最大重试次数 (在同一模型上) */ maxRetries: number; /** 内容验证失败时的动作 */ onContentFailure: ContentFailureAction; } /** 定义断路器策略 */ export interface CircuitBreakerPolicy { /** 触发断路的连续失败次数 */ failureThreshold: number; /** 断路器开启后的冷却时间 (秒) */ cooldownSeconds: number; } /** 定义模型支持的能力 */ export declare enum ModelAbility { Vision = "\u89C6\u89C9", WebSearch = "\u7F51\u7EDC\u641C\u7D22", Reasoning = "\u63A8\u7406", FunctionCalling = "\u51FD\u6570\u8C03\u7528", Embedding = "\u5D4C\u5165", Chat = "\u5BF9\u8BDD" } /** * @enum TaskType * @description 定义了系统中的核心AI任务类型,用于类型安全地分配模型组。 */ export declare enum TaskType { Chat = "chat", Embedding = "embed", Summarization = "summarize", Memory = "memory" } /** 描述一个模型在特定提供商中的位置 */ export type ModelDescriptor = { providerName: string; modelId: string; }; export interface ModelConfig { providerName?: string; modelId: string; abilities: ModelAbility[]; parameters?: { temperature?: number; topP?: number; stream?: boolean; custom?: Array<{ key: string; type: "string" | "number" | "boolean" | "object"; value: string; }>; }; /** 超时策略 */ timeoutPolicy?: TimeoutPolicy; /** 重试策略 */ retryPolicy?: RetryPolicy; /** 断路器策略 */ circuitBreakerPolicy?: CircuitBreakerPolicy; } export declare const ModelConfigSchema: Schema; declare const PROVIDERS: { readonly OpenAI: { readonly baseURL: "https://api.openai.com/v1/"; readonly link: "https://platform.openai.com/account/api-keys"; }; readonly "OpenAI Compatible": { readonly baseURL: "https://api.openai.com/v1/"; readonly link: "https://platform.openai.com/account/api-keys"; }; readonly Anthropic: { readonly baseURL: "https://api.anthropic.com/v1/"; readonly link: "https://console.anthropic.com/settings/keys"; }; readonly Fireworks: { readonly baseURL: "https://api.fireworks.ai/inference/v1/"; readonly link: "https://console.fireworks.ai/api-keys"; }; readonly DeepSeek: { readonly baseURL: "https://api.deepseek.com/"; readonly link: "https://platform.deepseek.com/api_keys"; }; readonly "Google Gemini": { readonly baseURL: "https://generativelanguage.googleapis.com/v1beta/openai/"; readonly link: "https://aistudio.google.com/app/apikey"; }; readonly "LM Studio": { readonly baseURL: "http://localhost:5000/v1/"; readonly link: "https://lmstudio.ai/docs/app/api/endpoints/openai"; }; readonly "Workers AI": { readonly baseURL: "https://api.cloudflare.com/client/v4/"; readonly link: "https://dash.cloudflare.com/?to=/:account/workers-ai"; }; readonly Zhipu: { readonly baseURL: "https://open.bigmodel.cn/api/paas/v4/"; readonly link: "https://open.bigmodel.cn/usercenter/apikeys"; }; readonly "Silicon Flow": { readonly baseURL: "https://api.siliconflow.cn/v1/"; readonly link: "https://console.siliconflow.cn/account/key"; }; readonly Qwen: { readonly baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1/"; readonly link: "https://dashscope.console.aliyun.com/apiKey"; }; readonly Ollama: { readonly baseURL: "http://localhost:11434/v1/"; readonly link: "https://ollama.com/"; }; readonly Cerebras: { readonly baseURL: "https://api.cerebras.ai/v1/"; readonly link: "https://inference-docs.cerebras.ai/api-reference/chat-completions"; }; readonly DeepInfra: { readonly baseURL: "https://api.deepinfra.com/v1/openai/"; readonly link: "https://deepinfra.com/dash/api_keys"; }; readonly "Fatherless AI": { readonly baseURL: "https://api.featherless.ai/v1/"; readonly link: "https://featherless.ai/login"; }; readonly Groq: { readonly baseURL: "https://api.groq.com/openai/v1/"; readonly link: "https://console.groq.com/keys"; }; readonly Minimax: { readonly baseURL: "https://api.minimax.chat/v1/"; readonly link: "https://platform.minimaxi.com/api-key"; }; readonly "Minimax (International)": { readonly baseURL: "https://api.minimaxi.chat/v1/"; readonly link: "https://www.minimax.io/user-center/api-keys"; }; readonly Mistral: { readonly baseURL: "https://api.mistral.ai/v1/"; readonly link: "https://console.mistral.ai/api-keys/"; }; readonly Moonshot: { readonly baseURL: "https://api.moonshot.cn/v1/"; readonly link: "https://platform.moonshot.cn/console/api-keys"; }; readonly Novita: { readonly baseURL: "https://api.novita.ai/v3/openai/"; readonly link: "https://novita.ai/get-started"; }; readonly OpenRouter: { readonly baseURL: "https://openrouter.ai/api/v1/"; readonly link: "https://openrouter.ai/keys"; }; readonly Perplexity: { readonly baseURL: "https://api.perplexity.ai/"; readonly link: "https://www.perplexity.ai/settings/api"; }; readonly Stepfun: { readonly baseURL: "https://api.stepfun.com/v1/"; readonly link: "https://platform.stepfun.com/my-keys"; }; readonly "Tencent Hunyuan": { readonly baseURL: "https://api.hunyuan.cloud.tencent.com/v1/"; readonly link: "https://console.cloud.tencent.com/cam/capi"; }; readonly "Together AI": { readonly baseURL: "https://api.together.xyz/v1/"; readonly link: "https://api.together.ai/settings/api-keys"; }; readonly "XAI (Grok)": { readonly baseURL: "https://api.x.ai/v1/"; readonly link: "https://docs.x.ai/docs/overview"; }; }; export declare const PROVIDER_TYPES: ProviderType[]; export type ProviderType = keyof typeof PROVIDERS; export interface ProviderConfig { name: string; type: ProviderType; baseURL?: string; apiKey: string; proxy?: string; models: ModelConfig[]; } export declare const ProviderConfigSchema: Schema; export interface ModelServiceConfig { providers: ProviderConfig[]; modelGroups: { name: string; models: ModelDescriptor[]; strategy: ModelSwitchingStrategy; }[]; task: { [TaskType.Chat]: string; [TaskType.Embedding]: string; }; } export declare const ModelServiceConfigSchema: Schema; export {};