sa2kit 3.3.0 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-LGVPFYPR.mjs → chunk-4H3SGG3T.mjs} +27 -3
- package/dist/chunk-4H3SGG3T.mjs.map +1 -0
- package/dist/{chunk-KVYHCGRY.js → chunk-7Z3XR2Y4.js} +552 -263
- package/dist/chunk-7Z3XR2Y4.js.map +1 -0
- package/dist/{chunk-5H2FICSO.js → chunk-LBMUIWJR.js} +27 -3
- package/dist/chunk-LBMUIWJR.js.map +1 -0
- package/dist/chunk-XPY45Y75.js +1143 -0
- package/dist/chunk-XPY45Y75.js.map +1 -0
- package/dist/{chunk-YIRPPMCN.mjs → chunk-XSTMLLJV.mjs} +474 -198
- package/dist/chunk-XSTMLLJV.mjs.map +1 -0
- package/dist/chunk-ZJLS5JU5.mjs +1090 -0
- package/dist/chunk-ZJLS5JU5.mjs.map +1 -0
- package/dist/common/aiApi/client/index.d.mts +71 -0
- package/dist/common/aiApi/client/index.d.ts +71 -0
- package/dist/common/aiApi/client/index.js +165 -0
- package/dist/common/aiApi/client/index.js.map +1 -0
- package/dist/common/aiApi/client/index.mjs +151 -0
- package/dist/common/aiApi/client/index.mjs.map +1 -0
- package/dist/common/aiApi/index.d.mts +184 -0
- package/dist/common/aiApi/index.d.ts +184 -0
- package/dist/common/aiApi/index.js +217 -0
- package/dist/common/aiApi/index.mjs +4 -0
- package/dist/common/aiApi/server/index.d.mts +3 -0
- package/dist/common/aiApi/server/index.d.ts +3 -0
- package/dist/common/aiApi/server/index.js +217 -0
- package/dist/common/aiApi/server/index.mjs +4 -0
- package/dist/common/auth/server/index.js +8 -8
- package/dist/common/auth/server/index.mjs +2 -2
- package/dist/common/components/index.js +176 -177
- package/dist/common/components/index.mjs +1 -2
- package/dist/common/config/bootstrap/index.d.mts +24 -0
- package/dist/common/config/bootstrap/index.d.ts +24 -0
- package/dist/common/config/bootstrap/index.js +15 -15
- package/dist/common/config/bootstrap/index.mjs +1 -1
- package/dist/common/config/server/index.js +14 -14
- package/dist/common/config/server/index.mjs +1 -1
- package/dist/common/index.js +2 -3
- package/dist/common/index.mjs +1 -2
- package/dist/index.d.mts +314 -154
- package/dist/index.d.ts +314 -154
- package/dist/index.js +1055 -369
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1005 -360
- package/dist/index.mjs.map +1 -1
- package/dist/types-CiqMQ-uu.d.mts +166 -0
- package/dist/types-CiqMQ-uu.d.ts +166 -0
- package/package.json +15 -50
- package/dist/chunk-3R6JHA6D.js +0 -120
- package/dist/chunk-3R6JHA6D.js.map +0 -1
- package/dist/chunk-4PJM4752.js +0 -4
- package/dist/chunk-4PJM4752.js.map +0 -1
- package/dist/chunk-5H2FICSO.js.map +0 -1
- package/dist/chunk-7PMT4L4I.js +0 -324
- package/dist/chunk-7PMT4L4I.js.map +0 -1
- package/dist/chunk-FY2X3LYR.mjs +0 -3
- package/dist/chunk-FY2X3LYR.mjs.map +0 -1
- package/dist/chunk-GS4SAW25.mjs +0 -116
- package/dist/chunk-GS4SAW25.mjs.map +0 -1
- package/dist/chunk-HL4H2HF6.js +0 -279
- package/dist/chunk-HL4H2HF6.js.map +0 -1
- package/dist/chunk-IJIQUMAK.mjs +0 -272
- package/dist/chunk-IJIQUMAK.mjs.map +0 -1
- package/dist/chunk-KVYHCGRY.js.map +0 -1
- package/dist/chunk-LGVPFYPR.mjs.map +0 -1
- package/dist/chunk-MMDSZIXD.mjs +0 -286
- package/dist/chunk-MMDSZIXD.mjs.map +0 -1
- package/dist/chunk-N2O3OX5Y.mjs +0 -243
- package/dist/chunk-N2O3OX5Y.mjs.map +0 -1
- package/dist/chunk-RRQ2X26Z.js +0 -106
- package/dist/chunk-RRQ2X26Z.js.map +0 -1
- package/dist/chunk-RVNQI6BI.js +0 -249
- package/dist/chunk-RVNQI6BI.js.map +0 -1
- package/dist/chunk-UJUWDF7M.mjs +0 -336
- package/dist/chunk-UJUWDF7M.mjs.map +0 -1
- package/dist/chunk-VCKXK6V5.js +0 -345
- package/dist/chunk-VCKXK6V5.js.map +0 -1
- package/dist/chunk-VIEXDTNF.mjs +0 -100
- package/dist/chunk-VIEXDTNF.mjs.map +0 -1
- package/dist/chunk-YIRPPMCN.mjs.map +0 -1
- package/dist/common/ai/llm/core/index.d.mts +0 -70
- package/dist/common/ai/llm/core/index.d.ts +0 -70
- package/dist/common/ai/llm/core/index.js +0 -54
- package/dist/common/ai/llm/core/index.mjs +0 -5
- package/dist/common/ai/llm/electron/index.d.mts +0 -6
- package/dist/common/ai/llm/electron/index.d.ts +0 -6
- package/dist/common/ai/llm/electron/index.js +0 -67
- package/dist/common/ai/llm/electron/index.mjs +0 -10
- package/dist/common/ai/llm/index.d.mts +0 -3
- package/dist/common/ai/llm/index.d.ts +0 -3
- package/dist/common/ai/llm/index.js +0 -54
- package/dist/common/ai/llm/index.js.map +0 -1
- package/dist/common/ai/llm/index.mjs +0 -5
- package/dist/common/ai/llm/index.mjs.map +0 -1
- package/dist/common/ai/llm/miniapp/index.d.mts +0 -6
- package/dist/common/ai/llm/miniapp/index.d.ts +0 -6
- package/dist/common/ai/llm/miniapp/index.js +0 -59
- package/dist/common/ai/llm/miniapp/index.js.map +0 -1
- package/dist/common/ai/llm/miniapp/index.mjs +0 -6
- package/dist/common/ai/llm/miniapp/index.mjs.map +0 -1
- package/dist/common/ai/llm/rn/index.d.mts +0 -6
- package/dist/common/ai/llm/rn/index.d.ts +0 -6
- package/dist/common/ai/llm/rn/index.js +0 -59
- package/dist/common/ai/llm/rn/index.js.map +0 -1
- package/dist/common/ai/llm/rn/index.mjs +0 -6
- package/dist/common/ai/llm/rn/index.mjs.map +0 -1
- package/dist/common/ai/llm/ui/electron/index.d.mts +0 -5
- package/dist/common/ai/llm/ui/electron/index.d.ts +0 -5
- package/dist/common/ai/llm/ui/electron/index.js +0 -22
- package/dist/common/ai/llm/ui/electron/index.js.map +0 -1
- package/dist/common/ai/llm/ui/electron/index.mjs +0 -9
- package/dist/common/ai/llm/ui/electron/index.mjs.map +0 -1
- package/dist/common/ai/llm/ui/miniapp/index.d.mts +0 -9
- package/dist/common/ai/llm/ui/miniapp/index.d.ts +0 -9
- package/dist/common/ai/llm/ui/miniapp/index.js +0 -14
- package/dist/common/ai/llm/ui/miniapp/index.js.map +0 -1
- package/dist/common/ai/llm/ui/miniapp/index.mjs +0 -5
- package/dist/common/ai/llm/ui/miniapp/index.mjs.map +0 -1
- package/dist/common/ai/llm/ui/rn/index.d.mts +0 -9
- package/dist/common/ai/llm/ui/rn/index.d.ts +0 -9
- package/dist/common/ai/llm/ui/rn/index.js +0 -14
- package/dist/common/ai/llm/ui/rn/index.js.map +0 -1
- package/dist/common/ai/llm/ui/rn/index.mjs +0 -5
- package/dist/common/ai/llm/ui/rn/index.mjs.map +0 -1
- package/dist/common/ai/llm/ui/web/index.d.mts +0 -15
- package/dist/common/ai/llm/ui/web/index.d.ts +0 -15
- package/dist/common/ai/llm/ui/web/index.js +0 -21
- package/dist/common/ai/llm/ui/web/index.js.map +0 -1
- package/dist/common/ai/llm/ui/web/index.mjs +0 -8
- package/dist/common/ai/llm/ui/web/index.mjs.map +0 -1
- package/dist/common/ai/llm/web/index.d.mts +0 -6
- package/dist/common/ai/llm/web/index.d.ts +0 -6
- package/dist/common/ai/llm/web/index.js +0 -66
- package/dist/common/ai/llm/web/index.js.map +0 -1
- package/dist/common/ai/llm/web/index.mjs +0 -9
- package/dist/common/ai/llm/web/index.mjs.map +0 -1
- package/dist/types-B2rs_jq1.d.mts +0 -38
- package/dist/types-DgACCUpT.d.ts +0 -122
- package/dist/types-DwS2Eg0q.d.ts +0 -38
- package/dist/types-LU_BGSzk.d.mts +0 -122
- /package/dist/common/{ai/llm/core → aiApi}/index.js.map +0 -0
- /package/dist/common/{ai/llm/core → aiApi}/index.mjs.map +0 -0
- /package/dist/common/{ai/llm/electron → aiApi/server}/index.js.map +0 -0
- /package/dist/common/{ai/llm/electron → aiApi/server}/index.mjs.map +0 -0
package/dist/index.d.mts
CHANGED
|
@@ -10495,188 +10495,348 @@ interface SmartAssistantProps {
|
|
|
10495
10495
|
}
|
|
10496
10496
|
declare const SmartAssistant: React__default.FC<SmartAssistantProps>;
|
|
10497
10497
|
|
|
10498
|
-
|
|
10499
|
-
type
|
|
10500
|
-
|
|
10501
|
-
|
|
10502
|
-
|
|
10503
|
-
|
|
10504
|
-
|
|
10505
|
-
|
|
10506
|
-
|
|
10507
|
-
|
|
10508
|
-
|
|
10509
|
-
|
|
10510
|
-
|
|
10511
|
-
|
|
10512
|
-
|
|
10513
|
-
|
|
10514
|
-
|
|
10515
|
-
|
|
10516
|
-
|
|
10517
|
-
|
|
10518
|
-
|
|
10519
|
-
|
|
10520
|
-
|
|
10521
|
-
|
|
10522
|
-
|
|
10523
|
-
|
|
10524
|
-
id: string;
|
|
10525
|
-
type: 'function';
|
|
10526
|
-
function: {
|
|
10527
|
-
name: string;
|
|
10528
|
-
arguments: string;
|
|
10529
|
-
};
|
|
10530
|
-
};
|
|
10531
|
-
interface AiMessage {
|
|
10532
|
-
role: AiRole;
|
|
10533
|
-
content: string;
|
|
10534
|
-
name?: string;
|
|
10535
|
-
toolCallId?: string;
|
|
10536
|
-
toolCalls?: AiToolCall[];
|
|
10498
|
+
/** 音频处理策略:native=chat 内嵌音频,stt=先转写再 chat,auto=按模型能力自动选择(失败时 STT 回退) */
|
|
10499
|
+
type AudioStrategy = 'native' | 'stt' | 'auto';
|
|
10500
|
+
/** 连接配置(调用方可显式传入,或与 env 合并) */
|
|
10501
|
+
interface AiConnectionSettings {
|
|
10502
|
+
apiKey: string;
|
|
10503
|
+
baseUrl: string;
|
|
10504
|
+
model?: string;
|
|
10505
|
+
textModel?: string;
|
|
10506
|
+
visionModel?: string;
|
|
10507
|
+
audioModel?: string;
|
|
10508
|
+
audioStrategy?: AudioStrategy;
|
|
10509
|
+
timeoutMs?: number;
|
|
10510
|
+
maxImageBytes?: number;
|
|
10511
|
+
maxAudioBytes?: number;
|
|
10512
|
+
}
|
|
10513
|
+
/** 客户端/请求可携带的 AI 连接配置(字段均可选,用于覆盖环境变量) */
|
|
10514
|
+
type AiClientSettings = Partial<AiConnectionSettings>;
|
|
10515
|
+
/** 解析后的完整连接配置 */
|
|
10516
|
+
interface AiConnectionConfig extends AiConnectionSettings {
|
|
10517
|
+
textModel: string;
|
|
10518
|
+
visionModel: string;
|
|
10519
|
+
audioModel: string;
|
|
10520
|
+
audioStrategy: AudioStrategy;
|
|
10521
|
+
timeoutMs: number;
|
|
10522
|
+
maxImageBytes: number;
|
|
10523
|
+
maxAudioBytes: number;
|
|
10537
10524
|
}
|
|
10538
|
-
|
|
10539
|
-
|
|
10540
|
-
|
|
10541
|
-
|
|
10525
|
+
/** 统一 AI 任务请求 */
|
|
10526
|
+
interface AiApiRunRequest<TInput = unknown> {
|
|
10527
|
+
taskId: string;
|
|
10528
|
+
input: TInput;
|
|
10529
|
+
options?: AiTaskRunOptions;
|
|
10530
|
+
clientSettings?: AiClientSettings;
|
|
10542
10531
|
}
|
|
10543
|
-
interface
|
|
10532
|
+
interface AiTaskRunOptions {
|
|
10544
10533
|
model?: string;
|
|
10545
10534
|
temperature?: number;
|
|
10546
10535
|
maxTokens?: number;
|
|
10547
|
-
topP?: number;
|
|
10548
|
-
stop?: string | string[];
|
|
10549
|
-
stream?: boolean;
|
|
10550
|
-
tools?: AiToolDefinition[];
|
|
10551
|
-
toolChoice?: 'auto' | 'none' | AiToolChoice;
|
|
10552
10536
|
}
|
|
10553
|
-
|
|
10554
|
-
|
|
10537
|
+
/** 统一 AI 任务响应 */
|
|
10538
|
+
interface AiApiResponse<TData = unknown> {
|
|
10539
|
+
success: boolean;
|
|
10540
|
+
taskId: string;
|
|
10541
|
+
data?: TData;
|
|
10542
|
+
error?: AiApiErrorBody;
|
|
10543
|
+
meta?: AiApiResponseMeta;
|
|
10544
|
+
}
|
|
10545
|
+
interface AiApiErrorBody {
|
|
10546
|
+
code: AiApiErrorCode;
|
|
10547
|
+
message: string;
|
|
10548
|
+
details?: unknown;
|
|
10549
|
+
}
|
|
10550
|
+
type AiApiErrorCode = 'UNAUTHORIZED' | 'INVALID_INPUT' | 'TASK_NOT_FOUND' | 'AI_CONFIG_MISSING' | 'AI_REQUEST_FAILED' | 'AI_PARSE_FAILED' | 'PAYLOAD_TOO_LARGE' | 'UNSUPPORTED_MEDIA';
|
|
10551
|
+
interface AiApiResponseMeta {
|
|
10552
|
+
model: string;
|
|
10553
|
+
latencyMs: number;
|
|
10554
|
+
provider?: string;
|
|
10555
|
+
confidence?: number;
|
|
10556
|
+
rawSummary?: string;
|
|
10557
|
+
}
|
|
10558
|
+
/** 多模态图片输入(base64) */
|
|
10559
|
+
interface AiImageInput {
|
|
10560
|
+
base64: string;
|
|
10561
|
+
mimeType: string;
|
|
10562
|
+
}
|
|
10563
|
+
/** 多模态音频输入(base64) */
|
|
10564
|
+
interface AiAudioInput {
|
|
10565
|
+
base64: string;
|
|
10566
|
+
mimeType: string;
|
|
10567
|
+
}
|
|
10568
|
+
type AiMediaKind = 'image' | 'audio';
|
|
10569
|
+
interface AiImageMediaInput extends AiImageInput {
|
|
10570
|
+
kind: 'image';
|
|
10571
|
+
}
|
|
10572
|
+
interface AiAudioMediaInput extends AiAudioInput {
|
|
10573
|
+
kind: 'audio';
|
|
10574
|
+
}
|
|
10575
|
+
type AiMediaInput = AiImageMediaInput | AiAudioMediaInput;
|
|
10576
|
+
/** 通用文本补全任务输入 */
|
|
10577
|
+
interface TextCompletionInput {
|
|
10578
|
+
systemPrompt?: string;
|
|
10579
|
+
userPrompt: string;
|
|
10580
|
+
model?: string;
|
|
10581
|
+
temperature?: number;
|
|
10582
|
+
maxTokens?: number;
|
|
10583
|
+
/** 显式连接配置,优先级高于 clientSettings / 环境变量 */
|
|
10584
|
+
connection?: AiClientSettings;
|
|
10555
10585
|
}
|
|
10556
|
-
|
|
10557
|
-
|
|
10586
|
+
/** 通用文本补全任务输出 */
|
|
10587
|
+
interface TextCompletionOutput {
|
|
10558
10588
|
content: string;
|
|
10559
|
-
|
|
10560
|
-
|
|
10561
|
-
|
|
10562
|
-
|
|
10589
|
+
rawText: string;
|
|
10590
|
+
}
|
|
10591
|
+
/** 通用结构化多模态任务输入 */
|
|
10592
|
+
interface StructuredMultimodalInput {
|
|
10593
|
+
systemPrompt: string;
|
|
10594
|
+
userPrompt: string;
|
|
10595
|
+
media?: AiMediaInput[];
|
|
10596
|
+
jsonSchemaHint?: string;
|
|
10597
|
+
model?: string;
|
|
10598
|
+
temperature?: number;
|
|
10599
|
+
maxTokens?: number;
|
|
10600
|
+
audioStrategy?: AudioStrategy;
|
|
10601
|
+
connection?: AiClientSettings;
|
|
10563
10602
|
}
|
|
10564
|
-
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
toolCalls?: AiToolCall[];
|
|
10569
|
-
raw?: unknown;
|
|
10603
|
+
/** 通用结构化多模态任务输出 */
|
|
10604
|
+
interface StructuredMultimodalOutput {
|
|
10605
|
+
json: Record<string, unknown>;
|
|
10606
|
+
rawText: string;
|
|
10570
10607
|
}
|
|
10571
|
-
|
|
10572
|
-
|
|
10573
|
-
|
|
10574
|
-
|
|
10575
|
-
|
|
10608
|
+
declare const CORE_LLM_COMPLETION_TASK_ID = "core.llmCompletion";
|
|
10609
|
+
declare const CORE_STRUCTURED_MULTIMODAL_TASK_ID = "core.structuredMultimodal";
|
|
10610
|
+
declare const CORE_CONNECTIVITY_TEST_TASK_ID = "core.connectivityTest";
|
|
10611
|
+
interface ConnectivityTestOutput {
|
|
10612
|
+
ok: boolean;
|
|
10613
|
+
reply: string;
|
|
10576
10614
|
}
|
|
10577
|
-
interface
|
|
10578
|
-
|
|
10579
|
-
|
|
10580
|
-
|
|
10615
|
+
interface AiModelsListRequest {
|
|
10616
|
+
clientSettings?: AiClientSettings;
|
|
10617
|
+
}
|
|
10618
|
+
interface AiModelsListResponse {
|
|
10619
|
+
success: boolean;
|
|
10620
|
+
models: string[];
|
|
10621
|
+
visionModels: string[];
|
|
10622
|
+
suggestedVisionModel?: string;
|
|
10623
|
+
error?: {
|
|
10624
|
+
code: string;
|
|
10625
|
+
message: string;
|
|
10626
|
+
};
|
|
10627
|
+
}
|
|
10628
|
+
interface AiTaskContext {
|
|
10629
|
+
requestId?: string;
|
|
10630
|
+
userId?: string | number;
|
|
10631
|
+
clientSettings?: AiClientSettings;
|
|
10632
|
+
}
|
|
10633
|
+
interface AiTaskDefinition<TInput = unknown, TOutput = unknown> {
|
|
10634
|
+
id: string;
|
|
10635
|
+
description?: string;
|
|
10636
|
+
validateInput: (input: unknown) => TInput;
|
|
10637
|
+
execute: (input: TInput, ctx: AiTaskContext) => Promise<{
|
|
10638
|
+
data: TOutput;
|
|
10639
|
+
meta?: Partial<AiApiResponseMeta>;
|
|
10640
|
+
}>;
|
|
10641
|
+
}
|
|
10642
|
+
interface MultimodalChatParams {
|
|
10643
|
+
systemPrompt: string;
|
|
10644
|
+
userPrompt: string;
|
|
10645
|
+
media?: AiMediaInput[];
|
|
10581
10646
|
model?: string;
|
|
10647
|
+
temperature?: number;
|
|
10648
|
+
maxTokens?: number;
|
|
10649
|
+
jsonMode?: boolean;
|
|
10650
|
+
audioStrategy?: AudioStrategy;
|
|
10651
|
+
connection?: AiClientSettings;
|
|
10652
|
+
}
|
|
10653
|
+
interface MultimodalChatResult {
|
|
10654
|
+
content: string;
|
|
10655
|
+
model: string;
|
|
10656
|
+
raw: unknown;
|
|
10657
|
+
/** auto/native/stt 实际采用的音频处理方式 */
|
|
10658
|
+
audioHandling?: 'none' | 'native' | 'stt';
|
|
10659
|
+
/** STT 或 native 失败回退时的转写文本 */
|
|
10660
|
+
transcriptions?: string[];
|
|
10661
|
+
}
|
|
10662
|
+
|
|
10663
|
+
/**
|
|
10664
|
+
* 合并连接配置:显式 connection > clientSettings > 环境变量。
|
|
10665
|
+
* 缺少 apiKey 时返回 null。
|
|
10666
|
+
*/
|
|
10667
|
+
declare function resolveAiConnectionConfig(...sources: Array<AiClientSettings | undefined>): AiConnectionConfig | null;
|
|
10668
|
+
declare function requireAiConnectionConfig(...sources: Array<AiClientSettings | undefined>): AiConnectionConfig;
|
|
10669
|
+
|
|
10670
|
+
type JsonRequestOptions = {
|
|
10671
|
+
url: string;
|
|
10672
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
10582
10673
|
headers?: Record<string, string>;
|
|
10674
|
+
body?: unknown;
|
|
10583
10675
|
timeoutMs?: number;
|
|
10584
10676
|
requestAdapter?: RequestAdapter;
|
|
10585
|
-
|
|
10586
|
-
|
|
10677
|
+
};
|
|
10678
|
+
declare function requestJson<T>(options: JsonRequestOptions): Promise<T>;
|
|
10679
|
+
|
|
10680
|
+
declare const DEFAULT_OPENAI_BASE_URL = "https://api.openai.com/v1";
|
|
10681
|
+
declare const DEFAULT_TEXT_MODEL = "gpt-4o-mini";
|
|
10682
|
+
type ChatRole = 'system' | 'user' | 'assistant';
|
|
10683
|
+
interface ChatMessage {
|
|
10684
|
+
role: ChatRole;
|
|
10685
|
+
content: string;
|
|
10587
10686
|
}
|
|
10588
|
-
interface
|
|
10687
|
+
interface CallChatOptions {
|
|
10688
|
+
/** OpenAI 兼容 API Base URL */
|
|
10589
10689
|
baseUrl: string;
|
|
10590
|
-
|
|
10591
|
-
|
|
10690
|
+
/** API Key */
|
|
10691
|
+
apiKey: string;
|
|
10692
|
+
model?: string;
|
|
10693
|
+
systemPrompt?: string;
|
|
10694
|
+
userPrompt?: string;
|
|
10695
|
+
messages?: ChatMessage[];
|
|
10696
|
+
temperature?: number;
|
|
10697
|
+
maxTokens?: number;
|
|
10698
|
+
topP?: number;
|
|
10699
|
+
stop?: string | string[];
|
|
10700
|
+
timeoutMs?: number;
|
|
10701
|
+
requestAdapter?: RequestAdapter;
|
|
10592
10702
|
}
|
|
10593
|
-
interface
|
|
10594
|
-
|
|
10595
|
-
|
|
10596
|
-
|
|
10597
|
-
}): Promise<AiChatResponse>;
|
|
10703
|
+
interface ChatUsage {
|
|
10704
|
+
promptTokens?: number;
|
|
10705
|
+
completionTokens?: number;
|
|
10706
|
+
totalTokens?: number;
|
|
10598
10707
|
}
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
|
|
10602
|
-
|
|
10708
|
+
interface CallChatResult {
|
|
10709
|
+
content: string;
|
|
10710
|
+
model: string;
|
|
10711
|
+
usage?: ChatUsage;
|
|
10712
|
+
raw?: unknown;
|
|
10603
10713
|
}
|
|
10604
|
-
|
|
10605
|
-
|
|
10714
|
+
/**
|
|
10715
|
+
* OpenAI 兼容文本对话:外部传入 URL、Key、提示词,返回模型生成内容。
|
|
10716
|
+
*/
|
|
10717
|
+
declare function callChat(options: CallChatOptions): Promise<CallChatResult>;
|
|
10718
|
+
|
|
10719
|
+
interface CallCompletionParams {
|
|
10606
10720
|
systemPrompt?: string;
|
|
10607
|
-
|
|
10608
|
-
|
|
10721
|
+
userPrompt: string;
|
|
10722
|
+
model?: string;
|
|
10723
|
+
temperature?: number;
|
|
10724
|
+
maxTokens?: number;
|
|
10725
|
+
connection?: AiClientSettings;
|
|
10609
10726
|
}
|
|
10610
|
-
interface
|
|
10611
|
-
|
|
10612
|
-
|
|
10613
|
-
|
|
10614
|
-
sendMessage(input: string, options?: AiChatInputOptions): Promise<AiChatResponse>;
|
|
10727
|
+
interface CallCompletionResult {
|
|
10728
|
+
content: string;
|
|
10729
|
+
model: string;
|
|
10730
|
+
raw?: unknown;
|
|
10615
10731
|
}
|
|
10732
|
+
/**
|
|
10733
|
+
* 文本补全:连接信息与提示词均由调用方传入(或通过 connection 合并 env)。
|
|
10734
|
+
*/
|
|
10735
|
+
declare function callCompletion(params: CallCompletionParams, clientSettings?: AiClientSettings): Promise<CallCompletionResult>;
|
|
10616
10736
|
|
|
10617
|
-
|
|
10737
|
+
/**
|
|
10738
|
+
* OpenAI 兼容多模态对话:文本 + 可选图片/语音。
|
|
10739
|
+
* audioStrategy=auto 时:优先 chat 内嵌音频(native),失败或未支持则 STT 转写后走文本 chat。
|
|
10740
|
+
*/
|
|
10741
|
+
declare function callMultimodalChat(params: MultimodalChatParams, clientSettings?: AiClientSettings): Promise<MultimodalChatResult>;
|
|
10618
10742
|
|
|
10619
|
-
declare
|
|
10743
|
+
declare function extractJsonObject(text: string): Record<string, unknown>;
|
|
10620
10744
|
|
|
10621
|
-
|
|
10622
|
-
|
|
10623
|
-
preserveUnknown?: boolean;
|
|
10624
|
-
}
|
|
10625
|
-
declare const applyPromptTemplate: (template: string, variables?: PromptVariables, options?: PromptTemplateOptions) => string;
|
|
10745
|
+
declare function assertValidImageInput(image: AiImageInput, maxImageBytes?: number): void;
|
|
10746
|
+
declare function fileToAiImageInput(file: File): Promise<AiImageInput>;
|
|
10626
10747
|
|
|
10627
|
-
declare
|
|
10628
|
-
declare
|
|
10629
|
-
declare
|
|
10748
|
+
declare function mimeToAudioFormat(mimeType: string): string;
|
|
10749
|
+
declare function assertValidAudioInput(audio: AiAudioInput, maxAudioBytes?: number): void;
|
|
10750
|
+
declare function fileToAiAudioInput(file: File): Promise<AiAudioInput>;
|
|
10751
|
+
declare function base64ToBlob(base64: string, mimeType: string): Blob;
|
|
10630
10752
|
|
|
10631
|
-
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
template?: string;
|
|
10635
|
-
initialMessages?: AiMessage[];
|
|
10636
|
-
}
|
|
10637
|
-
declare const useAiChat: (options: UseAiChatOptions) => {
|
|
10638
|
-
status: AiChatStatus;
|
|
10639
|
-
isLoading: boolean;
|
|
10640
|
-
error: Error | null;
|
|
10641
|
-
messages: AiMessage[];
|
|
10642
|
-
lastResponse: AiChatResponse | null;
|
|
10643
|
-
sendMessage: (input: string, requestOptions?: AiChatInputOptions) => Promise<AiChatResponse>;
|
|
10644
|
-
reset: () => void;
|
|
10645
|
-
setSystemPrompt: (prompt?: string) => void;
|
|
10753
|
+
declare function splitMediaByKind(media: AiMediaInput[]): {
|
|
10754
|
+
images: AiMediaInput[];
|
|
10755
|
+
audios: AiMediaInput[];
|
|
10646
10756
|
};
|
|
10757
|
+
declare function assertValidMultimodalMedia(media: AiMediaInput[] | undefined, limits: {
|
|
10758
|
+
maxImageBytes: number;
|
|
10759
|
+
maxAudioBytes: number;
|
|
10760
|
+
maxImages?: number;
|
|
10761
|
+
maxAudios?: number;
|
|
10762
|
+
}): AiMediaInput[];
|
|
10763
|
+
|
|
10764
|
+
type ResolvedAudioHandling = 'none' | 'native' | 'stt';
|
|
10765
|
+
declare function resolveAudioHandling(options: {
|
|
10766
|
+
hasAudio: boolean;
|
|
10767
|
+
strategy: AudioStrategy;
|
|
10768
|
+
model: string;
|
|
10769
|
+
baseUrl: string;
|
|
10770
|
+
}): ResolvedAudioHandling;
|
|
10771
|
+
declare function isAudioInputError(message: string): boolean;
|
|
10772
|
+
declare function appendTranscriptionsToPrompt(userPrompt: string, transcriptions: string[]): string;
|
|
10647
10773
|
|
|
10648
|
-
|
|
10649
|
-
|
|
10650
|
-
|
|
10651
|
-
|
|
10652
|
-
|
|
10774
|
+
interface TranscribeAudioOptions {
|
|
10775
|
+
audio: AiAudioInput;
|
|
10776
|
+
config: AiConnectionConfig;
|
|
10777
|
+
model?: string;
|
|
10778
|
+
language?: string;
|
|
10653
10779
|
}
|
|
10654
|
-
|
|
10655
|
-
|
|
10656
|
-
|
|
10657
|
-
|
|
10658
|
-
|
|
10659
|
-
|
|
10660
|
-
|
|
10661
|
-
|
|
10662
|
-
|
|
10663
|
-
|
|
10664
|
-
|
|
10665
|
-
|
|
10666
|
-
|
|
10667
|
-
|
|
10668
|
-
|
|
10669
|
-
declare
|
|
10670
|
-
declare
|
|
10671
|
-
|
|
10672
|
-
|
|
10673
|
-
|
|
10674
|
-
|
|
10675
|
-
|
|
10676
|
-
|
|
10677
|
-
|
|
10678
|
-
|
|
10679
|
-
|
|
10680
|
-
|
|
10681
|
-
|
|
10682
|
-
|
|
10780
|
+
declare function transcribeAudio(options: TranscribeAudioOptions): Promise<string>;
|
|
10781
|
+
declare function transcribeAudios(audios: AiAudioInput[], config: AiConnectionConfig, model?: string): Promise<string[]>;
|
|
10782
|
+
|
|
10783
|
+
declare function isLikelyNativeAudioChatModel(id: string): boolean;
|
|
10784
|
+
declare function isLikelySttModel(id: string): boolean;
|
|
10785
|
+
declare function filterSttModels(modelIds: string[]): string[];
|
|
10786
|
+
declare function pickDefaultSttModel(modelIds: string[], current?: string): string | undefined;
|
|
10787
|
+
declare function isLikelyVisionModel(id: string): boolean;
|
|
10788
|
+
declare function isKnownTextOnlyModel(id: string): boolean;
|
|
10789
|
+
declare function filterChatModels(modelIds: string[]): string[];
|
|
10790
|
+
declare function filterVisionModels(modelIds: string[]): string[];
|
|
10791
|
+
/** 从可用模型中挑选默认视觉模型 */
|
|
10792
|
+
declare function pickDefaultVisionModel(modelIds: string[], current?: string): string | undefined;
|
|
10793
|
+
|
|
10794
|
+
type VisionMessageFormat = 'openai' | 'ollama';
|
|
10795
|
+
declare function detectVisionMessageFormat(baseUrl: string): VisionMessageFormat;
|
|
10796
|
+
declare function assertVisionCapableModel(modelId: string, options?: {
|
|
10797
|
+
baseUrl?: string;
|
|
10798
|
+
hasImages?: boolean;
|
|
10799
|
+
}): void;
|
|
10800
|
+
declare function isImageUrlVariantError(message: string): boolean;
|
|
10801
|
+
declare function toVisionApiErrorMessage(rawMessage: string, modelId: string): string;
|
|
10802
|
+
|
|
10803
|
+
declare function buildMultimodalMessages(options: {
|
|
10804
|
+
systemPrompt: string;
|
|
10805
|
+
userPrompt: string;
|
|
10806
|
+
images: AiMediaInput[];
|
|
10807
|
+
nativeAudios: AiMediaInput[];
|
|
10808
|
+
format: VisionMessageFormat;
|
|
10809
|
+
}): Array<Record<string, unknown>>;
|
|
10810
|
+
declare function assertMultimodalCapableModel(modelId: string, options: {
|
|
10811
|
+
baseUrl?: string;
|
|
10812
|
+
hasImages?: boolean;
|
|
10813
|
+
hasNativeAudio?: boolean;
|
|
10814
|
+
}): void;
|
|
10815
|
+
|
|
10816
|
+
interface ListModelsResult {
|
|
10817
|
+
models: string[];
|
|
10818
|
+
visionModels: string[];
|
|
10819
|
+
suggestedVisionModel?: string;
|
|
10820
|
+
}
|
|
10821
|
+
declare function listOpenAiCompatibleModels(clientSettings?: AiClientSettings, currentVisionModel?: string): Promise<ListModelsResult>;
|
|
10822
|
+
|
|
10823
|
+
declare function registerAiTask<TInput, TOutput>(task: AiTaskDefinition<TInput, TOutput>): void;
|
|
10824
|
+
declare function getAiTask(taskId: string): AiTaskDefinition | undefined;
|
|
10825
|
+
declare function listAiTasks(): string[];
|
|
10826
|
+
declare function clearAiTasksForTest(): void;
|
|
10827
|
+
|
|
10828
|
+
declare function runAiTask<TData = unknown>(taskId: string, input: unknown, ctx?: AiTaskContext): Promise<AiApiResponse<TData>>;
|
|
10829
|
+
|
|
10830
|
+
/** 注册内置通用 AI 任务(幂等) */
|
|
10831
|
+
declare function registerCoreAiTasks(): void;
|
|
10832
|
+
/** 别名:确保 core 任务已注册 */
|
|
10833
|
+
declare const ensureCoreAiTasksRegistered: typeof registerCoreAiTasks;
|
|
10834
|
+
declare function resetCoreAiTasksForTest(): void;
|
|
10835
|
+
|
|
10836
|
+
declare const coreLlmCompletionTask: AiTaskDefinition<TextCompletionInput, TextCompletionOutput>;
|
|
10837
|
+
|
|
10838
|
+
declare const coreStructuredMultimodalTask: AiTaskDefinition<StructuredMultimodalInput, StructuredMultimodalOutput>;
|
|
10839
|
+
|
|
10840
|
+
declare const coreConnectivityTestTask: AiTaskDefinition<Record<string, never>, ConnectivityTestOutput>;
|
|
10841
|
+
|
|
10842
|
+
export { type AiApiErrorBody, type AiApiErrorCode, type AiApiResponse, type AiApiResponseMeta, type AiApiRunRequest, type AiAudioInput, type AiAudioMediaInput, type AiClientSettings, type AiConnectionConfig, type AiConnectionSettings, type AiImageInput, type AiImageMediaInput, type AiMediaInput, type AiMediaKind, type AiModelsListRequest, type AiModelsListResponse, type AiTaskContext, type AiTaskDefinition, type AiTaskRunOptions, Dialog as AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, DialogDescription as AlertDialogDescription, DialogFooter as AlertDialogFooter, DialogHeader as AlertDialogHeader, DialogOverlay as AlertDialogOverlay, DialogPortal as AlertDialogPortal, DialogTitle as AlertDialogTitle, DialogTrigger as AlertDialogTrigger, type AudioStrategy, Avatar, AvatarFallback, AvatarImage, BackButton, BackButtonProps, type BackgroundRemovalOptions, type BackgroundRemovalState, BackgroundRemover, Badge, BadgeProps, Ball, Button, ButtonProps, CORE_CONNECTIVITY_TEST_TASK_ID, CORE_LLM_COMPLETION_TASK_ID, CORE_STRUCTURED_MULTIMODAL_TASK_ID, type CallChatOptions, type CallChatResult, type CallCompletionParams, type CallCompletionResult, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type ChatMessage, type ChatRole, type ChatUsage, CollisionBalls, CollisionBallsConfig, ConfirmModal, ConfirmModalProps, type ConnectivityTestOutput, ConsoleLoggerAdapter, DEFAULT_OPENAI_BASE_URL, DEFAULT_TEXT_MODEL, Dialog, DialogClose, DialogContent, DialogContentProps, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, FilterButtonGroup, FilterButtonGroupProps, FilterOption, GenericOrderManager, GenericOrderManagerProps, Grid, GridColumns, GridGap, GridItem, GridProps, ImageMappingItem, ImageMappingPanel, ImageMappingPanelProps, ImageMappingValue, Input, type JsonRequestOptions, Label, type ListModelsResult, LocalImageMappingPanel, LocalImageMappingPanelProps, type LogEntry, LogLevel, Logger, type LoggerAdapter, type LoggerConfig, Modal, ModalProps, type MultimodalChatParams, type MultimodalChatResult, type OCROptions, type OCRResult, OCRScanner, type OCRState, OrderManagerOperations, OrderableItem, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Progress, ProgressProps, type ResolvedAudioHandling, ScrollArea, ScrollBar, SearchBox, SearchResultHint, SearchResultHintProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, SentimentAnalyzer, type SentimentOptions, type SentimentResult, type SentimentState, Separator, SeparatorProps, Dialog as Sheet, DialogClose as SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, DialogOverlay as SheetOverlay, DialogPortal as SheetPortal, SheetTitle, DialogTrigger as SheetTrigger, SmartAssistant, type StorageAdapter, type StorageChangeEvent, type StructuredMultimodalInput, type StructuredMultimodalOutput, Tabs, TabsContent, TabsList, TabsTrigger, type TextCompletionInput, type TextCompletionOutput, type TextGenerationOptions, type TextGenerationState, Textarea, Timeline, TimelineConfig, TimelineItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type TranscribeAudioOptions, type VisionMessageFormat, appendTranscriptionsToPrompt, arrayUtils, assertMultimodalCapableModel, assertValidAudioInput, assertValidImageInput, assertValidMultimodalMedia, assertVisionCapableModel, badgeVariants, base64ToBlob, buildMultimodalMessages, buttonVariants, callChat, callCompletion, callMultimodalChat, clearAiTasksForTest, cn, index as common, coreConnectivityTestTask, coreLlmCompletionTask, coreStructuredMultimodalTask, createLogger, debugUtils, detectVisionMessageFormat, ensureCoreAiTasksRegistered, errorUtils, extractJsonObject, fileToAiAudioInput, fileToAiImageInput, fileUtils, filterChatModels, filterSttModels, filterVisionModels, formatTime, getAiTask, isAudioInputError, isImageUrlVariantError, isKnownTextOnlyModel, isLikelyNativeAudioChatModel, isLikelySttModel, isLikelyVisionModel, japaneseUtils, listAiTasks, listOpenAiCompatibleModels, logger, mimeToAudioFormat, pickDefaultSttModel, pickDefaultVisionModel, registerAiTask, registerCoreAiTasks, requestJson, requireAiConnectionConfig, resetCoreAiTasksForTest, resolveAiConnectionConfig, resolveAudioHandling, runAiTask, splitMediaByKind, stringUtils, toVisionApiErrorMessage, transcribeAudio, transcribeAudios, useAsyncStorage, useBackgroundRemoval, useElectronStorage, useLocalStorage, useOCR, useSentimentAnalysis, useStorage, useTaroStorage, useTextGeneration, validators };
|