@opencode/ai 2.1.3 → 2.2.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/README.md +283 -114
- package/dist/ai-client.d.ts +2 -2
- package/dist/ai-client.js +2 -1
- package/dist/cache-policy.d.ts +4 -0
- package/dist/cache-policy.js +20 -6
- package/dist/decision-client.d.ts +21 -0
- package/dist/decision-client.js +55 -0
- package/dist/decision.d.ts +472 -0
- package/dist/decision.js +158 -0
- package/dist/effect.d.ts +38 -0
- package/dist/effect.js +27 -0
- package/dist/effort-updates.d.ts +2 -2
- package/dist/experimental/cloudflare-run-extraction.d.ts +13 -0
- package/dist/experimental/cloudflare-run-extraction.js +83 -0
- package/dist/experimental/extraction.d.ts +183 -0
- package/dist/experimental/extraction.js +102 -0
- package/dist/experimental/realtime.d.ts +7 -2
- package/dist/experimental/realtime.js +5 -5
- package/dist/experimental.d.ts +2 -3
- package/dist/experimental.js +1 -2
- package/dist/image-client.d.ts +13 -22
- package/dist/image-client.js +0 -1
- package/dist/image.d.ts +154 -324
- package/dist/image.js +4 -11
- package/dist/index.d.ts +1426 -34
- package/dist/index.js +127 -24
- package/dist/llm.d.ts +16 -1
- package/dist/llm.js +34 -0
- package/dist/media-client.d.ts +2 -1
- package/dist/media-model.d.ts +3 -0
- package/dist/media-model.js +4 -1
- package/dist/media.d.ts +0 -7
- package/dist/media.js +0 -6
- package/dist/protocols/alibaba-chat.d.ts +32 -12
- package/dist/protocols/alibaba-images.d.ts +22 -0
- package/dist/protocols/alibaba-images.js +77 -0
- package/dist/protocols/alibaba-messages.d.ts +62 -27
- package/dist/protocols/alibaba-responses.d.ts +41 -38
- package/dist/protocols/anthropic-messages.d.ts +196 -94
- package/dist/protocols/anthropic-messages.js +47 -16
- package/dist/protocols/bedrock-converse.d.ts +140 -47
- package/dist/protocols/bedrock-converse.js +114 -18
- package/dist/protocols/bedrock-event-stream.js +1 -0
- package/dist/protocols/bfl-images.d.ts +9 -0
- package/dist/protocols/bfl-images.js +17 -15
- package/dist/protocols/cartesia-speech.d.ts +32 -50
- package/dist/protocols/cloudflare-run-decisions.d.ts +9 -0
- package/dist/protocols/cloudflare-run-decisions.js +36 -0
- package/dist/protocols/cloudflare-workers-ai-images.d.ts +23 -0
- package/dist/protocols/cloudflare-workers-ai-images.js +80 -0
- package/dist/protocols/cohere-chat.d.ts +7 -8
- package/dist/protocols/deepgram-speech.d.ts +32 -50
- package/dist/protocols/elevenlabs-speech.d.ts +32 -50
- package/dist/protocols/fal-images.d.ts +10 -1
- package/dist/protocols/fal-images.js +16 -25
- package/dist/protocols/fal-video.js +1 -1
- package/dist/protocols/gemini.d.ts +37 -34
- package/dist/protocols/gemini.js +13 -8
- package/dist/protocols/google-images.d.ts +2 -2
- package/dist/protocols/google-images.js +8 -37
- package/dist/protocols/google-interactions.d.ts +18 -14
- package/dist/protocols/google-interactions.js +14 -7
- package/dist/protocols/google-speech.d.ts +32 -50
- package/dist/protocols/google-speech.js +0 -1
- package/dist/protocols/google-transcription.d.ts +32 -50
- package/dist/protocols/google-transcription.js +0 -1
- package/dist/protocols/google-video.d.ts +1 -1
- package/dist/protocols/google-video.js +2 -7
- package/dist/protocols/index.d.ts +3 -0
- package/dist/protocols/index.js +3 -0
- package/dist/protocols/meta-images.d.ts +7 -1
- package/dist/protocols/meta-images.js +10 -8
- package/dist/protocols/meta-messages.d.ts +73 -38
- package/dist/protocols/meta-messages.js +14 -1
- package/dist/protocols/meta-responses.d.ts +84 -78
- package/dist/protocols/meta-responses.js +29 -1
- package/dist/protocols/mistral-chat.d.ts +81 -78
- package/dist/protocols/mistral-chat.js +2 -1
- package/dist/protocols/open-responses-channel.js +47 -46
- package/dist/protocols/open-responses-continuation.d.ts +8 -2
- package/dist/protocols/open-responses-continuation.js +3 -1
- package/dist/protocols/open-responses.d.ts +426 -396
- package/dist/protocols/open-responses.js +16 -25
- package/dist/protocols/openai-chat.d.ts +764 -52
- package/dist/protocols/openai-chat.js +38 -25
- package/dist/protocols/openai-compatible-chat.d.ts +35 -15
- package/dist/protocols/openai-compatible-responses.d.ts +44 -42
- package/dist/protocols/openai-decisions.d.ts +22 -0
- package/dist/protocols/openai-decisions.js +128 -0
- package/dist/protocols/openai-images.d.ts +53 -56
- package/dist/protocols/openai-images.js +100 -34
- package/dist/protocols/openai-responses.d.ts +322 -264
- package/dist/protocols/openai-responses.js +33 -3
- package/dist/protocols/openai-speech.d.ts +32 -50
- package/dist/protocols/openai-speech.js +15 -5
- package/dist/protocols/openai-transcription.d.ts +32 -50
- package/dist/protocols/openai-transcription.js +15 -11
- package/dist/protocols/replicate-images.js +1 -1
- package/dist/protocols/runway-video.d.ts +1 -1
- package/dist/protocols/runway-video.js +1 -1
- package/dist/protocols/shared.d.ts +9 -1
- package/dist/protocols/shared.js +13 -2
- package/dist/protocols/stability-images.d.ts +5 -0
- package/dist/protocols/stability-images.js +4 -9
- package/dist/protocols/system-one.d.ts +101 -0
- package/dist/protocols/system-one.js +230 -0
- package/dist/protocols/utils/bedrock-cache.d.ts +2 -2
- package/dist/protocols/utils/bedrock-cache.js +7 -6
- package/dist/protocols/utils/cache.d.ts +14 -3
- package/dist/protocols/utils/cache.js +11 -4
- package/dist/protocols/utils/gemini-generate-content.d.ts +3 -3
- package/dist/protocols/utils/gemini-generate-content.js +10 -16
- package/dist/protocols/utils/gemini-json-schema.d.ts +5 -0
- package/dist/protocols/utils/gemini-json-schema.js +3 -3
- package/dist/protocols/utils/image-sizing.d.ts +31 -0
- package/dist/protocols/utils/image-sizing.js +73 -0
- package/dist/protocols/utils/media-input.d.ts +4 -5
- package/dist/protocols/utils/media-input.js +8 -5
- package/dist/protocols/utils/partial-json-options.d.ts +0 -1
- package/dist/protocols/utils/partial-json-options.js +0 -1
- package/dist/protocols/utils/speech-stream.d.ts +0 -1
- package/dist/protocols/utils/speech-stream.js +0 -1
- package/dist/protocols/utils/tool-schema.js +15 -5
- package/dist/protocols/utils/tool-stream.d.ts +10 -1
- package/dist/protocols/venice-chat.d.ts +71 -53
- package/dist/protocols/venice-chat.js +7 -6
- package/dist/protocols/xai-images.d.ts +1 -2
- package/dist/protocols/xai-images.js +9 -2
- package/dist/protocols/xai-responses.d.ts +88 -78
- package/dist/protocols/xai-responses.js +28 -2
- package/dist/protocols/xai-video.d.ts +1 -1
- package/dist/protocols/xai-video.js +11 -8
- package/dist/protocols/zai-chat.d.ts +54 -30
- package/dist/protocols/zai-chat.js +8 -3
- package/dist/protocols/zai-images.d.ts +3 -1
- package/dist/protocols/zai-images.js +12 -11
- package/dist/protocols/zai-messages.d.ts +72 -35
- package/dist/protocols/zai-messages.js +3 -2
- package/dist/provider-error.js +24 -7
- package/dist/providers/alibaba/images.d.ts +2 -0
- package/dist/providers/alibaba/images.js +1 -0
- package/dist/providers/alibaba.d.ts +146 -85
- package/dist/providers/alibaba.js +16 -8
- package/dist/providers/amazon-bedrock-mantle.d.ts +277 -218
- package/dist/providers/amazon-bedrock.d.ts +48 -28
- package/dist/providers/amazon-bedrock.js +11 -11
- package/dist/providers/anthropic-compatible.d.ts +64 -29
- package/dist/providers/anthropic.d.ts +64 -29
- package/dist/providers/azure/images.d.ts +2 -0
- package/dist/providers/azure/images.js +1 -0
- package/dist/providers/azure.d.ts +156 -115
- package/dist/providers/azure.js +19 -1
- package/dist/providers/baseten/decisions.d.ts +2 -0
- package/dist/providers/baseten/decisions.js +1 -0
- package/dist/providers/baseten.d.ts +75 -25
- package/dist/providers/baseten.js +41 -8
- package/dist/providers/cerebras.d.ts +66 -24
- package/dist/providers/cloudflare-ai-gateway/decisions.d.ts +2 -0
- package/dist/providers/cloudflare-ai-gateway/decisions.js +1 -0
- package/dist/providers/cloudflare-ai-gateway.d.ts +409 -272
- package/dist/providers/cloudflare-ai-gateway.js +33 -6
- package/dist/providers/cloudflare-workers-ai/decisions.d.ts +2 -0
- package/dist/providers/cloudflare-workers-ai/decisions.js +1 -0
- package/dist/providers/cloudflare-workers-ai/images.d.ts +2 -0
- package/dist/providers/cloudflare-workers-ai/images.js +1 -0
- package/dist/providers/cloudflare-workers-ai.d.ts +79 -25
- package/dist/providers/cloudflare-workers-ai.js +45 -9
- package/dist/providers/cohere.d.ts +117 -75
- package/dist/providers/deepinfra.d.ts +66 -24
- package/dist/providers/deepseek.d.ts +66 -24
- package/dist/providers/digitalocean/decisions.d.ts +2 -0
- package/dist/providers/digitalocean/decisions.js +1 -0
- package/dist/providers/digitalocean/images.d.ts +2 -0
- package/dist/providers/digitalocean/images.js +1 -0
- package/dist/providers/digitalocean.d.ts +108 -37
- package/dist/providers/digitalocean.js +39 -8
- package/dist/providers/fireworks.d.ts +66 -24
- package/dist/providers/google/images.d.ts +2 -0
- package/dist/providers/google/images.js +1 -0
- package/dist/providers/google-vertex/images.d.ts +2 -0
- package/dist/providers/google-vertex/images.js +1 -0
- package/dist/providers/google-vertex-chat.d.ts +33 -12
- package/dist/providers/google-vertex-messages.d.ts +64 -29
- package/dist/providers/google-vertex-mistral.d.ts +17 -17
- package/dist/providers/google-vertex-responses.d.ts +38 -35
- package/dist/providers/google-vertex.d.ts +20 -18
- package/dist/providers/google-vertex.js +32 -15
- package/dist/providers/google.d.ts +22 -21
- package/dist/providers/google.js +15 -8
- package/dist/providers/groq.d.ts +66 -28
- package/dist/providers/groq.js +0 -6
- package/dist/providers/meta.d.ts +144 -85
- package/dist/providers/minimax.d.ts +145 -86
- package/dist/providers/mistral.d.ts +28 -28
- package/dist/providers/moonshot.d.ts +277 -218
- package/dist/providers/open-responses-options.d.ts +0 -1
- package/dist/providers/open-responses-options.js +1 -1
- package/dist/providers/openai/images.d.ts +2 -0
- package/dist/providers/openai/images.js +1 -0
- package/dist/providers/openai-compatible/images.d.ts +2 -0
- package/dist/providers/openai-compatible/images.js +1 -0
- package/dist/providers/openai-compatible-responses.d.ts +38 -35
- package/dist/providers/openai-compatible.d.ts +36 -13
- package/dist/providers/openai-compatible.js +22 -10
- package/dist/providers/openai-options.d.ts +3 -2
- package/dist/providers/openai-options.js +0 -1
- package/dist/providers/openai.d.ts +146 -109
- package/dist/providers/openai.js +20 -4
- package/dist/providers/opencode/decisions.d.ts +2 -0
- package/dist/providers/opencode/decisions.js +1 -0
- package/dist/providers/opencode.d.ts +9 -10
- package/dist/providers/opencode.js +10 -8
- package/dist/providers/openrouter/decisions.d.ts +2 -0
- package/dist/providers/openrouter/decisions.js +1 -0
- package/dist/providers/openrouter/images.d.ts +2 -0
- package/dist/providers/openrouter/images.js +1 -0
- package/dist/providers/openrouter.d.ts +128 -47
- package/dist/providers/openrouter.js +38 -16
- package/dist/providers/togetherai.d.ts +66 -24
- package/dist/providers/typesafe-ai/decisions.d.ts +2 -0
- package/dist/providers/typesafe-ai/decisions.js +1 -0
- package/dist/providers/typesafe-ai.d.ts +9 -10
- package/dist/providers/typesafe-ai.js +10 -8
- package/dist/providers/venice.d.ts +214 -20
- package/dist/providers/vercel-ai-gateway/decisions.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/decisions.js +1 -0
- package/dist/providers/vercel-ai-gateway/images.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/images.js +1 -0
- package/dist/providers/vercel-ai-gateway.d.ts +10 -16
- package/dist/providers/vercel-ai-gateway.js +31 -85
- package/dist/providers/xai/images.d.ts +2 -0
- package/dist/providers/xai/images.js +1 -0
- package/dist/providers/xai.d.ts +40 -17
- package/dist/providers/xai.js +15 -8
- package/dist/providers/zai/images.d.ts +2 -0
- package/dist/providers/zai/images.js +1 -0
- package/dist/providers/zai-coding-plan.d.ts +224 -85
- package/dist/providers/zai.d.ts +110 -23
- package/dist/providers/zai.js +15 -8
- package/dist/route/auth-options.d.ts +0 -3
- package/dist/route/auth.d.ts +0 -2
- package/dist/route/auth.js +0 -2
- package/dist/route/client.d.ts +2 -4
- package/dist/route/client.js +29 -8
- package/dist/route/decision.d.ts +58 -0
- package/dist/route/decision.js +75 -0
- package/dist/route/executor-service.js +1 -1
- package/dist/route/executor.d.ts +1 -1
- package/dist/route/framing.d.ts +2 -0
- package/dist/route/index.d.ts +3 -0
- package/dist/route/index.js +3 -0
- package/dist/route/media-protocol.d.ts +1 -0
- package/dist/route/media-protocol.js +12 -8
- package/dist/route/media.d.ts +5 -1
- package/dist/route/media.js +6 -2
- package/dist/route/transport/http.js +1 -0
- package/dist/route/transport/index.d.ts +1 -0
- package/dist/schema/events.d.ts +148 -6
- package/dist/schema/events.js +20 -0
- package/dist/schema/messages.d.ts +6 -2
- package/dist/schema/messages.js +3 -0
- package/dist/schema/options.d.ts +5 -3
- package/dist/schema/options.js +8 -3
- package/dist/speech-client.d.ts +13 -22
- package/dist/speech-client.js +0 -1
- package/dist/speech.d.ts +148 -283
- package/dist/speech.js +2 -4
- package/dist/testing.d.ts +25 -24
- package/dist/testing.js +3 -21
- package/dist/transcription-client.d.ts +13 -22
- package/dist/transcription.d.ts +148 -283
- package/dist/transcription.js +1 -1
- package/dist/utils/media-type.js +22 -1
- package/dist/video-client.d.ts +13 -22
- package/dist/video-client.js +0 -1
- package/dist/video.d.ts +115 -250
- package/dist/video.js +3 -5
- package/package.json +516 -13
- package/dist/experimental/evaluation-client.d.ts +0 -21
- package/dist/experimental/evaluation-client.js +0 -64
- package/dist/experimental/evaluation.d.ts +0 -242
- package/dist/experimental/evaluation.js +0 -115
- package/dist/experimental/system-one.d.ts +0 -16
- package/dist/experimental/system-one.js +0 -135
- package/dist/promise.d.ts +0 -1021
- package/dist/promise.js +0 -101
- package/dist/provider.d.ts +0 -23
- package/dist/provider.js +0 -2
package/dist/provider-error.js
CHANGED
|
@@ -4,7 +4,9 @@ import { Json } from "./utils/json.js";
|
|
|
4
4
|
import { isRecord } from "./utils/record.js";
|
|
5
5
|
const patterns = [
|
|
6
6
|
/prompt is too long/i,
|
|
7
|
-
/input is too long for requested model/i,
|
|
7
|
+
/input is too long for (?:the )?(?:requested|selected) model/i,
|
|
8
|
+
// OpenCode Go
|
|
9
|
+
/too large for the model'?s configured input limit/i,
|
|
8
10
|
// Cloudflare Workers AI reports this as HTTP 413.
|
|
9
11
|
/exceeded this model context window limit/i,
|
|
10
12
|
/exceeds the context window/i,
|
|
@@ -31,8 +33,8 @@ const patterns = [
|
|
|
31
33
|
/context[_ ]length[_ ]exceeded/i,
|
|
32
34
|
/context length is only \d+ tokens/i,
|
|
33
35
|
/input length.*exceeds.*context length/i,
|
|
34
|
-
// Z.ai code 1261 arrives as `Prompt too long` or `Prompt 超长`.
|
|
35
|
-
/prompt (?:too long|超长)/i,
|
|
36
|
+
// Z.ai code 1261 arrives as `Prompt too long`, `Prompt exceeds max length` or `Prompt 超长`.
|
|
37
|
+
/prompt (?:too long|exceeds max length|超长)/i,
|
|
36
38
|
/too large for model with \d+ maximum context length/i,
|
|
37
39
|
/prompt has [\d,]+ tokens?, but the configured context size is [\d,]+ tokens?/i,
|
|
38
40
|
/model_context_window_exceeded/i,
|
|
@@ -48,6 +50,8 @@ const exclusions = [
|
|
|
48
50
|
/too many requests/i,
|
|
49
51
|
// Cohere reports an output limit above the model maximum as "too many tokens"; compaction cannot fix it.
|
|
50
52
|
/max[_ ]tokens must be less than/i,
|
|
53
|
+
// Bedrock phrases throttling as "Too many tokens[, per day], please wait..."; it is a 429 to retry, not overflow.
|
|
54
|
+
/too many tokens(?: per day)?, please wait/i,
|
|
51
55
|
];
|
|
52
56
|
export const isContextOverflow = (message) => !exclusions.some((pattern) => pattern.test(message)) &&
|
|
53
57
|
(patterns.some((pattern) => pattern.test(message)) || /^4(?:00|13)\s*(status code)?\s*\(no body\)/i.test(message));
|
|
@@ -102,6 +106,7 @@ const QUOTA_CODES = new Set([
|
|
|
102
106
|
"usage_not_included",
|
|
103
107
|
"billing_error",
|
|
104
108
|
"gousagelimiterror",
|
|
109
|
+
"budgetlimiterror",
|
|
105
110
|
"freeusagelimiterror",
|
|
106
111
|
"creditlimitexceeded",
|
|
107
112
|
]);
|
|
@@ -129,7 +134,8 @@ const INVALID_REQUEST_CODES = new Set([
|
|
|
129
134
|
]);
|
|
130
135
|
// Azure OpenAI reports `content_filter` with `innererror.code` ResponsibleAIPolicyViolation.
|
|
131
136
|
// OpenRouter tags provider failures with a typed `error_type`; its Responses skin also
|
|
132
|
-
// emits `image_content_policy_violation` as the native code.
|
|
137
|
+
// emits `image_content_policy_violation` as the native code. Alibaba Model Studio reports
|
|
138
|
+
// moderation rejections as `DataInspectionFailed`. OpenAI Images reports `moderation_blocked`.
|
|
133
139
|
const CONTENT_POLICY_CODES = new Set([
|
|
134
140
|
"content_filter",
|
|
135
141
|
"content_moderation",
|
|
@@ -137,6 +143,8 @@ const CONTENT_POLICY_CODES = new Set([
|
|
|
137
143
|
"content_policy_violation",
|
|
138
144
|
"image_content_policy_violation",
|
|
139
145
|
"refusal",
|
|
146
|
+
"datainspectionfailed",
|
|
147
|
+
"moderation_blocked",
|
|
140
148
|
]);
|
|
141
149
|
// OpenCode Zen replaces upstream codes outside its allow-list but keeps the original
|
|
142
150
|
// as a `[code]` label at the start of the rewritten message.
|
|
@@ -150,8 +158,8 @@ const QUOTA_TEXT = /insufficient[-_\s]?(?:quota|balance)|quota[-_\s]?exceeded|bu
|
|
|
150
158
|
// Policy rejections without a dedicated code, matched against the provider's own
|
|
151
159
|
// explanation only. OpenAI reuses `invalid_prompt` for usage-policy rejections while
|
|
152
160
|
// Bedrock Mantle reuses it for schema validation; Anthropic reports blocked output
|
|
153
|
-
// under `invalid_request_error`.
|
|
154
|
-
const CONTENT_POLICY_TEXT = /violating our usage policy|blocked by content filtering policy|content[-_\s]?policy|rejected as a result of our safety system|detected potentially unsafe or sensitive content/i;
|
|
161
|
+
// under `invalid_request_error`. The Vercel AI Gateway drops OpenAI's `moderation_blocked` code.
|
|
162
|
+
const CONTENT_POLICY_TEXT = /violating our usage policy|blocked by content filtering policy|content[-_\s]?policy|rejected (?:as a result of our|by the) safety system|detected potentially unsafe or sensitive content/i;
|
|
155
163
|
const SERVER_ERROR_TEXT = /\b(?:try again|(?:please |you can )?retry (?:the |this |your )?request|try (?:the |this |your )?request again|(?:currently |temporarily )?at capacity|overloaded|temporarily unavailable|service[-_\s]?unavailable|(?:server|internal)[-_\s]?error|server (?:is )?busy|provider returned (?:an )?error|resource[-_\s]?exhausted|upstream (?:connect|connection|request)|request buffer limit while retrying upstream)\b/i;
|
|
156
164
|
const Message = Schema.String.check(Schema.isPattern(/\S/));
|
|
157
165
|
const messageAt = (fields, message) => Schema.Struct(fields).pipe(Schema.decodeTo(Schema.String, {
|
|
@@ -185,6 +193,7 @@ export function classifyProviderFailure(input) {
|
|
|
185
193
|
...providerCodes(body),
|
|
186
194
|
...providerCodes(input.message),
|
|
187
195
|
...(GATEWAY_CODE_LABEL.exec(input.message)?.slice(1) ?? []),
|
|
196
|
+
...awsErrorType(input.http?.headers["x-amzn-errortype"]),
|
|
188
197
|
].map((code) => code.toLowerCase());
|
|
189
198
|
// Scan the raw payload too so signals missing from the summary message
|
|
190
199
|
// (e.g. overflow phrases nested in a JSON error body) still classify.
|
|
@@ -194,7 +203,7 @@ export function classifyProviderFailure(input) {
|
|
|
194
203
|
(codes.includes("context_length_exceeded") ||
|
|
195
204
|
codes.includes("model_context_window_exceeded") ||
|
|
196
205
|
codes.includes("request_too_large") ||
|
|
197
|
-
isContextOverflow(text)))
|
|
206
|
+
(!codes.includes("throttlingexception") && isContextOverflow(text))))
|
|
198
207
|
return new InvalidRequestError({ ...details, classification: "context-overflow" });
|
|
199
208
|
if (input.status === 413 || isPayloadTooLarge(text))
|
|
200
209
|
return new InvalidRequestError({ ...details, classification: "payload-too-large" });
|
|
@@ -249,6 +258,8 @@ function providerCodes(value) {
|
|
|
249
258
|
const exception = isRecord(decoded.exception) ? decoded.exception : undefined;
|
|
250
259
|
return [
|
|
251
260
|
decoded.code,
|
|
261
|
+
...awsErrorType(decoded.__type),
|
|
262
|
+
...awsErrorType(decoded.code),
|
|
252
263
|
// Stability's `{ id, name, errors }` bodies carry the code in `name`.
|
|
253
264
|
Array.isArray(decoded.errors) ? decoded.name : undefined,
|
|
254
265
|
decoded.error_type,
|
|
@@ -267,3 +278,9 @@ function providerCodes(value) {
|
|
|
267
278
|
exception?.type,
|
|
268
279
|
].filter((value) => typeof value === "string");
|
|
269
280
|
}
|
|
281
|
+
// AWS restJson1 reports the modeled error in `X-Amzn-Errortype`, `__type` or `code`, possibly
|
|
282
|
+
// namespaced (`ns#Name`) or suffixed (`Name:uri`). Keep the shape name only.
|
|
283
|
+
// https://smithy.io/2.0/aws/protocols/aws-restjson1-protocol.html#operation-error-serialization
|
|
284
|
+
function awsErrorType(value) {
|
|
285
|
+
return typeof value === "string" ? [value.replace(/:.*/s, "").replace(/^[^#]*#/, "")] : [];
|
|
286
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { imageModel as model } from "../alibaba.js";
|
|
@@ -4,12 +4,13 @@ import { AlibabaMessages } from "../protocols/alibaba-messages.js";
|
|
|
4
4
|
import { AlibabaResponses } from "../protocols/alibaba-responses.js";
|
|
5
5
|
import { type AtLeastOne, type ProviderAuthOption } from "../route/auth-options.js";
|
|
6
6
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
7
|
-
import { ToolDefinition, type ModelID } from "../schema/index.js";
|
|
7
|
+
import { ToolDefinition, type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
8
8
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
9
9
|
export type Region = "ap-southeast-1" | "cn-beijing" | "cn-hongkong" | "us-east-1" | "eu-central-1" | "ap-northeast-1" | (string & {});
|
|
10
10
|
export type ChatOptionsInput = AlibabaChat.OptionsInput;
|
|
11
11
|
export type MessagesOptionsInput = AlibabaMessages.OptionsInput;
|
|
12
12
|
export type ResponsesOptionsInput = AlibabaResponses.OptionsInput;
|
|
13
|
+
export type { AlibabaImageOptions } from "../protocols/alibaba-images.js";
|
|
13
14
|
type Location = AtLeastOne<{
|
|
14
15
|
readonly region: Region;
|
|
15
16
|
/** Overrides the selected API's complete base URL, including its version prefix. */
|
|
@@ -28,44 +29,54 @@ export declare const routes: (Route<{
|
|
|
28
29
|
readonly messages: readonly ({
|
|
29
30
|
readonly role: "system";
|
|
30
31
|
readonly content: string | readonly ({
|
|
31
|
-
readonly type: "text";
|
|
32
|
-
readonly text: string;
|
|
33
|
-
readonly cache_control?: {
|
|
34
|
-
readonly type: "ephemeral";
|
|
35
|
-
readonly ttl?: string | undefined;
|
|
36
|
-
} | undefined;
|
|
37
|
-
} | {
|
|
38
32
|
readonly type: "image_url";
|
|
39
33
|
readonly image_url: {
|
|
40
34
|
readonly url: string;
|
|
41
35
|
};
|
|
36
|
+
} | {
|
|
37
|
+
readonly type: "video_url";
|
|
38
|
+
readonly video_url: {
|
|
39
|
+
readonly url: string;
|
|
40
|
+
};
|
|
42
41
|
} | {
|
|
43
42
|
readonly type: "file";
|
|
44
43
|
readonly file: {
|
|
45
44
|
readonly filename: string;
|
|
46
45
|
readonly file_data: string;
|
|
47
46
|
};
|
|
48
|
-
}
|
|
49
|
-
} | {
|
|
50
|
-
readonly role: "user";
|
|
51
|
-
readonly content: string | readonly ({
|
|
47
|
+
} | {
|
|
52
48
|
readonly type: "text";
|
|
53
49
|
readonly text: string;
|
|
54
50
|
readonly cache_control?: {
|
|
55
51
|
readonly type: "ephemeral";
|
|
56
52
|
readonly ttl?: string | undefined;
|
|
57
53
|
} | undefined;
|
|
58
|
-
}
|
|
54
|
+
})[];
|
|
55
|
+
} | {
|
|
56
|
+
readonly role: "user";
|
|
57
|
+
readonly content: string | readonly ({
|
|
59
58
|
readonly type: "image_url";
|
|
60
59
|
readonly image_url: {
|
|
61
60
|
readonly url: string;
|
|
62
61
|
};
|
|
62
|
+
} | {
|
|
63
|
+
readonly type: "video_url";
|
|
64
|
+
readonly video_url: {
|
|
65
|
+
readonly url: string;
|
|
66
|
+
};
|
|
63
67
|
} | {
|
|
64
68
|
readonly type: "file";
|
|
65
69
|
readonly file: {
|
|
66
70
|
readonly filename: string;
|
|
67
71
|
readonly file_data: string;
|
|
68
72
|
};
|
|
73
|
+
} | {
|
|
74
|
+
readonly type: "text";
|
|
75
|
+
readonly text: string;
|
|
76
|
+
readonly cache_control?: {
|
|
77
|
+
readonly type: "ephemeral";
|
|
78
|
+
readonly ttl?: string | undefined;
|
|
79
|
+
} | undefined;
|
|
69
80
|
})[];
|
|
70
81
|
} | {
|
|
71
82
|
readonly role: "tool";
|
|
@@ -134,7 +145,17 @@ export declare const routes: (Route<{
|
|
|
134
145
|
} | undefined;
|
|
135
146
|
readonly store?: boolean | undefined;
|
|
136
147
|
readonly prompt_cache_key?: string | undefined;
|
|
148
|
+
readonly prompt_cache_retention?: string | undefined;
|
|
149
|
+
readonly prompt_cache_options?: {
|
|
150
|
+
readonly ttl?: string | undefined;
|
|
151
|
+
} | undefined;
|
|
137
152
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
153
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
154
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
155
|
+
readonly metadata?: {
|
|
156
|
+
readonly [x: string]: string;
|
|
157
|
+
} | undefined;
|
|
158
|
+
readonly safety_identifier?: string | undefined;
|
|
138
159
|
readonly tool_stream?: boolean | undefined;
|
|
139
160
|
readonly max_completion_tokens?: number | undefined;
|
|
140
161
|
readonly max_tokens?: number | undefined;
|
|
@@ -184,7 +205,7 @@ export declare const routes: (Route<{
|
|
|
184
205
|
readonly text: string;
|
|
185
206
|
readonly cache_control?: {
|
|
186
207
|
readonly type: "ephemeral";
|
|
187
|
-
readonly ttl?:
|
|
208
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
188
209
|
} | undefined;
|
|
189
210
|
}[] | undefined;
|
|
190
211
|
readonly messages: readonly ({
|
|
@@ -194,7 +215,7 @@ export declare const routes: (Route<{
|
|
|
194
215
|
readonly text: string;
|
|
195
216
|
readonly cache_control?: {
|
|
196
217
|
readonly type: "ephemeral";
|
|
197
|
-
readonly ttl?:
|
|
218
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
198
219
|
} | undefined;
|
|
199
220
|
} | {
|
|
200
221
|
readonly type: "image";
|
|
@@ -211,11 +232,28 @@ export declare const routes: (Route<{
|
|
|
211
232
|
};
|
|
212
233
|
readonly cache_control?: {
|
|
213
234
|
readonly type: "ephemeral";
|
|
214
|
-
readonly ttl?:
|
|
235
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
215
236
|
} | undefined;
|
|
216
237
|
readonly transformations?: {
|
|
217
238
|
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
218
239
|
} | undefined;
|
|
240
|
+
} | {
|
|
241
|
+
readonly type: "video";
|
|
242
|
+
readonly source: {
|
|
243
|
+
readonly type: "base64";
|
|
244
|
+
readonly media_type: string;
|
|
245
|
+
readonly data: string;
|
|
246
|
+
} | {
|
|
247
|
+
readonly type: "url";
|
|
248
|
+
readonly url: string;
|
|
249
|
+
} | {
|
|
250
|
+
readonly type: "file";
|
|
251
|
+
readonly file_id: string;
|
|
252
|
+
};
|
|
253
|
+
readonly cache_control?: {
|
|
254
|
+
readonly type: "ephemeral";
|
|
255
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
256
|
+
} | undefined;
|
|
219
257
|
} | {
|
|
220
258
|
readonly type: "document";
|
|
221
259
|
readonly source: {
|
|
@@ -235,7 +273,7 @@ export declare const routes: (Route<{
|
|
|
235
273
|
};
|
|
236
274
|
readonly cache_control?: {
|
|
237
275
|
readonly type: "ephemeral";
|
|
238
|
-
readonly ttl?:
|
|
276
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
239
277
|
} | undefined;
|
|
240
278
|
readonly title?: string | undefined;
|
|
241
279
|
readonly context?: string | undefined;
|
|
@@ -250,7 +288,7 @@ export declare const routes: (Route<{
|
|
|
250
288
|
readonly text: string;
|
|
251
289
|
readonly cache_control?: {
|
|
252
290
|
readonly type: "ephemeral";
|
|
253
|
-
readonly ttl?:
|
|
291
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
254
292
|
} | undefined;
|
|
255
293
|
} | {
|
|
256
294
|
readonly type: "image";
|
|
@@ -267,11 +305,28 @@ export declare const routes: (Route<{
|
|
|
267
305
|
};
|
|
268
306
|
readonly cache_control?: {
|
|
269
307
|
readonly type: "ephemeral";
|
|
270
|
-
readonly ttl?:
|
|
308
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
271
309
|
} | undefined;
|
|
272
310
|
readonly transformations?: {
|
|
273
311
|
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
274
312
|
} | undefined;
|
|
313
|
+
} | {
|
|
314
|
+
readonly type: "video";
|
|
315
|
+
readonly source: {
|
|
316
|
+
readonly type: "base64";
|
|
317
|
+
readonly media_type: string;
|
|
318
|
+
readonly data: string;
|
|
319
|
+
} | {
|
|
320
|
+
readonly type: "url";
|
|
321
|
+
readonly url: string;
|
|
322
|
+
} | {
|
|
323
|
+
readonly type: "file";
|
|
324
|
+
readonly file_id: string;
|
|
325
|
+
};
|
|
326
|
+
readonly cache_control?: {
|
|
327
|
+
readonly type: "ephemeral";
|
|
328
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
329
|
+
} | undefined;
|
|
275
330
|
} | {
|
|
276
331
|
readonly type: "document";
|
|
277
332
|
readonly source: {
|
|
@@ -291,7 +346,7 @@ export declare const routes: (Route<{
|
|
|
291
346
|
};
|
|
292
347
|
readonly cache_control?: {
|
|
293
348
|
readonly type: "ephemeral";
|
|
294
|
-
readonly ttl?:
|
|
349
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
295
350
|
} | undefined;
|
|
296
351
|
readonly title?: string | undefined;
|
|
297
352
|
readonly context?: string | undefined;
|
|
@@ -302,17 +357,35 @@ export declare const routes: (Route<{
|
|
|
302
357
|
readonly is_error?: boolean | undefined;
|
|
303
358
|
readonly cache_control?: {
|
|
304
359
|
readonly type: "ephemeral";
|
|
305
|
-
readonly ttl?:
|
|
360
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
306
361
|
} | undefined;
|
|
307
362
|
})[];
|
|
308
363
|
} | {
|
|
309
364
|
readonly role: "assistant";
|
|
310
365
|
readonly content: readonly ({
|
|
366
|
+
readonly type: "compaction";
|
|
367
|
+
readonly content: string | null;
|
|
368
|
+
} | {
|
|
311
369
|
readonly type: "text";
|
|
312
370
|
readonly text: string;
|
|
313
371
|
readonly cache_control?: {
|
|
314
372
|
readonly type: "ephemeral";
|
|
315
|
-
readonly ttl?:
|
|
373
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
374
|
+
} | undefined;
|
|
375
|
+
} | {
|
|
376
|
+
readonly type: "thinking";
|
|
377
|
+
readonly thinking: string;
|
|
378
|
+
readonly signature: string;
|
|
379
|
+
readonly cache_control?: {
|
|
380
|
+
readonly type: "ephemeral";
|
|
381
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
382
|
+
} | undefined;
|
|
383
|
+
} | {
|
|
384
|
+
readonly type: "redacted_thinking";
|
|
385
|
+
readonly data: string;
|
|
386
|
+
readonly cache_control?: {
|
|
387
|
+
readonly type: "ephemeral";
|
|
388
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
316
389
|
} | undefined;
|
|
317
390
|
} | {
|
|
318
391
|
readonly type: "tool_use";
|
|
@@ -321,7 +394,7 @@ export declare const routes: (Route<{
|
|
|
321
394
|
readonly input: unknown;
|
|
322
395
|
readonly cache_control?: {
|
|
323
396
|
readonly type: "ephemeral";
|
|
324
|
-
readonly ttl?:
|
|
397
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
325
398
|
} | undefined;
|
|
326
399
|
} | {
|
|
327
400
|
readonly type: "server_tool_use";
|
|
@@ -330,7 +403,7 @@ export declare const routes: (Route<{
|
|
|
330
403
|
readonly input: unknown;
|
|
331
404
|
readonly cache_control?: {
|
|
332
405
|
readonly type: "ephemeral";
|
|
333
|
-
readonly ttl?:
|
|
406
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
334
407
|
} | undefined;
|
|
335
408
|
} | {
|
|
336
409
|
readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
|
|
@@ -338,25 +411,7 @@ export declare const routes: (Route<{
|
|
|
338
411
|
readonly content: unknown;
|
|
339
412
|
readonly cache_control?: {
|
|
340
413
|
readonly type: "ephemeral";
|
|
341
|
-
readonly ttl?:
|
|
342
|
-
} | undefined;
|
|
343
|
-
} | {
|
|
344
|
-
readonly type: "compaction";
|
|
345
|
-
readonly content: string | null;
|
|
346
|
-
} | {
|
|
347
|
-
readonly type: "thinking";
|
|
348
|
-
readonly thinking: string;
|
|
349
|
-
readonly signature: string;
|
|
350
|
-
readonly cache_control?: {
|
|
351
|
-
readonly type: "ephemeral";
|
|
352
|
-
readonly ttl?: "1h" | "5m" | undefined;
|
|
353
|
-
} | undefined;
|
|
354
|
-
} | {
|
|
355
|
-
readonly type: "redacted_thinking";
|
|
356
|
-
readonly data: string;
|
|
357
|
-
readonly cache_control?: {
|
|
358
|
-
readonly type: "ephemeral";
|
|
359
|
-
readonly ttl?: "1h" | "5m" | undefined;
|
|
414
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
360
415
|
} | undefined;
|
|
361
416
|
})[];
|
|
362
417
|
} | {
|
|
@@ -366,7 +421,7 @@ export declare const routes: (Route<{
|
|
|
366
421
|
readonly text: string;
|
|
367
422
|
readonly cache_control?: {
|
|
368
423
|
readonly type: "ephemeral";
|
|
369
|
-
readonly ttl?:
|
|
424
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
370
425
|
} | undefined;
|
|
371
426
|
}[];
|
|
372
427
|
readonly output_config?: {
|
|
@@ -381,7 +436,7 @@ export declare const routes: (Route<{
|
|
|
381
436
|
};
|
|
382
437
|
readonly cache_control?: {
|
|
383
438
|
readonly type: "ephemeral";
|
|
384
|
-
readonly ttl?:
|
|
439
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
385
440
|
} | undefined;
|
|
386
441
|
}[] | undefined;
|
|
387
442
|
readonly tool_choice?: {
|
|
@@ -409,7 +464,7 @@ export declare const routes: (Route<{
|
|
|
409
464
|
} | undefined;
|
|
410
465
|
readonly cache_control?: {
|
|
411
466
|
readonly type: "ephemeral";
|
|
412
|
-
readonly ttl?:
|
|
467
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
413
468
|
} | undefined;
|
|
414
469
|
readonly container?: string | {
|
|
415
470
|
readonly id?: string | null | undefined;
|
|
@@ -422,6 +477,7 @@ export declare const routes: (Route<{
|
|
|
422
477
|
readonly user_id?: string | null | undefined;
|
|
423
478
|
} | undefined;
|
|
424
479
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
|
|
480
|
+
readonly speed?: import("../schema/options.js").OpenString<"fast" | "standard"> | undefined;
|
|
425
481
|
readonly thinking?: {
|
|
426
482
|
readonly type: string;
|
|
427
483
|
readonly budget_tokens?: number | undefined;
|
|
@@ -429,14 +485,6 @@ export declare const routes: (Route<{
|
|
|
429
485
|
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined> | Route<{
|
|
430
486
|
readonly model: string;
|
|
431
487
|
readonly input: readonly ({
|
|
432
|
-
readonly [x: string]: unknown;
|
|
433
|
-
readonly type: string;
|
|
434
|
-
readonly id: string;
|
|
435
|
-
} | {
|
|
436
|
-
readonly type: "compaction";
|
|
437
|
-
readonly id?: string | null | undefined;
|
|
438
|
-
readonly encrypted_content: string;
|
|
439
|
-
} | {
|
|
440
488
|
readonly type: "configuration_update";
|
|
441
489
|
readonly reasoning: {
|
|
442
490
|
readonly effort: import("../schema/options.js").ReasoningEffort;
|
|
@@ -449,10 +497,48 @@ export declare const routes: (Route<{
|
|
|
449
497
|
readonly type: "message";
|
|
450
498
|
readonly role: "developer";
|
|
451
499
|
readonly content: string;
|
|
500
|
+
} | {
|
|
501
|
+
readonly type: "function_call_output";
|
|
502
|
+
readonly call_id: string;
|
|
503
|
+
readonly output: string | readonly ({
|
|
504
|
+
readonly type: "input_text";
|
|
505
|
+
readonly text: string;
|
|
506
|
+
} | {
|
|
507
|
+
readonly type: "input_video";
|
|
508
|
+
readonly video_url: string;
|
|
509
|
+
} | {
|
|
510
|
+
readonly type: "input_image";
|
|
511
|
+
readonly image_url: string;
|
|
512
|
+
readonly detail?: string | undefined;
|
|
513
|
+
} | {
|
|
514
|
+
readonly type: "input_file";
|
|
515
|
+
readonly filename: string;
|
|
516
|
+
readonly detail?: string | undefined;
|
|
517
|
+
readonly file_data?: string | undefined;
|
|
518
|
+
readonly file_url?: string | undefined;
|
|
519
|
+
})[];
|
|
520
|
+
} | {
|
|
521
|
+
readonly type: "reasoning";
|
|
522
|
+
readonly id?: string | undefined;
|
|
523
|
+
readonly summary: readonly {
|
|
524
|
+
readonly type: "summary_text";
|
|
525
|
+
readonly text: string;
|
|
526
|
+
}[];
|
|
527
|
+
readonly encrypted_content?: string | null | undefined;
|
|
528
|
+
} | {
|
|
529
|
+
readonly type: "compaction";
|
|
530
|
+
readonly id?: string | null | undefined;
|
|
531
|
+
readonly encrypted_content: string;
|
|
452
532
|
} | {
|
|
453
533
|
readonly type: "message";
|
|
454
534
|
readonly role: "user";
|
|
455
535
|
readonly content: readonly ({
|
|
536
|
+
readonly type: "input_text";
|
|
537
|
+
readonly text: string;
|
|
538
|
+
} | {
|
|
539
|
+
readonly type: "input_video";
|
|
540
|
+
readonly video_url: string;
|
|
541
|
+
} | {
|
|
456
542
|
readonly type: "input_image";
|
|
457
543
|
readonly image_url: string;
|
|
458
544
|
readonly detail?: string | undefined;
|
|
@@ -462,9 +548,6 @@ export declare const routes: (Route<{
|
|
|
462
548
|
readonly detail?: string | undefined;
|
|
463
549
|
readonly file_data?: string | undefined;
|
|
464
550
|
readonly file_url?: string | undefined;
|
|
465
|
-
} | {
|
|
466
|
-
readonly type: "input_text";
|
|
467
|
-
readonly text: string;
|
|
468
551
|
})[];
|
|
469
552
|
readonly id?: string | undefined;
|
|
470
553
|
readonly status?: string | undefined;
|
|
@@ -478,14 +561,6 @@ export declare const routes: (Route<{
|
|
|
478
561
|
}[];
|
|
479
562
|
readonly phase?: "commentary" | "final_answer" | null | undefined;
|
|
480
563
|
readonly status?: string | undefined;
|
|
481
|
-
} | {
|
|
482
|
-
readonly type: "reasoning";
|
|
483
|
-
readonly id?: string | undefined;
|
|
484
|
-
readonly summary: readonly {
|
|
485
|
-
readonly type: "summary_text";
|
|
486
|
-
readonly text: string;
|
|
487
|
-
}[];
|
|
488
|
-
readonly encrypted_content?: string | null | undefined;
|
|
489
564
|
} | {
|
|
490
565
|
readonly type: "function_call";
|
|
491
566
|
readonly id?: string | undefined;
|
|
@@ -493,26 +568,6 @@ export declare const routes: (Route<{
|
|
|
493
568
|
readonly name: string;
|
|
494
569
|
readonly namespace?: string | undefined;
|
|
495
570
|
readonly arguments: string;
|
|
496
|
-
} | {
|
|
497
|
-
readonly type: "function_call_output";
|
|
498
|
-
readonly call_id: string;
|
|
499
|
-
readonly output: string | readonly ({
|
|
500
|
-
readonly type: "input_image";
|
|
501
|
-
readonly image_url: string;
|
|
502
|
-
readonly detail?: string | undefined;
|
|
503
|
-
} | {
|
|
504
|
-
readonly type: "input_file";
|
|
505
|
-
readonly filename: string;
|
|
506
|
-
readonly detail?: string | undefined;
|
|
507
|
-
readonly file_data?: string | undefined;
|
|
508
|
-
readonly file_url?: string | undefined;
|
|
509
|
-
} | {
|
|
510
|
-
readonly type: "input_text";
|
|
511
|
-
readonly text: string;
|
|
512
|
-
} | {
|
|
513
|
-
readonly type: "input_video";
|
|
514
|
-
readonly video_url: string;
|
|
515
|
-
})[];
|
|
516
571
|
} | {
|
|
517
572
|
readonly [x: string]: unknown;
|
|
518
573
|
readonly type: "web_search_call";
|
|
@@ -550,6 +605,10 @@ export declare const routes: (Route<{
|
|
|
550
605
|
readonly arguments?: string | undefined;
|
|
551
606
|
readonly output?: string | null | undefined;
|
|
552
607
|
readonly error?: unknown;
|
|
608
|
+
} | {
|
|
609
|
+
readonly [x: string]: unknown;
|
|
610
|
+
readonly type: string;
|
|
611
|
+
readonly id: string;
|
|
553
612
|
})[];
|
|
554
613
|
readonly instructions?: string | undefined;
|
|
555
614
|
readonly tools?: readonly ({
|
|
@@ -667,6 +726,7 @@ export declare const configure: (input: Config) => {
|
|
|
667
726
|
readonly previousResponseId?: string | undefined;
|
|
668
727
|
readonly conversation?: string | undefined;
|
|
669
728
|
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
729
|
+
image: (id: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("./alibaba.js").AlibabaImageOptions>;
|
|
670
730
|
configure: typeof configure;
|
|
671
731
|
};
|
|
672
732
|
export declare const provider: {
|
|
@@ -676,6 +736,7 @@ export declare const provider: {
|
|
|
676
736
|
export declare const model: ProviderPackage.Definition<Settings, ChatOptionsInput>["model"];
|
|
677
737
|
export declare const messagesModel: ProviderPackage.Definition<Settings<MessagesOptionsInput>, MessagesOptionsInput>["model"];
|
|
678
738
|
export declare const responsesModel: ProviderPackage.Definition<Settings<ResponsesOptionsInput>, ResponsesOptionsInput>["model"];
|
|
739
|
+
export declare const imageModel: (id: string, settings: Settings) => import("../image.js").ImageModel<import("./alibaba.js").AlibabaImageOptions>;
|
|
679
740
|
export declare const webSearch: () => ToolDefinition;
|
|
680
741
|
export declare const webExtractor: () => ToolDefinition;
|
|
681
742
|
export declare const codeInterpreter: () => ToolDefinition;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Struct } from "effect";
|
|
2
2
|
import { AlibabaChat } from "../protocols/alibaba-chat.js";
|
|
3
|
+
import { AlibabaImages } from "../protocols/alibaba-images.js";
|
|
3
4
|
import { AlibabaMessages } from "../protocols/alibaba-messages.js";
|
|
4
5
|
import { AlibabaResponses } from "../protocols/alibaba-responses.js";
|
|
5
6
|
import { AuthOptions } from "../route/auth-options.js";
|
|
6
7
|
import { Route } from "../route/client.js";
|
|
7
8
|
import { Endpoint } from "../route/endpoint.js";
|
|
8
9
|
import { Framing } from "../route/framing.js";
|
|
9
|
-
import {
|
|
10
|
+
import { MediaRoute } from "../route/media.js";
|
|
11
|
+
import { ProviderConfigurationError, ProviderID, ToolDefinition, } from "../schema/index.js";
|
|
10
12
|
export const id = ProviderID.make("alibaba");
|
|
11
13
|
const hosts = new Map([
|
|
12
14
|
["ap-southeast-1", "dashscope-intl.aliyuncs.com"],
|
|
@@ -66,19 +68,25 @@ export const configure = (input) => {
|
|
|
66
68
|
})
|
|
67
69
|
.model({ id, compatibility: { requireSignature: false } });
|
|
68
70
|
const responses = (id) => responsesRoute.with(common).model({ id });
|
|
69
|
-
|
|
71
|
+
const media = MediaRoute.deployment({ ...input, baseURL: baseURL ?? `https://${host}/api/v1` }, opts.auth);
|
|
72
|
+
const image = (id, providerOptions) => AlibabaImages.model({ ...media, id, providerOptions });
|
|
73
|
+
return { id, model: chat, chat, messages, responses, image, configure };
|
|
70
74
|
};
|
|
71
75
|
export const provider = { id, configure };
|
|
72
|
-
export const model = (id, input) =>
|
|
73
|
-
export const messagesModel = (id, input) =>
|
|
74
|
-
export const responsesModel = (id, input) =>
|
|
75
|
-
|
|
76
|
+
export const model = (id, input) => configure(config(input)).chat(id);
|
|
77
|
+
export const messagesModel = (id, input) => configure(config(input)).messages(id);
|
|
78
|
+
export const responsesModel = (id, input) => configure(config(input)).responses(id);
|
|
79
|
+
export const imageModel = (id, settings) => {
|
|
80
|
+
const input = config(settings);
|
|
81
|
+
return configure(input).image(id, input.providerOptions);
|
|
82
|
+
};
|
|
83
|
+
function config(input) {
|
|
76
84
|
const { body, ...rest } = input;
|
|
77
|
-
return
|
|
85
|
+
return {
|
|
78
86
|
...rest,
|
|
79
87
|
http: body === undefined ? undefined : { body },
|
|
80
88
|
providerOptions: Struct.omit(rest, ["apiKey", "baseURL", "headers", "region", "workspaceID"]),
|
|
81
|
-
}
|
|
89
|
+
};
|
|
82
90
|
}
|
|
83
91
|
export const webSearch = () => hostedTool("web_search", "Search the web with Alibaba's hosted search tool.");
|
|
84
92
|
export const webExtractor = () => hostedTool("web_extractor", "Extract web page content with Alibaba's hosted tool.");
|