@opencode/ai 2.0.22 → 2.0.24
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 +61 -1
- package/dist/cache-policy.js +13 -9
- package/dist/protocols/alibaba-chat.d.ts +3 -3
- package/dist/protocols/alibaba-messages.d.ts +3 -0
- package/dist/protocols/alibaba-responses.d.ts +19 -12
- package/dist/protocols/alibaba-responses.js +3 -5
- package/dist/protocols/anthropic-messages.d.ts +3 -0
- package/dist/protocols/anthropic-messages.js +53 -48
- package/dist/protocols/bedrock-converse.js +3 -3
- package/dist/protocols/cartesia-speech.js +3 -3
- package/dist/protocols/cohere-chat.d.ts +178 -0
- package/dist/protocols/cohere-chat.js +299 -0
- package/dist/protocols/elevenlabs-speech.js +3 -3
- package/dist/protocols/gemini.d.ts +2 -2
- package/dist/protocols/gemini.js +3 -3
- package/dist/protocols/google-interactions.d.ts +236 -0
- package/dist/protocols/google-interactions.js +478 -0
- package/dist/protocols/google-speech.js +1 -1
- package/dist/protocols/google-transcription.js +1 -1
- package/dist/protocols/index.d.ts +2 -0
- package/dist/protocols/index.js +2 -0
- package/dist/protocols/meta-messages.d.ts +3 -0
- package/dist/protocols/meta-responses.d.ts +34 -58
- package/dist/protocols/meta-responses.js +8 -27
- package/dist/protocols/mistral-chat.d.ts +24 -9
- package/dist/protocols/mistral-chat.js +22 -10
- package/dist/protocols/open-responses.d.ts +424 -103
- package/dist/protocols/open-responses.js +30 -20
- package/dist/protocols/openai-chat.d.ts +401 -5
- package/dist/protocols/openai-chat.js +18 -21
- package/dist/protocols/openai-compatible-chat.d.ts +1 -1
- package/dist/protocols/openai-compatible-responses.d.ts +16 -4
- package/dist/protocols/openai-images.js +2 -2
- package/dist/protocols/openai-responses.d.ts +90 -223
- package/dist/protocols/openai-responses.js +6 -13
- package/dist/protocols/openai-speech.js +1 -1
- package/dist/protocols/openai-transcription.js +1 -1
- package/dist/protocols/shared.js +2 -2
- package/dist/protocols/stability-images.js +1 -1
- package/dist/protocols/utils/bedrock-media.js +2 -2
- package/dist/protocols/utils/gateway-protocol.d.ts +17 -0
- package/dist/protocols/utils/gateway-protocol.js +57 -0
- package/dist/protocols/utils/responses-checkpoint.js +2 -2
- package/dist/protocols/utils/responses-hosted-tools.js +1 -1
- package/dist/protocols/utils/tool-stream.js +15 -7
- package/dist/protocols/venice-chat.d.ts +280 -0
- package/dist/protocols/venice-chat.js +283 -0
- package/dist/protocols/xai-responses.d.ts +21 -21
- package/dist/protocols/xai-responses.js +2 -8
- package/dist/protocols/zai-chat.d.ts +3 -3
- package/dist/protocols/zai-messages.d.ts +3 -0
- package/dist/provider-error.js +7 -1
- package/dist/providers/alibaba.d.ts +17 -13
- package/dist/providers/amazon-bedrock/mantle/messages.d.ts +2 -0
- package/dist/providers/amazon-bedrock/mantle/messages.js +1 -0
- package/dist/providers/amazon-bedrock-mantle.d.ts +301 -9
- package/dist/providers/amazon-bedrock-mantle.js +28 -3
- package/dist/providers/azure.d.ts +13 -61
- package/dist/providers/baseten.d.ts +2 -2
- package/dist/providers/cerebras.d.ts +2 -2
- package/dist/providers/cloudflare-ai-gateway.d.ts +14 -62
- package/dist/providers/cloudflare-workers-ai.d.ts +2 -2
- package/dist/providers/cohere/chat.d.ts +4 -0
- package/dist/providers/cohere/chat.js +8 -0
- package/dist/providers/cohere.d.ts +395 -0
- package/dist/providers/cohere.js +48 -0
- package/dist/providers/deepinfra.d.ts +2 -2
- package/dist/providers/deepseek.d.ts +2 -2
- package/dist/providers/digitalocean.d.ts +5 -5
- package/dist/providers/fireworks.d.ts +2 -2
- package/dist/providers/google/interactions.d.ts +7 -0
- package/dist/providers/google/interactions.js +8 -0
- package/dist/providers/google-vertex-chat.d.ts +1 -1
- package/dist/providers/google-vertex-messages.js +1 -0
- package/dist/providers/google-vertex-responses.d.ts +16 -4
- package/dist/providers/google-vertex.d.ts +1 -1
- package/dist/providers/google.d.ts +95 -4
- package/dist/providers/google.js +8 -1
- package/dist/providers/groq.d.ts +4 -4
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.js +2 -0
- package/dist/providers/meta.d.ts +15 -28
- package/dist/providers/minimax.d.ts +17 -5
- package/dist/providers/mistral.d.ts +10 -4
- package/dist/providers/moonshot.d.ts +17 -5
- package/dist/providers/openai-compatible-responses.d.ts +16 -4
- package/dist/providers/openai-compatible.d.ts +1 -1
- package/dist/providers/openai-options.d.ts +1 -1
- package/dist/providers/openai.d.ts +7 -31
- package/dist/providers/openrouter.d.ts +5 -5
- package/dist/providers/togetherai.d.ts +2 -2
- package/dist/providers/venice.d.ts +183 -0
- package/dist/providers/venice.js +38 -0
- package/dist/providers/vercel-ai-gateway/chat.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/chat.js +1 -0
- package/dist/providers/vercel-ai-gateway/messages.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/messages.js +1 -0
- package/dist/providers/vercel-ai-gateway/responses.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/responses.js +1 -0
- package/dist/providers/vercel-ai-gateway.d.ts +91 -9
- package/dist/providers/vercel-ai-gateway.js +161 -21
- package/dist/providers/xai.d.ts +1 -1
- package/dist/providers/zai-coding-plan.d.ts +17 -5
- package/dist/providers/zai.d.ts +1 -1
- package/dist/route/client.js +2 -5
- package/dist/route/framing.js +23 -23
- package/package.json +3 -3
|
@@ -70,6 +70,10 @@ export declare const responsesRoute: import("../route/client.js").Route<{
|
|
|
70
70
|
readonly reasoning: {
|
|
71
71
|
readonly effort: import("../schema/options.js").ReasoningEffort;
|
|
72
72
|
};
|
|
73
|
+
} | {
|
|
74
|
+
readonly [x: string]: unknown;
|
|
75
|
+
readonly type: string;
|
|
76
|
+
readonly id: string;
|
|
73
77
|
} | {
|
|
74
78
|
readonly type: "reasoning";
|
|
75
79
|
readonly summary: readonly {
|
|
@@ -146,34 +150,6 @@ export declare const responsesRoute: import("../route/client.js").Route<{
|
|
|
146
150
|
readonly type: "input_video";
|
|
147
151
|
readonly video_url: string;
|
|
148
152
|
})[];
|
|
149
|
-
} | {
|
|
150
|
-
readonly [x: string]: unknown;
|
|
151
|
-
readonly id: string;
|
|
152
|
-
readonly type: "computer_call";
|
|
153
|
-
readonly status?: string | undefined;
|
|
154
|
-
readonly action?: {
|
|
155
|
-
readonly [x: string]: unknown;
|
|
156
|
-
} | null | undefined;
|
|
157
|
-
readonly call_id?: string | undefined;
|
|
158
|
-
readonly pending_safety_checks?: readonly {
|
|
159
|
-
readonly [x: string]: unknown;
|
|
160
|
-
}[] | undefined;
|
|
161
|
-
} | {
|
|
162
|
-
readonly [x: string]: unknown;
|
|
163
|
-
readonly id: string;
|
|
164
|
-
readonly type: "web_search_preview_call";
|
|
165
|
-
readonly status?: string | undefined;
|
|
166
|
-
readonly action?: {
|
|
167
|
-
readonly [x: string]: unknown;
|
|
168
|
-
} | null | undefined;
|
|
169
|
-
} | {
|
|
170
|
-
readonly [x: string]: unknown;
|
|
171
|
-
readonly id: string;
|
|
172
|
-
readonly type: "image_generation_call";
|
|
173
|
-
readonly status?: string | undefined;
|
|
174
|
-
readonly result?: string | null | undefined;
|
|
175
|
-
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
176
|
-
readonly revised_prompt?: string | null | undefined;
|
|
177
153
|
})[];
|
|
178
154
|
readonly model: string;
|
|
179
155
|
readonly stream: true;
|
|
@@ -242,9 +218,10 @@ export declare const responsesRoute: import("../route/client.js").Route<{
|
|
|
242
218
|
readonly top_p?: number | undefined;
|
|
243
219
|
readonly frequency_penalty?: number | undefined;
|
|
244
220
|
readonly presence_penalty?: number | undefined;
|
|
221
|
+
readonly store?: boolean | undefined;
|
|
222
|
+
readonly max_output_tokens?: number | undefined;
|
|
245
223
|
readonly prompt_cache_key?: string | undefined;
|
|
246
224
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
247
|
-
readonly store?: boolean | undefined;
|
|
248
225
|
readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
|
|
249
226
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
250
227
|
readonly stream_options?: {
|
|
@@ -252,7 +229,6 @@ export declare const responsesRoute: import("../route/client.js").Route<{
|
|
|
252
229
|
} | undefined;
|
|
253
230
|
readonly safety_identifier?: string | undefined;
|
|
254
231
|
readonly top_logprobs?: number | undefined;
|
|
255
|
-
readonly max_output_tokens?: number | undefined;
|
|
256
232
|
readonly max_tool_calls?: number | undefined;
|
|
257
233
|
}, import("../protocols/open-responses-channel.js").Prepared, {
|
|
258
234
|
endpoint: import("../route/client.js").CompactOperation;
|
|
@@ -645,9 +621,9 @@ export declare const route: import("../route/client.js").Route<{
|
|
|
645
621
|
readonly top_p?: number | undefined;
|
|
646
622
|
readonly frequency_penalty?: number | undefined;
|
|
647
623
|
readonly presence_penalty?: number | undefined;
|
|
624
|
+
readonly store?: boolean | undefined;
|
|
648
625
|
readonly prompt_cache_key?: string | undefined;
|
|
649
626
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
650
|
-
readonly store?: boolean | undefined;
|
|
651
627
|
readonly stream_options?: {
|
|
652
628
|
readonly include_usage: boolean;
|
|
653
629
|
} | undefined;
|
|
@@ -1039,9 +1015,9 @@ export declare const routes: (import("../route/client.js").Route<{
|
|
|
1039
1015
|
readonly top_p?: number | undefined;
|
|
1040
1016
|
readonly frequency_penalty?: number | undefined;
|
|
1041
1017
|
readonly presence_penalty?: number | undefined;
|
|
1018
|
+
readonly store?: boolean | undefined;
|
|
1042
1019
|
readonly prompt_cache_key?: string | undefined;
|
|
1043
1020
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
1044
|
-
readonly store?: boolean | undefined;
|
|
1045
1021
|
readonly stream_options?: {
|
|
1046
1022
|
readonly include_usage: boolean;
|
|
1047
1023
|
} | undefined;
|
|
@@ -1089,6 +1065,10 @@ export declare const routes: (import("../route/client.js").Route<{
|
|
|
1089
1065
|
readonly reasoning: {
|
|
1090
1066
|
readonly effort: import("../schema/options.js").ReasoningEffort;
|
|
1091
1067
|
};
|
|
1068
|
+
} | {
|
|
1069
|
+
readonly [x: string]: unknown;
|
|
1070
|
+
readonly type: string;
|
|
1071
|
+
readonly id: string;
|
|
1092
1072
|
} | {
|
|
1093
1073
|
readonly type: "reasoning";
|
|
1094
1074
|
readonly summary: readonly {
|
|
@@ -1165,34 +1145,6 @@ export declare const routes: (import("../route/client.js").Route<{
|
|
|
1165
1145
|
readonly type: "input_video";
|
|
1166
1146
|
readonly video_url: string;
|
|
1167
1147
|
})[];
|
|
1168
|
-
} | {
|
|
1169
|
-
readonly [x: string]: unknown;
|
|
1170
|
-
readonly id: string;
|
|
1171
|
-
readonly type: "computer_call";
|
|
1172
|
-
readonly status?: string | undefined;
|
|
1173
|
-
readonly action?: {
|
|
1174
|
-
readonly [x: string]: unknown;
|
|
1175
|
-
} | null | undefined;
|
|
1176
|
-
readonly call_id?: string | undefined;
|
|
1177
|
-
readonly pending_safety_checks?: readonly {
|
|
1178
|
-
readonly [x: string]: unknown;
|
|
1179
|
-
}[] | undefined;
|
|
1180
|
-
} | {
|
|
1181
|
-
readonly [x: string]: unknown;
|
|
1182
|
-
readonly id: string;
|
|
1183
|
-
readonly type: "web_search_preview_call";
|
|
1184
|
-
readonly status?: string | undefined;
|
|
1185
|
-
readonly action?: {
|
|
1186
|
-
readonly [x: string]: unknown;
|
|
1187
|
-
} | null | undefined;
|
|
1188
|
-
} | {
|
|
1189
|
-
readonly [x: string]: unknown;
|
|
1190
|
-
readonly id: string;
|
|
1191
|
-
readonly type: "image_generation_call";
|
|
1192
|
-
readonly status?: string | undefined;
|
|
1193
|
-
readonly result?: string | null | undefined;
|
|
1194
|
-
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
1195
|
-
readonly revised_prompt?: string | null | undefined;
|
|
1196
1148
|
})[];
|
|
1197
1149
|
readonly model: string;
|
|
1198
1150
|
readonly stream: true;
|
|
@@ -1261,9 +1213,10 @@ export declare const routes: (import("../route/client.js").Route<{
|
|
|
1261
1213
|
readonly top_p?: number | undefined;
|
|
1262
1214
|
readonly frequency_penalty?: number | undefined;
|
|
1263
1215
|
readonly presence_penalty?: number | undefined;
|
|
1216
|
+
readonly store?: boolean | undefined;
|
|
1217
|
+
readonly max_output_tokens?: number | undefined;
|
|
1264
1218
|
readonly prompt_cache_key?: string | undefined;
|
|
1265
1219
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
1266
|
-
readonly store?: boolean | undefined;
|
|
1267
1220
|
readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
|
|
1268
1221
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
1269
1222
|
readonly stream_options?: {
|
|
@@ -1271,7 +1224,6 @@ export declare const routes: (import("../route/client.js").Route<{
|
|
|
1271
1224
|
} | undefined;
|
|
1272
1225
|
readonly safety_identifier?: string | undefined;
|
|
1273
1226
|
readonly top_logprobs?: number | undefined;
|
|
1274
|
-
readonly max_output_tokens?: number | undefined;
|
|
1275
1227
|
readonly max_tool_calls?: number | undefined;
|
|
1276
1228
|
}, import("../protocols/open-responses-channel.js").Prepared, {
|
|
1277
1229
|
endpoint: import("../route/client.js").CompactOperation;
|
|
@@ -130,9 +130,9 @@ export declare const route: Route<{
|
|
|
130
130
|
readonly top_p?: number | undefined;
|
|
131
131
|
readonly frequency_penalty?: number | undefined;
|
|
132
132
|
readonly presence_penalty?: number | undefined;
|
|
133
|
+
readonly store?: boolean | undefined;
|
|
133
134
|
readonly prompt_cache_key?: string | undefined;
|
|
134
135
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
135
|
-
readonly store?: boolean | undefined;
|
|
136
136
|
readonly stream_options?: {
|
|
137
137
|
readonly include_usage: boolean;
|
|
138
138
|
} | undefined;
|
|
@@ -252,9 +252,9 @@ export declare const routes: Route<{
|
|
|
252
252
|
readonly top_p?: number | undefined;
|
|
253
253
|
readonly frequency_penalty?: number | undefined;
|
|
254
254
|
readonly presence_penalty?: number | undefined;
|
|
255
|
+
readonly store?: boolean | undefined;
|
|
255
256
|
readonly prompt_cache_key?: string | undefined;
|
|
256
257
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
257
|
-
readonly store?: boolean | undefined;
|
|
258
258
|
readonly stream_options?: {
|
|
259
259
|
readonly include_usage: boolean;
|
|
260
260
|
} | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ProviderPackage } from "../../provider-package.js";
|
|
2
|
+
import { Cohere } from "../cohere.js";
|
|
3
|
+
export type Settings = Cohere.Settings<Cohere.ChatOptionsInput>;
|
|
4
|
+
export declare const model: ProviderPackage.Definition<Settings, Cohere.ChatOptionsInput>["model"];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Cohere } from "../cohere.js";
|
|
2
|
+
export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => Cohere.configure({
|
|
3
|
+
apiKey,
|
|
4
|
+
baseURL,
|
|
5
|
+
headers,
|
|
6
|
+
http: body === undefined ? undefined : { body: { ...body } },
|
|
7
|
+
providerOptions,
|
|
8
|
+
}).chat(modelID);
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { CohereChat } from "../protocols/cohere-chat.js";
|
|
2
|
+
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
3
|
+
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
4
|
+
import { type ModelID, type OpenString } from "../schema/index.js";
|
|
5
|
+
import type { ProviderPackage } from "../provider-package.js";
|
|
6
|
+
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
7
|
+
export type ChatOptionsInput = {
|
|
8
|
+
readonly reasoningEffort?: OpenString<"none" | "high">;
|
|
9
|
+
};
|
|
10
|
+
export type ProviderOptions = CohereChat.ProviderOptionsInput & ChatOptionsInput;
|
|
11
|
+
export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
12
|
+
readonly baseURL?: string;
|
|
13
|
+
readonly providerOptions?: ProviderOptions;
|
|
14
|
+
};
|
|
15
|
+
export type Settings<Options = CohereChat.ProviderOptionsInput> = ProviderPackage.Settings & Options & {
|
|
16
|
+
readonly apiKey?: string;
|
|
17
|
+
readonly baseURL?: string;
|
|
18
|
+
};
|
|
19
|
+
export declare const route: Route<{
|
|
20
|
+
readonly model: string;
|
|
21
|
+
readonly messages: readonly {
|
|
22
|
+
readonly role: "tool" | "system" | "user" | "assistant";
|
|
23
|
+
readonly content?: string | readonly ({
|
|
24
|
+
readonly type: "text";
|
|
25
|
+
readonly text: string;
|
|
26
|
+
} | {
|
|
27
|
+
readonly type: "thinking";
|
|
28
|
+
readonly thinking: string;
|
|
29
|
+
} | {
|
|
30
|
+
readonly type: "image_url";
|
|
31
|
+
readonly image_url: {
|
|
32
|
+
readonly url: string;
|
|
33
|
+
};
|
|
34
|
+
})[] | undefined;
|
|
35
|
+
readonly tool_calls?: readonly {
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly type: "function";
|
|
38
|
+
readonly function: {
|
|
39
|
+
readonly name: string;
|
|
40
|
+
readonly arguments: string;
|
|
41
|
+
};
|
|
42
|
+
}[] | undefined;
|
|
43
|
+
readonly tool_call_id?: string | undefined;
|
|
44
|
+
readonly tool_plan?: string | undefined;
|
|
45
|
+
}[];
|
|
46
|
+
readonly stream: true;
|
|
47
|
+
readonly max_tokens?: number | undefined;
|
|
48
|
+
readonly tools?: readonly {
|
|
49
|
+
readonly type: "function";
|
|
50
|
+
readonly function: {
|
|
51
|
+
readonly name: string;
|
|
52
|
+
readonly parameters: unknown;
|
|
53
|
+
readonly description?: string | undefined;
|
|
54
|
+
};
|
|
55
|
+
}[] | undefined;
|
|
56
|
+
readonly temperature?: number | undefined;
|
|
57
|
+
readonly seed?: number | undefined;
|
|
58
|
+
readonly thinking?: {
|
|
59
|
+
readonly type: string;
|
|
60
|
+
readonly token_budget?: number | undefined;
|
|
61
|
+
} | undefined;
|
|
62
|
+
readonly tool_choice?: "NONE" | "REQUIRED" | undefined;
|
|
63
|
+
readonly stop_sequences?: readonly string[] | undefined;
|
|
64
|
+
readonly p?: number | undefined;
|
|
65
|
+
readonly k?: number | undefined;
|
|
66
|
+
readonly frequency_penalty?: number | undefined;
|
|
67
|
+
readonly presence_penalty?: number | undefined;
|
|
68
|
+
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>;
|
|
69
|
+
export declare const chatRoute: Route<{
|
|
70
|
+
readonly model: string;
|
|
71
|
+
readonly messages: readonly ({
|
|
72
|
+
readonly role: "system";
|
|
73
|
+
readonly content: string | readonly ({
|
|
74
|
+
readonly type: "text";
|
|
75
|
+
readonly text: string;
|
|
76
|
+
readonly cache_control?: {
|
|
77
|
+
readonly type: "ephemeral";
|
|
78
|
+
readonly ttl?: string | undefined;
|
|
79
|
+
} | undefined;
|
|
80
|
+
} | {
|
|
81
|
+
readonly type: "image_url";
|
|
82
|
+
readonly image_url: {
|
|
83
|
+
readonly url: string;
|
|
84
|
+
};
|
|
85
|
+
} | {
|
|
86
|
+
readonly type: "file";
|
|
87
|
+
readonly file: {
|
|
88
|
+
readonly filename: string;
|
|
89
|
+
readonly file_data: string;
|
|
90
|
+
};
|
|
91
|
+
})[];
|
|
92
|
+
} | {
|
|
93
|
+
readonly role: "user";
|
|
94
|
+
readonly content: string | readonly ({
|
|
95
|
+
readonly type: "text";
|
|
96
|
+
readonly text: string;
|
|
97
|
+
readonly cache_control?: {
|
|
98
|
+
readonly type: "ephemeral";
|
|
99
|
+
readonly ttl?: string | undefined;
|
|
100
|
+
} | undefined;
|
|
101
|
+
} | {
|
|
102
|
+
readonly type: "image_url";
|
|
103
|
+
readonly image_url: {
|
|
104
|
+
readonly url: string;
|
|
105
|
+
};
|
|
106
|
+
} | {
|
|
107
|
+
readonly type: "file";
|
|
108
|
+
readonly file: {
|
|
109
|
+
readonly filename: string;
|
|
110
|
+
readonly file_data: string;
|
|
111
|
+
};
|
|
112
|
+
})[];
|
|
113
|
+
} | {
|
|
114
|
+
readonly [x: string]: unknown;
|
|
115
|
+
readonly content: string | readonly {
|
|
116
|
+
readonly type: "text";
|
|
117
|
+
readonly text: string;
|
|
118
|
+
readonly cache_control?: {
|
|
119
|
+
readonly type: "ephemeral";
|
|
120
|
+
readonly ttl?: string | undefined;
|
|
121
|
+
} | undefined;
|
|
122
|
+
}[] | null;
|
|
123
|
+
readonly role: "assistant";
|
|
124
|
+
readonly reasoning?: string | undefined;
|
|
125
|
+
readonly reasoning_content?: string | undefined;
|
|
126
|
+
readonly reasoning_text?: string | undefined;
|
|
127
|
+
readonly tool_calls?: readonly {
|
|
128
|
+
readonly function: {
|
|
129
|
+
readonly name: string;
|
|
130
|
+
readonly arguments: string;
|
|
131
|
+
};
|
|
132
|
+
readonly id: string;
|
|
133
|
+
readonly type: "function";
|
|
134
|
+
readonly extra_content?: {
|
|
135
|
+
readonly google: {
|
|
136
|
+
readonly thought_signature: string;
|
|
137
|
+
};
|
|
138
|
+
} | undefined;
|
|
139
|
+
}[] | undefined;
|
|
140
|
+
readonly reasoning_details?: unknown;
|
|
141
|
+
} | {
|
|
142
|
+
readonly role: "tool";
|
|
143
|
+
readonly tool_call_id: string;
|
|
144
|
+
readonly content: string | readonly {
|
|
145
|
+
readonly type: "text";
|
|
146
|
+
readonly text: string;
|
|
147
|
+
readonly cache_control?: {
|
|
148
|
+
readonly type: "ephemeral";
|
|
149
|
+
readonly ttl?: string | undefined;
|
|
150
|
+
} | undefined;
|
|
151
|
+
}[];
|
|
152
|
+
})[];
|
|
153
|
+
readonly stream: true;
|
|
154
|
+
readonly max_completion_tokens?: number | undefined;
|
|
155
|
+
readonly max_tokens?: number | undefined;
|
|
156
|
+
readonly tools?: readonly {
|
|
157
|
+
readonly function: {
|
|
158
|
+
readonly description: string;
|
|
159
|
+
readonly name: string;
|
|
160
|
+
readonly parameters: {
|
|
161
|
+
readonly [x: string]: unknown;
|
|
162
|
+
};
|
|
163
|
+
readonly strict?: boolean | undefined;
|
|
164
|
+
};
|
|
165
|
+
readonly type: "function";
|
|
166
|
+
readonly cache_control?: {
|
|
167
|
+
readonly type: "ephemeral";
|
|
168
|
+
readonly ttl?: string | undefined;
|
|
169
|
+
} | undefined;
|
|
170
|
+
}[] | undefined;
|
|
171
|
+
readonly stop?: readonly string[] | undefined;
|
|
172
|
+
readonly temperature?: number | undefined;
|
|
173
|
+
readonly seed?: number | undefined;
|
|
174
|
+
readonly tool_choice?: "required" | "auto" | "none" | {
|
|
175
|
+
readonly type: "function";
|
|
176
|
+
readonly function: {
|
|
177
|
+
readonly name: string;
|
|
178
|
+
};
|
|
179
|
+
} | undefined;
|
|
180
|
+
readonly top_p?: number | undefined;
|
|
181
|
+
readonly frequency_penalty?: number | undefined;
|
|
182
|
+
readonly presence_penalty?: number | undefined;
|
|
183
|
+
readonly store?: boolean | undefined;
|
|
184
|
+
readonly prompt_cache_key?: string | undefined;
|
|
185
|
+
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
186
|
+
readonly stream_options?: {
|
|
187
|
+
readonly include_usage: boolean;
|
|
188
|
+
} | undefined;
|
|
189
|
+
readonly tool_stream?: boolean | undefined;
|
|
190
|
+
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>;
|
|
191
|
+
export declare const routes: (Route<{
|
|
192
|
+
readonly model: string;
|
|
193
|
+
readonly messages: readonly {
|
|
194
|
+
readonly role: "tool" | "system" | "user" | "assistant";
|
|
195
|
+
readonly content?: string | readonly ({
|
|
196
|
+
readonly type: "text";
|
|
197
|
+
readonly text: string;
|
|
198
|
+
} | {
|
|
199
|
+
readonly type: "thinking";
|
|
200
|
+
readonly thinking: string;
|
|
201
|
+
} | {
|
|
202
|
+
readonly type: "image_url";
|
|
203
|
+
readonly image_url: {
|
|
204
|
+
readonly url: string;
|
|
205
|
+
};
|
|
206
|
+
})[] | undefined;
|
|
207
|
+
readonly tool_calls?: readonly {
|
|
208
|
+
readonly id: string;
|
|
209
|
+
readonly type: "function";
|
|
210
|
+
readonly function: {
|
|
211
|
+
readonly name: string;
|
|
212
|
+
readonly arguments: string;
|
|
213
|
+
};
|
|
214
|
+
}[] | undefined;
|
|
215
|
+
readonly tool_call_id?: string | undefined;
|
|
216
|
+
readonly tool_plan?: string | undefined;
|
|
217
|
+
}[];
|
|
218
|
+
readonly stream: true;
|
|
219
|
+
readonly max_tokens?: number | undefined;
|
|
220
|
+
readonly tools?: readonly {
|
|
221
|
+
readonly type: "function";
|
|
222
|
+
readonly function: {
|
|
223
|
+
readonly name: string;
|
|
224
|
+
readonly parameters: unknown;
|
|
225
|
+
readonly description?: string | undefined;
|
|
226
|
+
};
|
|
227
|
+
}[] | undefined;
|
|
228
|
+
readonly temperature?: number | undefined;
|
|
229
|
+
readonly seed?: number | undefined;
|
|
230
|
+
readonly thinking?: {
|
|
231
|
+
readonly type: string;
|
|
232
|
+
readonly token_budget?: number | undefined;
|
|
233
|
+
} | undefined;
|
|
234
|
+
readonly tool_choice?: "NONE" | "REQUIRED" | undefined;
|
|
235
|
+
readonly stop_sequences?: readonly string[] | undefined;
|
|
236
|
+
readonly p?: number | undefined;
|
|
237
|
+
readonly k?: number | undefined;
|
|
238
|
+
readonly frequency_penalty?: number | undefined;
|
|
239
|
+
readonly presence_penalty?: number | undefined;
|
|
240
|
+
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined> | Route<{
|
|
241
|
+
readonly model: string;
|
|
242
|
+
readonly messages: readonly ({
|
|
243
|
+
readonly role: "system";
|
|
244
|
+
readonly content: string | readonly ({
|
|
245
|
+
readonly type: "text";
|
|
246
|
+
readonly text: string;
|
|
247
|
+
readonly cache_control?: {
|
|
248
|
+
readonly type: "ephemeral";
|
|
249
|
+
readonly ttl?: string | undefined;
|
|
250
|
+
} | undefined;
|
|
251
|
+
} | {
|
|
252
|
+
readonly type: "image_url";
|
|
253
|
+
readonly image_url: {
|
|
254
|
+
readonly url: string;
|
|
255
|
+
};
|
|
256
|
+
} | {
|
|
257
|
+
readonly type: "file";
|
|
258
|
+
readonly file: {
|
|
259
|
+
readonly filename: string;
|
|
260
|
+
readonly file_data: string;
|
|
261
|
+
};
|
|
262
|
+
})[];
|
|
263
|
+
} | {
|
|
264
|
+
readonly role: "user";
|
|
265
|
+
readonly content: string | readonly ({
|
|
266
|
+
readonly type: "text";
|
|
267
|
+
readonly text: string;
|
|
268
|
+
readonly cache_control?: {
|
|
269
|
+
readonly type: "ephemeral";
|
|
270
|
+
readonly ttl?: string | undefined;
|
|
271
|
+
} | undefined;
|
|
272
|
+
} | {
|
|
273
|
+
readonly type: "image_url";
|
|
274
|
+
readonly image_url: {
|
|
275
|
+
readonly url: string;
|
|
276
|
+
};
|
|
277
|
+
} | {
|
|
278
|
+
readonly type: "file";
|
|
279
|
+
readonly file: {
|
|
280
|
+
readonly filename: string;
|
|
281
|
+
readonly file_data: string;
|
|
282
|
+
};
|
|
283
|
+
})[];
|
|
284
|
+
} | {
|
|
285
|
+
readonly [x: string]: unknown;
|
|
286
|
+
readonly content: string | readonly {
|
|
287
|
+
readonly type: "text";
|
|
288
|
+
readonly text: string;
|
|
289
|
+
readonly cache_control?: {
|
|
290
|
+
readonly type: "ephemeral";
|
|
291
|
+
readonly ttl?: string | undefined;
|
|
292
|
+
} | undefined;
|
|
293
|
+
}[] | null;
|
|
294
|
+
readonly role: "assistant";
|
|
295
|
+
readonly reasoning?: string | undefined;
|
|
296
|
+
readonly reasoning_content?: string | undefined;
|
|
297
|
+
readonly reasoning_text?: string | undefined;
|
|
298
|
+
readonly tool_calls?: readonly {
|
|
299
|
+
readonly function: {
|
|
300
|
+
readonly name: string;
|
|
301
|
+
readonly arguments: string;
|
|
302
|
+
};
|
|
303
|
+
readonly id: string;
|
|
304
|
+
readonly type: "function";
|
|
305
|
+
readonly extra_content?: {
|
|
306
|
+
readonly google: {
|
|
307
|
+
readonly thought_signature: string;
|
|
308
|
+
};
|
|
309
|
+
} | undefined;
|
|
310
|
+
}[] | undefined;
|
|
311
|
+
readonly reasoning_details?: unknown;
|
|
312
|
+
} | {
|
|
313
|
+
readonly role: "tool";
|
|
314
|
+
readonly tool_call_id: string;
|
|
315
|
+
readonly content: string | readonly {
|
|
316
|
+
readonly type: "text";
|
|
317
|
+
readonly text: string;
|
|
318
|
+
readonly cache_control?: {
|
|
319
|
+
readonly type: "ephemeral";
|
|
320
|
+
readonly ttl?: string | undefined;
|
|
321
|
+
} | undefined;
|
|
322
|
+
}[];
|
|
323
|
+
})[];
|
|
324
|
+
readonly stream: true;
|
|
325
|
+
readonly max_completion_tokens?: number | undefined;
|
|
326
|
+
readonly max_tokens?: number | undefined;
|
|
327
|
+
readonly tools?: readonly {
|
|
328
|
+
readonly function: {
|
|
329
|
+
readonly description: string;
|
|
330
|
+
readonly name: string;
|
|
331
|
+
readonly parameters: {
|
|
332
|
+
readonly [x: string]: unknown;
|
|
333
|
+
};
|
|
334
|
+
readonly strict?: boolean | undefined;
|
|
335
|
+
};
|
|
336
|
+
readonly type: "function";
|
|
337
|
+
readonly cache_control?: {
|
|
338
|
+
readonly type: "ephemeral";
|
|
339
|
+
readonly ttl?: string | undefined;
|
|
340
|
+
} | undefined;
|
|
341
|
+
}[] | undefined;
|
|
342
|
+
readonly stop?: readonly string[] | undefined;
|
|
343
|
+
readonly temperature?: number | undefined;
|
|
344
|
+
readonly seed?: number | undefined;
|
|
345
|
+
readonly tool_choice?: "required" | "auto" | "none" | {
|
|
346
|
+
readonly type: "function";
|
|
347
|
+
readonly function: {
|
|
348
|
+
readonly name: string;
|
|
349
|
+
};
|
|
350
|
+
} | undefined;
|
|
351
|
+
readonly top_p?: number | undefined;
|
|
352
|
+
readonly frequency_penalty?: number | undefined;
|
|
353
|
+
readonly presence_penalty?: number | undefined;
|
|
354
|
+
readonly store?: boolean | undefined;
|
|
355
|
+
readonly prompt_cache_key?: string | undefined;
|
|
356
|
+
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
357
|
+
readonly stream_options?: {
|
|
358
|
+
readonly include_usage: boolean;
|
|
359
|
+
} | undefined;
|
|
360
|
+
readonly tool_stream?: boolean | undefined;
|
|
361
|
+
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>)[];
|
|
362
|
+
export declare const configure: (input?: LanguageModelOptions) => {
|
|
363
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
364
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
|
|
365
|
+
readonly thinking?: {
|
|
366
|
+
readonly type?: "enabled" | "disabled" | undefined;
|
|
367
|
+
readonly tokenBudget?: number | undefined;
|
|
368
|
+
} | undefined;
|
|
369
|
+
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
370
|
+
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ChatOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
371
|
+
configure: (input?: LanguageModelOptions) => /*elided*/ any;
|
|
372
|
+
};
|
|
373
|
+
export declare const provider: {
|
|
374
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
375
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
|
|
376
|
+
readonly thinking?: {
|
|
377
|
+
readonly type?: "enabled" | "disabled" | undefined;
|
|
378
|
+
readonly tokenBudget?: number | undefined;
|
|
379
|
+
} | undefined;
|
|
380
|
+
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
381
|
+
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ChatOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
382
|
+
configure: (input?: LanguageModelOptions) => {
|
|
383
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
384
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
|
|
385
|
+
readonly thinking?: {
|
|
386
|
+
readonly type?: "enabled" | "disabled" | undefined;
|
|
387
|
+
readonly tokenBudget?: number | undefined;
|
|
388
|
+
} | undefined;
|
|
389
|
+
}, import("../route/client.js").CompactionOperations | undefined>;
|
|
390
|
+
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ChatOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
391
|
+
configure: /*elided*/ any;
|
|
392
|
+
};
|
|
393
|
+
};
|
|
394
|
+
export declare const model: ProviderPackage.Definition<Settings, CohereChat.ProviderOptionsInput>["model"];
|
|
395
|
+
export * as Cohere from "./cohere.js";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { CohereChat } from "../protocols/cohere-chat.js";
|
|
2
|
+
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
3
|
+
import { Route } from "../route/client.js";
|
|
4
|
+
import { Endpoint } from "../route/endpoint.js";
|
|
5
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
6
|
+
import { ProviderID } from "../schema/index.js";
|
|
7
|
+
export const id = ProviderID.make("cohere");
|
|
8
|
+
const COMPATIBILITY_BASE_URL = "https://api.cohere.ai/compatibility/v1";
|
|
9
|
+
export const route = CohereChat.route;
|
|
10
|
+
export const chatRoute = Route.make({
|
|
11
|
+
id: "cohere-chat-completions",
|
|
12
|
+
provider: id,
|
|
13
|
+
providerMetadataKey: "cohere",
|
|
14
|
+
protocol: OpenAIChat.protocol,
|
|
15
|
+
endpoint: Endpoint.path("/chat/completions", { baseURL: COMPATIBILITY_BASE_URL }),
|
|
16
|
+
framing: OpenAIChat.framing,
|
|
17
|
+
});
|
|
18
|
+
export const routes = [route, chatRoute];
|
|
19
|
+
export const configure = (input = {}) => {
|
|
20
|
+
const { apiKey: _apiKey, auth: _auth, baseURL, ...defaults } = input;
|
|
21
|
+
const auth = AuthOptions.bearer(input, "COHERE_API_KEY");
|
|
22
|
+
const native = route.with({ ...defaults, auth, endpoint: { baseURL: baseURL ?? CohereChat.DEFAULT_BASE_URL } });
|
|
23
|
+
const chat = chatRoute.with({ ...defaults, auth, endpoint: { baseURL: baseURL ?? COMPATIBILITY_BASE_URL } });
|
|
24
|
+
return {
|
|
25
|
+
id,
|
|
26
|
+
model: (modelID) => native.model({ id: modelID }),
|
|
27
|
+
chat: (modelID) => chat.model({
|
|
28
|
+
id: modelID,
|
|
29
|
+
compatibility: {
|
|
30
|
+
maxTokensField: "max_tokens",
|
|
31
|
+
supportsStore: false,
|
|
32
|
+
supportsUsageInStreaming: true,
|
|
33
|
+
reasoningField: "reasoning_content",
|
|
34
|
+
supportsStrictMode: false,
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
configure,
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export const provider = configure();
|
|
41
|
+
export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({
|
|
42
|
+
apiKey,
|
|
43
|
+
baseURL,
|
|
44
|
+
headers,
|
|
45
|
+
http: body === undefined ? undefined : { body: { ...body } },
|
|
46
|
+
providerOptions,
|
|
47
|
+
}).model(modelID);
|
|
48
|
+
export * as Cohere from "./cohere.js";
|
|
@@ -126,9 +126,9 @@ export declare const route: Route<{
|
|
|
126
126
|
readonly top_p?: number | undefined;
|
|
127
127
|
readonly frequency_penalty?: number | undefined;
|
|
128
128
|
readonly presence_penalty?: number | undefined;
|
|
129
|
+
readonly store?: boolean | undefined;
|
|
129
130
|
readonly prompt_cache_key?: string | undefined;
|
|
130
131
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
131
|
-
readonly store?: boolean | undefined;
|
|
132
132
|
readonly stream_options?: {
|
|
133
133
|
readonly include_usage: boolean;
|
|
134
134
|
} | undefined;
|
|
@@ -248,9 +248,9 @@ export declare const routes: Route<{
|
|
|
248
248
|
readonly top_p?: number | undefined;
|
|
249
249
|
readonly frequency_penalty?: number | undefined;
|
|
250
250
|
readonly presence_penalty?: number | undefined;
|
|
251
|
+
readonly store?: boolean | undefined;
|
|
251
252
|
readonly prompt_cache_key?: string | undefined;
|
|
252
253
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
253
|
-
readonly store?: boolean | undefined;
|
|
254
254
|
readonly stream_options?: {
|
|
255
255
|
readonly include_usage: boolean;
|
|
256
256
|
} | undefined;
|
|
@@ -126,9 +126,9 @@ export declare const route: Route<{
|
|
|
126
126
|
readonly top_p?: number | undefined;
|
|
127
127
|
readonly frequency_penalty?: number | undefined;
|
|
128
128
|
readonly presence_penalty?: number | undefined;
|
|
129
|
+
readonly store?: boolean | undefined;
|
|
129
130
|
readonly prompt_cache_key?: string | undefined;
|
|
130
131
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
131
|
-
readonly store?: boolean | undefined;
|
|
132
132
|
readonly stream_options?: {
|
|
133
133
|
readonly include_usage: boolean;
|
|
134
134
|
} | undefined;
|
|
@@ -248,9 +248,9 @@ export declare const routes: Route<{
|
|
|
248
248
|
readonly top_p?: number | undefined;
|
|
249
249
|
readonly frequency_penalty?: number | undefined;
|
|
250
250
|
readonly presence_penalty?: number | undefined;
|
|
251
|
+
readonly store?: boolean | undefined;
|
|
251
252
|
readonly prompt_cache_key?: string | undefined;
|
|
252
253
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
253
|
-
readonly store?: boolean | undefined;
|
|
254
254
|
readonly stream_options?: {
|
|
255
255
|
readonly include_usage: boolean;
|
|
256
256
|
} | undefined;
|