@opencode-ai/ai 0.0.0-dev-18240 → 0.0.0-dev-18245
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/protocols/shared.d.ts +3 -4
- package/dist/protocols/shared.js +18 -5
- package/dist/providers/cerebras.d.ts +228 -0
- package/dist/providers/cerebras.js +35 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.js +2 -0
- package/dist/providers/togetherai.d.ts +228 -0
- package/dist/providers/togetherai.js +35 -0
- package/package.json +3 -3
|
@@ -119,10 +119,9 @@ export declare const errorText: (error: unknown) => string;
|
|
|
119
119
|
* `framing` step for Server-Sent Events. Decodes UTF-8, runs the SSE channel
|
|
120
120
|
* decoder, optionally filters named events, and drops empty / `[DONE]`
|
|
121
121
|
* keep-alive events so the protocol event schema sees one JSON string per
|
|
122
|
-
* element.
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* errors so the public error channel stays `AIError`.
|
|
122
|
+
* element. Retry control events are ignored without interrupting the stream.
|
|
123
|
+
* Decoder failures become provider output errors so the public error channel
|
|
124
|
+
* stays `AIError`.
|
|
126
125
|
*/
|
|
127
126
|
export declare const sseFraming: (bytes: Stream.Stream<Uint8Array, AIError>, events?: ReadonlySet<string>) => Stream.Stream<string, AIError>;
|
|
128
127
|
/**
|
package/dist/protocols/shared.js
CHANGED
|
@@ -162,12 +162,25 @@ export const errorText = (error) => {
|
|
|
162
162
|
* `framing` step for Server-Sent Events. Decodes UTF-8, runs the SSE channel
|
|
163
163
|
* decoder, optionally filters named events, and drops empty / `[DONE]`
|
|
164
164
|
* keep-alive events so the protocol event schema sees one JSON string per
|
|
165
|
-
* element.
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* errors so the public error channel stays `AIError`.
|
|
165
|
+
* element. Retry control events are ignored without interrupting the stream.
|
|
166
|
+
* Decoder failures become provider output errors so the public error channel
|
|
167
|
+
* stays `AIError`.
|
|
169
168
|
*/
|
|
170
|
-
export const sseFraming = (bytes, events) => bytes.pipe(Stream.decodeText(), Stream.
|
|
169
|
+
export const sseFraming = (bytes, events) => bytes.pipe(Stream.decodeText(), Stream.mapAccumEffect(() => {
|
|
170
|
+
const output = [];
|
|
171
|
+
return {
|
|
172
|
+
output,
|
|
173
|
+
parser: Sse.makeParser((event) => {
|
|
174
|
+
if (event._tag === "Event")
|
|
175
|
+
output.push(event);
|
|
176
|
+
}),
|
|
177
|
+
};
|
|
178
|
+
}, (state, chunk) => Effect.gen(function* () {
|
|
179
|
+
const error = state.parser.feed(chunk);
|
|
180
|
+
if (error)
|
|
181
|
+
return yield* eventError("sse", error.message);
|
|
182
|
+
return [state, state.output.splice(0)];
|
|
183
|
+
})), Stream.filter((event) => (events === undefined || events.has(event.event)) &&
|
|
171
184
|
event.data.length > 0 &&
|
|
172
185
|
(event.data !== "[DONE]" || (events !== undefined && event.event !== "message"))), Stream.map((event) => event.data));
|
|
173
186
|
/**
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
+
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
3
|
+
import type { RouteDefaultsInput } from "../route/client.js";
|
|
4
|
+
import { type ModelID } from "../schema/index.js";
|
|
5
|
+
import type { OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
6
|
+
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
7
|
+
export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
8
|
+
readonly baseURL?: string;
|
|
9
|
+
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
10
|
+
};
|
|
11
|
+
export interface Settings extends ProviderPackage.Settings {
|
|
12
|
+
readonly apiKey?: string;
|
|
13
|
+
readonly baseURL?: string;
|
|
14
|
+
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
15
|
+
}
|
|
16
|
+
export declare const route: import("../route/client.js").Route<{
|
|
17
|
+
readonly model: string;
|
|
18
|
+
readonly messages: readonly ({
|
|
19
|
+
readonly role: "system";
|
|
20
|
+
readonly content: string | readonly ({
|
|
21
|
+
readonly type: "text";
|
|
22
|
+
readonly text: string;
|
|
23
|
+
readonly cache_control?: {
|
|
24
|
+
readonly type: "ephemeral";
|
|
25
|
+
readonly ttl?: string | undefined;
|
|
26
|
+
} | undefined;
|
|
27
|
+
} | {
|
|
28
|
+
readonly type: "image_url";
|
|
29
|
+
readonly image_url: {
|
|
30
|
+
readonly url: string;
|
|
31
|
+
};
|
|
32
|
+
})[];
|
|
33
|
+
} | {
|
|
34
|
+
readonly role: "user";
|
|
35
|
+
readonly content: string | readonly ({
|
|
36
|
+
readonly type: "text";
|
|
37
|
+
readonly text: string;
|
|
38
|
+
readonly cache_control?: {
|
|
39
|
+
readonly type: "ephemeral";
|
|
40
|
+
readonly ttl?: string | undefined;
|
|
41
|
+
} | undefined;
|
|
42
|
+
} | {
|
|
43
|
+
readonly type: "image_url";
|
|
44
|
+
readonly image_url: {
|
|
45
|
+
readonly url: string;
|
|
46
|
+
};
|
|
47
|
+
})[];
|
|
48
|
+
} | {
|
|
49
|
+
readonly [x: string]: unknown;
|
|
50
|
+
readonly content: string | null;
|
|
51
|
+
readonly role: "assistant";
|
|
52
|
+
readonly reasoning?: string | undefined;
|
|
53
|
+
readonly reasoning_content?: string | undefined;
|
|
54
|
+
readonly reasoning_text?: string | undefined;
|
|
55
|
+
readonly cache_control?: {
|
|
56
|
+
readonly type: "ephemeral";
|
|
57
|
+
readonly ttl?: string | undefined;
|
|
58
|
+
} | undefined;
|
|
59
|
+
readonly tool_calls?: readonly {
|
|
60
|
+
readonly id: string;
|
|
61
|
+
readonly type: "function";
|
|
62
|
+
readonly function: {
|
|
63
|
+
readonly name: string;
|
|
64
|
+
readonly arguments: string;
|
|
65
|
+
};
|
|
66
|
+
}[] | undefined;
|
|
67
|
+
readonly reasoning_details?: unknown;
|
|
68
|
+
} | {
|
|
69
|
+
readonly content: string;
|
|
70
|
+
readonly role: "tool";
|
|
71
|
+
readonly tool_call_id: string;
|
|
72
|
+
readonly cache_control?: {
|
|
73
|
+
readonly type: "ephemeral";
|
|
74
|
+
readonly ttl?: string | undefined;
|
|
75
|
+
} | undefined;
|
|
76
|
+
})[];
|
|
77
|
+
readonly stream: true;
|
|
78
|
+
readonly max_completion_tokens?: number | undefined;
|
|
79
|
+
readonly max_tokens?: number | undefined;
|
|
80
|
+
readonly tools?: readonly {
|
|
81
|
+
readonly function: {
|
|
82
|
+
readonly description: string;
|
|
83
|
+
readonly name: string;
|
|
84
|
+
readonly parameters: {
|
|
85
|
+
readonly [x: string]: unknown;
|
|
86
|
+
};
|
|
87
|
+
readonly strict?: boolean | undefined;
|
|
88
|
+
};
|
|
89
|
+
readonly type: "function";
|
|
90
|
+
readonly cache_control?: {
|
|
91
|
+
readonly type: "ephemeral";
|
|
92
|
+
readonly ttl?: string | undefined;
|
|
93
|
+
} | undefined;
|
|
94
|
+
}[] | undefined;
|
|
95
|
+
readonly stop?: readonly string[] | undefined;
|
|
96
|
+
readonly temperature?: number | undefined;
|
|
97
|
+
readonly seed?: number | undefined;
|
|
98
|
+
readonly tool_choice?: "required" | "auto" | "none" | {
|
|
99
|
+
readonly type: "function";
|
|
100
|
+
readonly function: {
|
|
101
|
+
readonly name: string;
|
|
102
|
+
};
|
|
103
|
+
} | undefined;
|
|
104
|
+
readonly top_p?: number | undefined;
|
|
105
|
+
readonly store?: boolean | undefined;
|
|
106
|
+
readonly stream_options?: {
|
|
107
|
+
readonly include_usage: boolean;
|
|
108
|
+
} | undefined;
|
|
109
|
+
readonly prompt_cache_key?: string | undefined;
|
|
110
|
+
readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
111
|
+
readonly tool_stream?: boolean | undefined;
|
|
112
|
+
readonly frequency_penalty?: number | undefined;
|
|
113
|
+
readonly presence_penalty?: number | undefined;
|
|
114
|
+
}, import("../route/transport/http.js").HttpPrepared<string>>;
|
|
115
|
+
export declare const routes: import("../route/client.js").Route<{
|
|
116
|
+
readonly model: string;
|
|
117
|
+
readonly messages: readonly ({
|
|
118
|
+
readonly role: "system";
|
|
119
|
+
readonly content: string | readonly ({
|
|
120
|
+
readonly type: "text";
|
|
121
|
+
readonly text: string;
|
|
122
|
+
readonly cache_control?: {
|
|
123
|
+
readonly type: "ephemeral";
|
|
124
|
+
readonly ttl?: string | undefined;
|
|
125
|
+
} | undefined;
|
|
126
|
+
} | {
|
|
127
|
+
readonly type: "image_url";
|
|
128
|
+
readonly image_url: {
|
|
129
|
+
readonly url: string;
|
|
130
|
+
};
|
|
131
|
+
})[];
|
|
132
|
+
} | {
|
|
133
|
+
readonly role: "user";
|
|
134
|
+
readonly content: string | readonly ({
|
|
135
|
+
readonly type: "text";
|
|
136
|
+
readonly text: string;
|
|
137
|
+
readonly cache_control?: {
|
|
138
|
+
readonly type: "ephemeral";
|
|
139
|
+
readonly ttl?: string | undefined;
|
|
140
|
+
} | undefined;
|
|
141
|
+
} | {
|
|
142
|
+
readonly type: "image_url";
|
|
143
|
+
readonly image_url: {
|
|
144
|
+
readonly url: string;
|
|
145
|
+
};
|
|
146
|
+
})[];
|
|
147
|
+
} | {
|
|
148
|
+
readonly [x: string]: unknown;
|
|
149
|
+
readonly content: string | null;
|
|
150
|
+
readonly role: "assistant";
|
|
151
|
+
readonly reasoning?: string | undefined;
|
|
152
|
+
readonly reasoning_content?: string | undefined;
|
|
153
|
+
readonly reasoning_text?: string | undefined;
|
|
154
|
+
readonly cache_control?: {
|
|
155
|
+
readonly type: "ephemeral";
|
|
156
|
+
readonly ttl?: string | undefined;
|
|
157
|
+
} | undefined;
|
|
158
|
+
readonly tool_calls?: readonly {
|
|
159
|
+
readonly id: string;
|
|
160
|
+
readonly type: "function";
|
|
161
|
+
readonly function: {
|
|
162
|
+
readonly name: string;
|
|
163
|
+
readonly arguments: string;
|
|
164
|
+
};
|
|
165
|
+
}[] | undefined;
|
|
166
|
+
readonly reasoning_details?: unknown;
|
|
167
|
+
} | {
|
|
168
|
+
readonly content: string;
|
|
169
|
+
readonly role: "tool";
|
|
170
|
+
readonly tool_call_id: string;
|
|
171
|
+
readonly cache_control?: {
|
|
172
|
+
readonly type: "ephemeral";
|
|
173
|
+
readonly ttl?: string | undefined;
|
|
174
|
+
} | undefined;
|
|
175
|
+
})[];
|
|
176
|
+
readonly stream: true;
|
|
177
|
+
readonly max_completion_tokens?: number | undefined;
|
|
178
|
+
readonly max_tokens?: number | undefined;
|
|
179
|
+
readonly tools?: readonly {
|
|
180
|
+
readonly function: {
|
|
181
|
+
readonly description: string;
|
|
182
|
+
readonly name: string;
|
|
183
|
+
readonly parameters: {
|
|
184
|
+
readonly [x: string]: unknown;
|
|
185
|
+
};
|
|
186
|
+
readonly strict?: boolean | undefined;
|
|
187
|
+
};
|
|
188
|
+
readonly type: "function";
|
|
189
|
+
readonly cache_control?: {
|
|
190
|
+
readonly type: "ephemeral";
|
|
191
|
+
readonly ttl?: string | undefined;
|
|
192
|
+
} | undefined;
|
|
193
|
+
}[] | undefined;
|
|
194
|
+
readonly stop?: readonly string[] | undefined;
|
|
195
|
+
readonly temperature?: number | undefined;
|
|
196
|
+
readonly seed?: number | undefined;
|
|
197
|
+
readonly tool_choice?: "required" | "auto" | "none" | {
|
|
198
|
+
readonly type: "function";
|
|
199
|
+
readonly function: {
|
|
200
|
+
readonly name: string;
|
|
201
|
+
};
|
|
202
|
+
} | undefined;
|
|
203
|
+
readonly top_p?: number | undefined;
|
|
204
|
+
readonly store?: boolean | undefined;
|
|
205
|
+
readonly stream_options?: {
|
|
206
|
+
readonly include_usage: boolean;
|
|
207
|
+
} | undefined;
|
|
208
|
+
readonly prompt_cache_key?: string | undefined;
|
|
209
|
+
readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
210
|
+
readonly tool_stream?: boolean | undefined;
|
|
211
|
+
readonly frequency_penalty?: number | undefined;
|
|
212
|
+
readonly presence_penalty?: number | undefined;
|
|
213
|
+
}, import("../route/transport/http.js").HttpPrepared<string>>[];
|
|
214
|
+
export declare const configure: (input?: LanguageModelOptions) => {
|
|
215
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
216
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
|
|
217
|
+
configure: (input?: LanguageModelOptions) => /*elided*/ any;
|
|
218
|
+
};
|
|
219
|
+
export declare const provider: {
|
|
220
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
221
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
|
|
222
|
+
configure: (input?: LanguageModelOptions) => {
|
|
223
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
224
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
|
|
225
|
+
configure: /*elided*/ any;
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
export declare const model: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { OpenAICompatibleChat } from "../protocols/openai-compatible-chat.js";
|
|
2
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
3
|
+
import { ProviderID } from "../schema/index.js";
|
|
4
|
+
import { profiles } from "./openai-compatible-profile.js";
|
|
5
|
+
export const id = ProviderID.make("cerebras");
|
|
6
|
+
export const route = OpenAICompatibleChat.route.with({
|
|
7
|
+
id: "cerebras-chat",
|
|
8
|
+
provider: id,
|
|
9
|
+
endpoint: { baseURL: profiles.cerebras.baseURL },
|
|
10
|
+
});
|
|
11
|
+
export const routes = [route];
|
|
12
|
+
export const configure = (input = {}) => {
|
|
13
|
+
const { apiKey: _apiKey, auth: _auth, baseURL, ...defaults } = input;
|
|
14
|
+
const configured = route.with({
|
|
15
|
+
...defaults,
|
|
16
|
+
endpoint: { baseURL: baseURL ?? profiles.cerebras.baseURL },
|
|
17
|
+
auth: AuthOptions.bearer(input, "CEREBRAS_API_KEY"),
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
id,
|
|
21
|
+
model: (modelID) => configured.model({
|
|
22
|
+
id: modelID,
|
|
23
|
+
compatibility: { maxTokensField: "max_tokens", reasoningField: "reasoning", supportsStore: false },
|
|
24
|
+
}),
|
|
25
|
+
configure,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export const provider = configure();
|
|
29
|
+
export const model = (modelID, settings) => configure({
|
|
30
|
+
apiKey: settings.apiKey,
|
|
31
|
+
baseURL: settings.baseURL,
|
|
32
|
+
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
33
|
+
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
34
|
+
providerOptions: settings.providerOptions,
|
|
35
|
+
}).model(modelID);
|
|
@@ -3,6 +3,7 @@ export * as AnthropicCompatible from "./anthropic-compatible.js";
|
|
|
3
3
|
export * as AmazonBedrock from "./amazon-bedrock.js";
|
|
4
4
|
export * as AmazonBedrockMantle from "./amazon-bedrock-mantle.js";
|
|
5
5
|
export * as Azure from "./azure.js";
|
|
6
|
+
export * as Cerebras from "./cerebras.js";
|
|
6
7
|
export * as Cloudflare from "./cloudflare.js";
|
|
7
8
|
export { CloudflareAIGateway, CloudflareWorkersAI } from "./cloudflare.js";
|
|
8
9
|
export * as Google from "./google.js";
|
|
@@ -14,5 +15,6 @@ export * as OpenAI from "./openai.js";
|
|
|
14
15
|
export * as OpenAICompatible from "./openai-compatible.js";
|
|
15
16
|
export * as OpenAICompatibleResponses from "./openai-compatible-responses.js";
|
|
16
17
|
export * as OpenRouter from "./openrouter.js";
|
|
18
|
+
export * as TogetherAI from "./togetherai.js";
|
|
17
19
|
export * as XAI from "./xai.js";
|
|
18
20
|
export * as ZAI from "./zai.js";
|
package/dist/providers/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * as AnthropicCompatible from "./anthropic-compatible.js";
|
|
|
3
3
|
export * as AmazonBedrock from "./amazon-bedrock.js";
|
|
4
4
|
export * as AmazonBedrockMantle from "./amazon-bedrock-mantle.js";
|
|
5
5
|
export * as Azure from "./azure.js";
|
|
6
|
+
export * as Cerebras from "./cerebras.js";
|
|
6
7
|
export * as Cloudflare from "./cloudflare.js";
|
|
7
8
|
export { CloudflareAIGateway, CloudflareWorkersAI } from "./cloudflare.js";
|
|
8
9
|
export * as Google from "./google.js";
|
|
@@ -14,5 +15,6 @@ export * as OpenAI from "./openai.js";
|
|
|
14
15
|
export * as OpenAICompatible from "./openai-compatible.js";
|
|
15
16
|
export * as OpenAICompatibleResponses from "./openai-compatible-responses.js";
|
|
16
17
|
export * as OpenRouter from "./openrouter.js";
|
|
18
|
+
export * as TogetherAI from "./togetherai.js";
|
|
17
19
|
export * as XAI from "./xai.js";
|
|
18
20
|
export * as ZAI from "./zai.js";
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
+
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
3
|
+
import type { RouteDefaultsInput } from "../route/client.js";
|
|
4
|
+
import { type ModelID } from "../schema/index.js";
|
|
5
|
+
import type { OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
6
|
+
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
7
|
+
export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
8
|
+
readonly baseURL?: string;
|
|
9
|
+
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
10
|
+
};
|
|
11
|
+
export interface Settings extends ProviderPackage.Settings {
|
|
12
|
+
readonly apiKey?: string;
|
|
13
|
+
readonly baseURL?: string;
|
|
14
|
+
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
15
|
+
}
|
|
16
|
+
export declare const route: import("../route/client.js").Route<{
|
|
17
|
+
readonly model: string;
|
|
18
|
+
readonly messages: readonly ({
|
|
19
|
+
readonly role: "system";
|
|
20
|
+
readonly content: string | readonly ({
|
|
21
|
+
readonly type: "text";
|
|
22
|
+
readonly text: string;
|
|
23
|
+
readonly cache_control?: {
|
|
24
|
+
readonly type: "ephemeral";
|
|
25
|
+
readonly ttl?: string | undefined;
|
|
26
|
+
} | undefined;
|
|
27
|
+
} | {
|
|
28
|
+
readonly type: "image_url";
|
|
29
|
+
readonly image_url: {
|
|
30
|
+
readonly url: string;
|
|
31
|
+
};
|
|
32
|
+
})[];
|
|
33
|
+
} | {
|
|
34
|
+
readonly role: "user";
|
|
35
|
+
readonly content: string | readonly ({
|
|
36
|
+
readonly type: "text";
|
|
37
|
+
readonly text: string;
|
|
38
|
+
readonly cache_control?: {
|
|
39
|
+
readonly type: "ephemeral";
|
|
40
|
+
readonly ttl?: string | undefined;
|
|
41
|
+
} | undefined;
|
|
42
|
+
} | {
|
|
43
|
+
readonly type: "image_url";
|
|
44
|
+
readonly image_url: {
|
|
45
|
+
readonly url: string;
|
|
46
|
+
};
|
|
47
|
+
})[];
|
|
48
|
+
} | {
|
|
49
|
+
readonly [x: string]: unknown;
|
|
50
|
+
readonly content: string | null;
|
|
51
|
+
readonly role: "assistant";
|
|
52
|
+
readonly reasoning?: string | undefined;
|
|
53
|
+
readonly reasoning_content?: string | undefined;
|
|
54
|
+
readonly reasoning_text?: string | undefined;
|
|
55
|
+
readonly cache_control?: {
|
|
56
|
+
readonly type: "ephemeral";
|
|
57
|
+
readonly ttl?: string | undefined;
|
|
58
|
+
} | undefined;
|
|
59
|
+
readonly tool_calls?: readonly {
|
|
60
|
+
readonly id: string;
|
|
61
|
+
readonly type: "function";
|
|
62
|
+
readonly function: {
|
|
63
|
+
readonly name: string;
|
|
64
|
+
readonly arguments: string;
|
|
65
|
+
};
|
|
66
|
+
}[] | undefined;
|
|
67
|
+
readonly reasoning_details?: unknown;
|
|
68
|
+
} | {
|
|
69
|
+
readonly content: string;
|
|
70
|
+
readonly role: "tool";
|
|
71
|
+
readonly tool_call_id: string;
|
|
72
|
+
readonly cache_control?: {
|
|
73
|
+
readonly type: "ephemeral";
|
|
74
|
+
readonly ttl?: string | undefined;
|
|
75
|
+
} | undefined;
|
|
76
|
+
})[];
|
|
77
|
+
readonly stream: true;
|
|
78
|
+
readonly max_completion_tokens?: number | undefined;
|
|
79
|
+
readonly max_tokens?: number | undefined;
|
|
80
|
+
readonly tools?: readonly {
|
|
81
|
+
readonly function: {
|
|
82
|
+
readonly description: string;
|
|
83
|
+
readonly name: string;
|
|
84
|
+
readonly parameters: {
|
|
85
|
+
readonly [x: string]: unknown;
|
|
86
|
+
};
|
|
87
|
+
readonly strict?: boolean | undefined;
|
|
88
|
+
};
|
|
89
|
+
readonly type: "function";
|
|
90
|
+
readonly cache_control?: {
|
|
91
|
+
readonly type: "ephemeral";
|
|
92
|
+
readonly ttl?: string | undefined;
|
|
93
|
+
} | undefined;
|
|
94
|
+
}[] | undefined;
|
|
95
|
+
readonly stop?: readonly string[] | undefined;
|
|
96
|
+
readonly temperature?: number | undefined;
|
|
97
|
+
readonly seed?: number | undefined;
|
|
98
|
+
readonly tool_choice?: "required" | "auto" | "none" | {
|
|
99
|
+
readonly type: "function";
|
|
100
|
+
readonly function: {
|
|
101
|
+
readonly name: string;
|
|
102
|
+
};
|
|
103
|
+
} | undefined;
|
|
104
|
+
readonly top_p?: number | undefined;
|
|
105
|
+
readonly store?: boolean | undefined;
|
|
106
|
+
readonly stream_options?: {
|
|
107
|
+
readonly include_usage: boolean;
|
|
108
|
+
} | undefined;
|
|
109
|
+
readonly prompt_cache_key?: string | undefined;
|
|
110
|
+
readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
111
|
+
readonly tool_stream?: boolean | undefined;
|
|
112
|
+
readonly frequency_penalty?: number | undefined;
|
|
113
|
+
readonly presence_penalty?: number | undefined;
|
|
114
|
+
}, import("../route/transport/http.js").HttpPrepared<string>>;
|
|
115
|
+
export declare const routes: import("../route/client.js").Route<{
|
|
116
|
+
readonly model: string;
|
|
117
|
+
readonly messages: readonly ({
|
|
118
|
+
readonly role: "system";
|
|
119
|
+
readonly content: string | readonly ({
|
|
120
|
+
readonly type: "text";
|
|
121
|
+
readonly text: string;
|
|
122
|
+
readonly cache_control?: {
|
|
123
|
+
readonly type: "ephemeral";
|
|
124
|
+
readonly ttl?: string | undefined;
|
|
125
|
+
} | undefined;
|
|
126
|
+
} | {
|
|
127
|
+
readonly type: "image_url";
|
|
128
|
+
readonly image_url: {
|
|
129
|
+
readonly url: string;
|
|
130
|
+
};
|
|
131
|
+
})[];
|
|
132
|
+
} | {
|
|
133
|
+
readonly role: "user";
|
|
134
|
+
readonly content: string | readonly ({
|
|
135
|
+
readonly type: "text";
|
|
136
|
+
readonly text: string;
|
|
137
|
+
readonly cache_control?: {
|
|
138
|
+
readonly type: "ephemeral";
|
|
139
|
+
readonly ttl?: string | undefined;
|
|
140
|
+
} | undefined;
|
|
141
|
+
} | {
|
|
142
|
+
readonly type: "image_url";
|
|
143
|
+
readonly image_url: {
|
|
144
|
+
readonly url: string;
|
|
145
|
+
};
|
|
146
|
+
})[];
|
|
147
|
+
} | {
|
|
148
|
+
readonly [x: string]: unknown;
|
|
149
|
+
readonly content: string | null;
|
|
150
|
+
readonly role: "assistant";
|
|
151
|
+
readonly reasoning?: string | undefined;
|
|
152
|
+
readonly reasoning_content?: string | undefined;
|
|
153
|
+
readonly reasoning_text?: string | undefined;
|
|
154
|
+
readonly cache_control?: {
|
|
155
|
+
readonly type: "ephemeral";
|
|
156
|
+
readonly ttl?: string | undefined;
|
|
157
|
+
} | undefined;
|
|
158
|
+
readonly tool_calls?: readonly {
|
|
159
|
+
readonly id: string;
|
|
160
|
+
readonly type: "function";
|
|
161
|
+
readonly function: {
|
|
162
|
+
readonly name: string;
|
|
163
|
+
readonly arguments: string;
|
|
164
|
+
};
|
|
165
|
+
}[] | undefined;
|
|
166
|
+
readonly reasoning_details?: unknown;
|
|
167
|
+
} | {
|
|
168
|
+
readonly content: string;
|
|
169
|
+
readonly role: "tool";
|
|
170
|
+
readonly tool_call_id: string;
|
|
171
|
+
readonly cache_control?: {
|
|
172
|
+
readonly type: "ephemeral";
|
|
173
|
+
readonly ttl?: string | undefined;
|
|
174
|
+
} | undefined;
|
|
175
|
+
})[];
|
|
176
|
+
readonly stream: true;
|
|
177
|
+
readonly max_completion_tokens?: number | undefined;
|
|
178
|
+
readonly max_tokens?: number | undefined;
|
|
179
|
+
readonly tools?: readonly {
|
|
180
|
+
readonly function: {
|
|
181
|
+
readonly description: string;
|
|
182
|
+
readonly name: string;
|
|
183
|
+
readonly parameters: {
|
|
184
|
+
readonly [x: string]: unknown;
|
|
185
|
+
};
|
|
186
|
+
readonly strict?: boolean | undefined;
|
|
187
|
+
};
|
|
188
|
+
readonly type: "function";
|
|
189
|
+
readonly cache_control?: {
|
|
190
|
+
readonly type: "ephemeral";
|
|
191
|
+
readonly ttl?: string | undefined;
|
|
192
|
+
} | undefined;
|
|
193
|
+
}[] | undefined;
|
|
194
|
+
readonly stop?: readonly string[] | undefined;
|
|
195
|
+
readonly temperature?: number | undefined;
|
|
196
|
+
readonly seed?: number | undefined;
|
|
197
|
+
readonly tool_choice?: "required" | "auto" | "none" | {
|
|
198
|
+
readonly type: "function";
|
|
199
|
+
readonly function: {
|
|
200
|
+
readonly name: string;
|
|
201
|
+
};
|
|
202
|
+
} | undefined;
|
|
203
|
+
readonly top_p?: number | undefined;
|
|
204
|
+
readonly store?: boolean | undefined;
|
|
205
|
+
readonly stream_options?: {
|
|
206
|
+
readonly include_usage: boolean;
|
|
207
|
+
} | undefined;
|
|
208
|
+
readonly prompt_cache_key?: string | undefined;
|
|
209
|
+
readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
210
|
+
readonly tool_stream?: boolean | undefined;
|
|
211
|
+
readonly frequency_penalty?: number | undefined;
|
|
212
|
+
readonly presence_penalty?: number | undefined;
|
|
213
|
+
}, import("../route/transport/http.js").HttpPrepared<string>>[];
|
|
214
|
+
export declare const configure: (input?: LanguageModelOptions) => {
|
|
215
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
216
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
|
|
217
|
+
configure: (input?: LanguageModelOptions) => /*elided*/ any;
|
|
218
|
+
};
|
|
219
|
+
export declare const provider: {
|
|
220
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
221
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
|
|
222
|
+
configure: (input?: LanguageModelOptions) => {
|
|
223
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
224
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput>;
|
|
225
|
+
configure: /*elided*/ any;
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
export declare const model: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { OpenAICompatibleChat } from "../protocols/openai-compatible-chat.js";
|
|
2
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
3
|
+
import { ProviderID } from "../schema/index.js";
|
|
4
|
+
import { profiles } from "./openai-compatible-profile.js";
|
|
5
|
+
export const id = ProviderID.make("togetherai");
|
|
6
|
+
export const route = OpenAICompatibleChat.route.with({
|
|
7
|
+
id: "togetherai-chat",
|
|
8
|
+
provider: id,
|
|
9
|
+
endpoint: { baseURL: profiles.togetherai.baseURL },
|
|
10
|
+
});
|
|
11
|
+
export const routes = [route];
|
|
12
|
+
export const configure = (input = {}) => {
|
|
13
|
+
const { apiKey: _apiKey, auth: _auth, baseURL, ...defaults } = input;
|
|
14
|
+
const configured = route.with({
|
|
15
|
+
...defaults,
|
|
16
|
+
endpoint: { baseURL: baseURL ?? profiles.togetherai.baseURL },
|
|
17
|
+
auth: AuthOptions.bearer(input, ["TOGETHER_API_KEY", "TOGETHER_AI_API_KEY"]),
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
id,
|
|
21
|
+
model: (modelID) => configured.model({
|
|
22
|
+
id: modelID,
|
|
23
|
+
compatibility: { maxTokensField: "max_tokens", supportsStore: false, supportsStrictMode: false },
|
|
24
|
+
}),
|
|
25
|
+
configure,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export const provider = configure();
|
|
29
|
+
export const model = (modelID, settings) => configure({
|
|
30
|
+
apiKey: settings.apiKey,
|
|
31
|
+
baseURL: settings.baseURL,
|
|
32
|
+
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
33
|
+
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
34
|
+
providerOptions: settings.providerOptions,
|
|
35
|
+
}).model(modelID);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-18245",
|
|
4
4
|
"name": "@opencode-ai/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
32
32
|
"@effect/platform-node": "4.0.0-rc.111",
|
|
33
|
-
"@opencode-ai/http-recorder": "0.0.0-dev-
|
|
33
|
+
"@opencode-ai/http-recorder": "0.0.0-dev-18245",
|
|
34
34
|
"@tsconfig/bun": "1.0.9",
|
|
35
35
|
"@types/bun": "1.3.13",
|
|
36
36
|
"@typescript/native-preview": "7.0.0-dev.20251207.1",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@smithy/eventstream-codec": "4.2.14",
|
|
41
41
|
"@smithy/util-utf8": "4.2.2",
|
|
42
|
-
"@opencode-ai/schema": "0.0.0-dev-
|
|
42
|
+
"@opencode-ai/schema": "0.0.0-dev-18245",
|
|
43
43
|
"aws4fetch": "1.0.20",
|
|
44
44
|
"effect": "4.0.0-rc.111",
|
|
45
45
|
"google-auth-library": "10.5.0"
|