@opencode/ai 0.0.0-dev-491 → 0.0.0-dev-513
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/anthropic-messages.js +35 -89
- package/dist/protocols/bedrock-converse.js +2 -3
- package/dist/protocols/gemini.js +26 -40
- package/dist/protocols/open-responses-channel.js +6 -19
- package/dist/protocols/open-responses-continuation.d.ts +1 -5
- package/dist/protocols/open-responses-continuation.js +1 -3
- package/dist/protocols/utils/bedrock-cache.js +2 -5
- package/dist/protocols/utils/cache.d.ts +3 -0
- package/dist/protocols/utils/cache.js +15 -2
- package/dist/providers/baseten.d.ts +1 -1
- package/dist/providers/baseten.js +5 -11
- package/dist/providers/cerebras.d.ts +1 -1
- package/dist/providers/cerebras.js +2 -8
- package/dist/providers/cloudflare-ai-gateway.js +5 -25
- package/dist/providers/cloudflare-shared.d.ts +9 -0
- package/dist/providers/cloudflare-shared.js +25 -0
- package/dist/providers/cloudflare-workers-ai.js +4 -20
- package/dist/providers/cohere.d.ts +1 -1
- package/dist/providers/cohere.js +4 -6
- package/dist/providers/deepinfra.d.ts +1 -1
- package/dist/providers/deepinfra.js +3 -6
- package/dist/providers/deepseek.d.ts +1 -1
- package/dist/providers/deepseek.js +2 -8
- package/dist/providers/digitalocean.d.ts +1 -1
- package/dist/providers/digitalocean.js +5 -7
- package/dist/providers/fireworks.d.ts +1 -1
- package/dist/providers/fireworks.js +2 -8
- package/dist/providers/google-vertex-chat.js +3 -29
- package/dist/providers/google-vertex-messages.js +3 -29
- package/dist/providers/google-vertex-mistral.js +3 -29
- package/dist/providers/google-vertex-responses.js +3 -29
- package/dist/providers/google-vertex-shared.d.ts +30 -0
- package/dist/providers/google-vertex-shared.js +25 -0
- package/dist/providers/groq.d.ts +1 -1
- package/dist/providers/groq.js +2 -8
- package/dist/providers/meta.d.ts +1 -1
- package/dist/providers/meta.js +2 -8
- package/dist/providers/minimax.d.ts +1 -1
- package/dist/providers/minimax.js +3 -10
- package/dist/providers/mistral.d.ts +1 -1
- package/dist/providers/mistral.js +2 -8
- package/dist/providers/moonshot.d.ts +1 -1
- package/dist/providers/moonshot.js +2 -8
- package/dist/providers/openrouter.d.ts +1 -1
- package/dist/providers/openrouter.js +5 -8
- package/dist/providers/settings.d.ts +21 -0
- package/dist/providers/settings.js +10 -0
- package/dist/providers/togetherai.d.ts +1 -1
- package/dist/providers/togetherai.js +2 -8
- package/dist/providers/vercel-ai-gateway.d.ts +1 -1
- package/dist/providers/vercel-ai-gateway.js +2 -8
- package/dist/providers/zai-coding-plan.d.ts +1 -1
- package/dist/providers/zai-coding-plan.js +2 -8
- package/dist/providers/zai.d.ts +1 -1
- package/dist/providers/zai.js +4 -12
- package/dist/schema/events.js +31 -64
- package/package.json +3 -3
|
@@ -6,29 +6,13 @@ import { AuthOptions } from "../route/auth-options.js";
|
|
|
6
6
|
import { Route } from "../route/client.js";
|
|
7
7
|
import { Endpoint } from "../route/endpoint.js";
|
|
8
8
|
import { MediaRoute } from "../route/media.js";
|
|
9
|
-
import {
|
|
9
|
+
import { ProviderID } from "../schema/index.js";
|
|
10
|
+
import { CloudflareShared } from "./cloudflare-shared.js";
|
|
10
11
|
export const id = ProviderID.make("cloudflare-workers-ai");
|
|
11
12
|
export const authEnvVars = ["CLOUDFLARE_API_KEY", "CLOUDFLARE_WORKERS_AI_TOKEN", "CLOUDFLARE_API_TOKEN"];
|
|
12
|
-
export const baseURL = (input) =>
|
|
13
|
-
if (input.baseURL)
|
|
14
|
-
return input.baseURL;
|
|
15
|
-
if (!input.accountId)
|
|
16
|
-
throw new ProviderConfigurationError({
|
|
17
|
-
provider: id,
|
|
18
|
-
message: "CloudflareWorkersAI.configure requires accountId unless baseURL is supplied",
|
|
19
|
-
});
|
|
20
|
-
return `https://api.cloudflare.com/client/v4/accounts/${encodeURIComponent(input.accountId)}/ai/v1`;
|
|
21
|
-
};
|
|
13
|
+
export const baseURL = (input) => CloudflareShared.baseURL(input, id, "CloudflareWorkersAI");
|
|
22
14
|
/** The Run API (`/ai/run`) next to the OpenAI-compatible `/ai/v1` base. */
|
|
23
|
-
export const runBaseURL = (input) =>
|
|
24
|
-
const url = Endpoint.trimBaseUrl(baseURL(input));
|
|
25
|
-
if (!url.endsWith("/ai/v1"))
|
|
26
|
-
throw new ProviderConfigurationError({
|
|
27
|
-
provider: id,
|
|
28
|
-
message: "CloudflareWorkersAI needs accountId or a baseURL ending in /ai/v1 to derive the Run API base",
|
|
29
|
-
});
|
|
30
|
-
return `${url.slice(0, -"/v1".length)}/run`;
|
|
31
|
-
};
|
|
15
|
+
export const runBaseURL = (input) => CloudflareShared.runBaseURL(input, id, "CloudflareWorkersAI");
|
|
32
16
|
export const route = Route.make({
|
|
33
17
|
id: "cloudflare-workers-ai",
|
|
34
18
|
provider: id,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CohereChat } from "../protocols/cohere-chat.js";
|
|
2
2
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
3
|
-
import {
|
|
3
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
4
4
|
import { type ModelID, type OpenString } from "../schema/index.js";
|
|
5
5
|
import type { ProviderPackage } from "../provider-package.js";
|
|
6
6
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
package/dist/providers/cohere.js
CHANGED
|
@@ -2,9 +2,8 @@ import { CohereChat } from "../protocols/cohere-chat.js";
|
|
|
2
2
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
3
3
|
import { Route } from "../route/client.js";
|
|
4
4
|
import { Endpoint } from "../route/endpoint.js";
|
|
5
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
6
5
|
import { ProviderID } from "../schema/index.js";
|
|
7
|
-
import { toConfig } from "./settings.js";
|
|
6
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
8
7
|
export const id = ProviderID.make("cohere");
|
|
9
8
|
const COMPATIBILITY_BASE_URL = "https://api.cohere.ai/compatibility/v1";
|
|
10
9
|
export const route = CohereChat.route;
|
|
@@ -18,10 +17,9 @@ export const chatRoute = Route.make({
|
|
|
18
17
|
});
|
|
19
18
|
export const routes = [route, chatRoute];
|
|
20
19
|
export const configure = (input = {}) => {
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const chat = chatRoute.with({ ...defaults, auth, endpoint: { baseURL: baseURL ?? COMPATIBILITY_BASE_URL } });
|
|
20
|
+
const options = bearerRouteDefaults(input, "COHERE_API_KEY", CohereChat.DEFAULT_BASE_URL);
|
|
21
|
+
const native = route.with(options);
|
|
22
|
+
const chat = chatRoute.with({ ...options, endpoint: { baseURL: input.baseURL ?? COMPATIBILITY_BASE_URL } });
|
|
25
23
|
return {
|
|
26
24
|
id,
|
|
27
25
|
model: (modelID) => native.model({ id: modelID }),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
-
import {
|
|
2
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
3
3
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
4
4
|
import { type ModelID } from "../schema/index.js";
|
|
5
5
|
import type { OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
2
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
3
2
|
import { Route } from "../route/client.js";
|
|
4
3
|
import { Endpoint } from "../route/endpoint.js";
|
|
5
4
|
import { ProviderID } from "../schema/index.js";
|
|
6
|
-
import { toConfig } from "./settings.js";
|
|
5
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
7
6
|
export const id = ProviderID.make("deepinfra");
|
|
8
7
|
const baseURL = "https://api.deepinfra.com/v1/openai";
|
|
9
8
|
export const route = Route.make({
|
|
@@ -16,14 +15,12 @@ export const route = Route.make({
|
|
|
16
15
|
});
|
|
17
16
|
export const routes = [route];
|
|
18
17
|
export const configure = (input = {}) => {
|
|
19
|
-
const
|
|
20
|
-
const root = endpoint?.replace(/\/+$/, "");
|
|
18
|
+
const root = input.baseURL?.replace(/\/+$/, "");
|
|
21
19
|
const configured = route.with({
|
|
22
|
-
...
|
|
20
|
+
...bearerRouteDefaults(input, "DEEPINFRA_API_KEY"),
|
|
23
21
|
endpoint: {
|
|
24
22
|
baseURL: root === undefined ? baseURL : root.endsWith("/openai") ? root : `${root}/openai`,
|
|
25
23
|
},
|
|
26
|
-
auth: AuthOptions.bearer(input, "DEEPINFRA_API_KEY"),
|
|
27
24
|
});
|
|
28
25
|
return {
|
|
29
26
|
id,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
-
import {
|
|
2
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
3
3
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
4
4
|
import { type ModelID } from "../schema/index.js";
|
|
5
5
|
import type { OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
2
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
3
2
|
import { Route } from "../route/client.js";
|
|
4
3
|
import { Endpoint } from "../route/endpoint.js";
|
|
5
4
|
import { ProviderID } from "../schema/index.js";
|
|
6
|
-
import { toConfig } from "./settings.js";
|
|
5
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
7
6
|
export const id = ProviderID.make("deepseek");
|
|
8
7
|
const baseURL = "https://api.deepseek.com/v1";
|
|
9
8
|
export const route = Route.make({
|
|
@@ -16,12 +15,7 @@ export const route = Route.make({
|
|
|
16
15
|
});
|
|
17
16
|
export const routes = [route];
|
|
18
17
|
export const configure = (input = {}) => {
|
|
19
|
-
const
|
|
20
|
-
const configured = route.with({
|
|
21
|
-
...defaults,
|
|
22
|
-
endpoint: { baseURL: endpoint ?? baseURL },
|
|
23
|
-
auth: AuthOptions.bearer(input, "DEEPSEEK_API_KEY"),
|
|
24
|
-
});
|
|
18
|
+
const configured = route.with(bearerRouteDefaults(input, "DEEPSEEK_API_KEY", baseURL));
|
|
25
19
|
return {
|
|
26
20
|
id,
|
|
27
21
|
model: (modelID) => configured.model({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
2
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
3
|
-
import {
|
|
3
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
4
4
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
5
5
|
import { Protocol } from "../route/protocol.js";
|
|
6
6
|
import { type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
@@ -3,12 +3,12 @@ import { OpenAIImages } from "../protocols/openai-images.js";
|
|
|
3
3
|
import { OpenResponses } from "../protocols/open-responses.js";
|
|
4
4
|
import { SystemOne } from "../protocols/system-one.js";
|
|
5
5
|
import { cacheControl } from "../protocols/utils/cache.js";
|
|
6
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
7
6
|
import { Route } from "../route/client.js";
|
|
8
7
|
import { Endpoint } from "../route/endpoint.js";
|
|
9
8
|
import { MediaRoute } from "../route/media.js";
|
|
10
9
|
import { Protocol } from "../route/protocol.js";
|
|
11
10
|
import { ProviderID } from "../schema/index.js";
|
|
11
|
+
import { bearerRouteDefaults } from "./settings.js";
|
|
12
12
|
export const id = ProviderID.make("digitalocean");
|
|
13
13
|
const baseURL = "https://inference.do-ai.run/v1";
|
|
14
14
|
export const protocol = Protocol.make({
|
|
@@ -38,22 +38,20 @@ const responsesRoute = Route.make({
|
|
|
38
38
|
});
|
|
39
39
|
export const routes = [route, responsesRoute];
|
|
40
40
|
export const configure = (input = {}) => {
|
|
41
|
-
const
|
|
42
|
-
const auth = AuthOptions.bearer(input, ["DIGITALOCEAN_ACCESS_TOKEN", "DIGITALOCEAN_API_KEY", "DO_INFERENCE_API_KEY"]);
|
|
43
|
-
const options = { ...defaults, endpoint: { baseURL: endpoint ?? baseURL }, auth };
|
|
41
|
+
const options = bearerRouteDefaults(input, ["DIGITALOCEAN_ACCESS_TOKEN", "DIGITALOCEAN_API_KEY", "DO_INFERENCE_API_KEY"], baseURL);
|
|
44
42
|
const configured = route.with(options);
|
|
45
43
|
const configuredResponses = responsesRoute.with(options);
|
|
46
44
|
const decisionRoute = SystemOne.route.with({
|
|
47
45
|
provider: id,
|
|
48
46
|
providerMetadataKey: "digitalocean",
|
|
49
|
-
endpoint:
|
|
50
|
-
auth,
|
|
47
|
+
endpoint: options.endpoint,
|
|
48
|
+
auth: options.auth,
|
|
51
49
|
// DigitalOcean serves TypeSafe's Jev, which needs this header for images.
|
|
52
50
|
headers: { "TypeSafe-Danger-Zone-Images": "true", ...input.headers },
|
|
53
51
|
http: input.http,
|
|
54
52
|
});
|
|
55
53
|
const decision = (modelID, providerOptions) => decisionRoute.model({ id: modelID, providerOptions });
|
|
56
|
-
const media = MediaRoute.deployment({ ...input, baseURL: endpoint
|
|
54
|
+
const media = MediaRoute.deployment({ ...input, baseURL: options.endpoint.baseURL }, options.auth);
|
|
57
55
|
const image = (modelID, providerOptions) => OpenAIImages.model({ ...media, id: modelID, provider: id, providerOptions });
|
|
58
56
|
const chat = (modelID) => configured.model({
|
|
59
57
|
id: modelID,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
-
import {
|
|
2
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
3
3
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
4
4
|
import { type ModelID } from "../schema/index.js";
|
|
5
5
|
import type { OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
2
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
3
2
|
import { Route } from "../route/client.js";
|
|
4
3
|
import { Endpoint } from "../route/endpoint.js";
|
|
5
4
|
import { ProviderID } from "../schema/index.js";
|
|
6
|
-
import { toConfig } from "./settings.js";
|
|
5
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
7
6
|
export const id = ProviderID.make("fireworks");
|
|
8
7
|
const baseURL = "https://api.fireworks.ai/inference/v1";
|
|
9
8
|
export const route = Route.make({
|
|
@@ -16,12 +15,7 @@ export const route = Route.make({
|
|
|
16
15
|
});
|
|
17
16
|
export const routes = [route];
|
|
18
17
|
export const configure = (input = {}) => {
|
|
19
|
-
const
|
|
20
|
-
const configured = route.with({
|
|
21
|
-
...defaults,
|
|
22
|
-
endpoint: { baseURL: endpoint ?? baseURL },
|
|
23
|
-
auth: AuthOptions.bearer(input, "FIREWORKS_API_KEY"),
|
|
24
|
-
});
|
|
18
|
+
const configured = route.with(bearerRouteDefaults(input, "FIREWORKS_API_KEY", baseURL));
|
|
25
19
|
return {
|
|
26
20
|
id,
|
|
27
21
|
model: (modelID) => configured.model({ id: modelID, compatibility: { supportsPromptCacheKey: true } }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
2
2
|
import { Route } from "../route/client.js";
|
|
3
3
|
import { Endpoint } from "../route/endpoint.js";
|
|
4
|
-
import {
|
|
4
|
+
import { ProviderID } from "../schema/index.js";
|
|
5
5
|
import { GoogleVertexShared } from "./google-vertex-shared.js";
|
|
6
6
|
export const id = ProviderID.make("google-vertex");
|
|
7
7
|
const route = Route.make({
|
|
@@ -13,21 +13,7 @@ const route = Route.make({
|
|
|
13
13
|
framing: OpenAIChat.framing,
|
|
14
14
|
});
|
|
15
15
|
export const routes = [route];
|
|
16
|
-
const configuredRoute = (input) => {
|
|
17
|
-
if ("apiKey" in input && input.apiKey !== undefined)
|
|
18
|
-
throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Chat does not support API keys" });
|
|
19
|
-
const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
|
|
20
|
-
const location = GoogleVertexShared.location(inputLocation);
|
|
21
|
-
const project = GoogleVertexShared.project(inputProject);
|
|
22
|
-
return route.with({
|
|
23
|
-
...rest,
|
|
24
|
-
endpoint: {
|
|
25
|
-
baseURL: baseURL ??
|
|
26
|
-
`https://aiplatform.googleapis.com/v1/projects/${GoogleVertexShared.requireProject(project)}/locations/${location}/endpoints/openapi`,
|
|
27
|
-
},
|
|
28
|
-
auth: GoogleVertexShared.oauth(input, project),
|
|
29
|
-
});
|
|
30
|
-
};
|
|
16
|
+
const configuredRoute = (input) => GoogleVertexShared.oauthRoute(route, "Chat", input, (project, location) => `https://aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/endpoints/openapi`);
|
|
31
17
|
export const configure = (input = {}) => {
|
|
32
18
|
const route = configuredRoute(input);
|
|
33
19
|
return {
|
|
@@ -40,16 +26,4 @@ export const provider = {
|
|
|
40
26
|
id,
|
|
41
27
|
configure,
|
|
42
28
|
};
|
|
43
|
-
export const model = (modelID,
|
|
44
|
-
if (apiKey !== undefined)
|
|
45
|
-
throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Chat does not support API keys" });
|
|
46
|
-
return configure({
|
|
47
|
-
accessToken,
|
|
48
|
-
baseURL,
|
|
49
|
-
headers,
|
|
50
|
-
http: body === undefined ? undefined : { body },
|
|
51
|
-
location,
|
|
52
|
-
project,
|
|
53
|
-
providerOptions,
|
|
54
|
-
}).model(modelID);
|
|
55
|
-
};
|
|
29
|
+
export const model = (modelID, settings = {}) => configure(GoogleVertexShared.oauthSettings("Chat", settings)).model(modelID);
|
|
@@ -4,7 +4,7 @@ import { Auth } from "../route/auth.js";
|
|
|
4
4
|
import { Route } from "../route/client.js";
|
|
5
5
|
import { Endpoint } from "../route/endpoint.js";
|
|
6
6
|
import { Protocol } from "../route/protocol.js";
|
|
7
|
-
import {
|
|
7
|
+
import { ProviderID } from "../schema/index.js";
|
|
8
8
|
import { GoogleVertexShared } from "./google-vertex-shared.js";
|
|
9
9
|
const VERSION = "vertex-2023-10-16";
|
|
10
10
|
const HEADER_VERSION = "2023-06-01";
|
|
@@ -34,21 +34,7 @@ const route = Route.make({
|
|
|
34
34
|
headers: () => ({ "anthropic-version": HEADER_VERSION }),
|
|
35
35
|
});
|
|
36
36
|
export const routes = [route];
|
|
37
|
-
const configuredRoute = (input) => {
|
|
38
|
-
if ("apiKey" in input && input.apiKey !== undefined)
|
|
39
|
-
throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Messages does not support API keys" });
|
|
40
|
-
const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
|
|
41
|
-
const location = GoogleVertexShared.location(inputLocation);
|
|
42
|
-
const project = GoogleVertexShared.project(inputProject);
|
|
43
|
-
return route.with({
|
|
44
|
-
...rest,
|
|
45
|
-
endpoint: {
|
|
46
|
-
baseURL: baseURL ??
|
|
47
|
-
`https://${GoogleVertexShared.host(location)}/v1/projects/${GoogleVertexShared.requireProject(project)}/locations/${location}/publishers/anthropic/models`,
|
|
48
|
-
},
|
|
49
|
-
auth: GoogleVertexShared.oauth(input, project),
|
|
50
|
-
});
|
|
51
|
-
};
|
|
37
|
+
const configuredRoute = (input) => GoogleVertexShared.oauthRoute(route, "Messages", input, (project, location) => `https://${GoogleVertexShared.host(location)}/v1/projects/${project}/locations/${location}/publishers/anthropic/models`);
|
|
52
38
|
export const configure = (input = {}) => {
|
|
53
39
|
const route = configuredRoute(input);
|
|
54
40
|
return {
|
|
@@ -61,16 +47,4 @@ export const provider = {
|
|
|
61
47
|
id,
|
|
62
48
|
configure,
|
|
63
49
|
};
|
|
64
|
-
export const model = (modelID,
|
|
65
|
-
if (apiKey !== undefined)
|
|
66
|
-
throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Messages does not support API keys" });
|
|
67
|
-
return configure({
|
|
68
|
-
accessToken,
|
|
69
|
-
baseURL,
|
|
70
|
-
headers,
|
|
71
|
-
http: body === undefined ? undefined : { body },
|
|
72
|
-
location,
|
|
73
|
-
project,
|
|
74
|
-
providerOptions,
|
|
75
|
-
}).model(modelID);
|
|
76
|
-
};
|
|
50
|
+
export const model = (modelID, settings = {}) => configure(GoogleVertexShared.oauthSettings("Messages", settings)).model(modelID);
|
|
@@ -5,7 +5,7 @@ import { Route } from "../route/client.js";
|
|
|
5
5
|
import { Endpoint } from "../route/endpoint.js";
|
|
6
6
|
import { Protocol } from "../route/protocol.js";
|
|
7
7
|
import { HttpTransport } from "../route/transport/index.js";
|
|
8
|
-
import {
|
|
8
|
+
import { ProviderID } from "../schema/index.js";
|
|
9
9
|
import { GoogleVertexShared } from "./google-vertex-shared.js";
|
|
10
10
|
export const id = ProviderID.make("google-vertex");
|
|
11
11
|
// Mistral on Vertex takes the Mistral chat body, model included, through the publisher's streamRawPredict method.
|
|
@@ -27,21 +27,7 @@ const route = Route.make({
|
|
|
27
27
|
transport: HttpTransport.sseJson.with().with({ framing: MistralChat.framing }),
|
|
28
28
|
});
|
|
29
29
|
export const routes = [route];
|
|
30
|
-
const configuredRoute = (input) => {
|
|
31
|
-
if ("apiKey" in input && input.apiKey !== undefined)
|
|
32
|
-
throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Mistral does not support API keys" });
|
|
33
|
-
const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
|
|
34
|
-
const location = GoogleVertexShared.location(inputLocation);
|
|
35
|
-
const project = GoogleVertexShared.project(inputProject);
|
|
36
|
-
return route.with({
|
|
37
|
-
...rest,
|
|
38
|
-
endpoint: {
|
|
39
|
-
baseURL: baseURL ??
|
|
40
|
-
`https://${GoogleVertexShared.host(location)}/v1/projects/${GoogleVertexShared.requireProject(project)}/locations/${location}/publishers/mistralai/models`,
|
|
41
|
-
},
|
|
42
|
-
auth: GoogleVertexShared.oauth(input, project),
|
|
43
|
-
});
|
|
44
|
-
};
|
|
30
|
+
const configuredRoute = (input) => GoogleVertexShared.oauthRoute(route, "Mistral", input, (project, location) => `https://${GoogleVertexShared.host(location)}/v1/projects/${project}/locations/${location}/publishers/mistralai/models`);
|
|
45
31
|
export const configure = (input = {}) => {
|
|
46
32
|
const route = configuredRoute(input);
|
|
47
33
|
return {
|
|
@@ -54,16 +40,4 @@ export const provider = {
|
|
|
54
40
|
id,
|
|
55
41
|
configure,
|
|
56
42
|
};
|
|
57
|
-
export const model = (modelID,
|
|
58
|
-
if (apiKey !== undefined)
|
|
59
|
-
throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Mistral does not support API keys" });
|
|
60
|
-
return configure({
|
|
61
|
-
accessToken,
|
|
62
|
-
baseURL,
|
|
63
|
-
headers,
|
|
64
|
-
http: body === undefined ? undefined : { body },
|
|
65
|
-
location,
|
|
66
|
-
project,
|
|
67
|
-
providerOptions,
|
|
68
|
-
}).model(modelID);
|
|
69
|
-
};
|
|
43
|
+
export const model = (modelID, settings = {}) => configure(GoogleVertexShared.oauthSettings("Mistral", settings)).model(modelID);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenResponses } from "../protocols/open-responses.js";
|
|
2
2
|
import { Route } from "../route/client.js";
|
|
3
3
|
import { Endpoint } from "../route/endpoint.js";
|
|
4
|
-
import {
|
|
4
|
+
import { ProviderID } from "../schema/index.js";
|
|
5
5
|
import { GoogleVertexShared } from "./google-vertex-shared.js";
|
|
6
6
|
export const id = ProviderID.make("google-vertex");
|
|
7
7
|
const route = Route.make({
|
|
@@ -14,21 +14,7 @@ const route = Route.make({
|
|
|
14
14
|
defaults: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
|
|
15
15
|
});
|
|
16
16
|
export const routes = [route];
|
|
17
|
-
const configuredRoute = (input) => {
|
|
18
|
-
if ("apiKey" in input && input.apiKey !== undefined)
|
|
19
|
-
throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Responses does not support API keys" });
|
|
20
|
-
const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
|
|
21
|
-
const location = GoogleVertexShared.location(inputLocation);
|
|
22
|
-
const project = GoogleVertexShared.project(inputProject);
|
|
23
|
-
return route.with({
|
|
24
|
-
...rest,
|
|
25
|
-
endpoint: {
|
|
26
|
-
baseURL: baseURL ??
|
|
27
|
-
`https://aiplatform.googleapis.com/v1/projects/${GoogleVertexShared.requireProject(project)}/locations/${location}/endpoints/openapi`,
|
|
28
|
-
},
|
|
29
|
-
auth: GoogleVertexShared.oauth(input, project),
|
|
30
|
-
});
|
|
31
|
-
};
|
|
17
|
+
const configuredRoute = (input) => GoogleVertexShared.oauthRoute(route, "Responses", input, (project, location) => `https://aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/endpoints/openapi`);
|
|
32
18
|
export const configure = (input = {}) => {
|
|
33
19
|
const route = configuredRoute(input);
|
|
34
20
|
return {
|
|
@@ -41,16 +27,4 @@ export const provider = {
|
|
|
41
27
|
id,
|
|
42
28
|
configure,
|
|
43
29
|
};
|
|
44
|
-
export const model = (modelID,
|
|
45
|
-
if (apiKey !== undefined)
|
|
46
|
-
throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Responses does not support API keys" });
|
|
47
|
-
return configure({
|
|
48
|
-
accessToken,
|
|
49
|
-
baseURL,
|
|
50
|
-
headers,
|
|
51
|
-
http: body === undefined ? undefined : { body },
|
|
52
|
-
location,
|
|
53
|
-
project,
|
|
54
|
-
providerOptions,
|
|
55
|
-
}).model(modelID);
|
|
56
|
-
};
|
|
30
|
+
export const model = (modelID, settings = {}) => configure(GoogleVertexShared.oauthSettings("Responses", settings)).model(modelID);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { AnyAuthClient } from "google-auth-library";
|
|
2
|
+
import type { ProviderPackage } from "../provider-package.js";
|
|
2
3
|
import { Auth } from "../route/auth.js";
|
|
4
|
+
import type { CompactionOperations, Route, RouteDefaultsInput } from "../route/client.js";
|
|
3
5
|
export declare const loadADCClient: (project?: string) => Promise<AnyAuthClient>;
|
|
4
6
|
export type OAuthOptions = {
|
|
5
7
|
readonly accessToken?: string;
|
|
@@ -24,4 +26,32 @@ export declare const apiKey: (input: ApiKeyOptions & {
|
|
|
24
26
|
readonly location?: string;
|
|
25
27
|
}) => string | undefined;
|
|
26
28
|
export declare const oauth: (input: OAuthOptions, project?: string) => Auth.Definition;
|
|
29
|
+
export declare const oauthRoute: <Body, Prepared, Compact extends CompactionOperations | undefined>(route: Route<Body, Prepared, Compact>, label: string, input: RouteDefaultsInput & OAuthOptions & {
|
|
30
|
+
readonly baseURL?: string;
|
|
31
|
+
readonly location?: string;
|
|
32
|
+
readonly project?: string;
|
|
33
|
+
}, url: (project: string, location: string) => string) => Route<Body, Prepared, Compact>;
|
|
34
|
+
export declare const oauthSettings: <Options>(label: string, { accessToken, apiKey, baseURL, body, headers, location, project, ...providerOptions }: ProviderPackage.Settings & Options & {
|
|
35
|
+
readonly accessToken?: string;
|
|
36
|
+
readonly apiKey?: never;
|
|
37
|
+
readonly baseURL?: string;
|
|
38
|
+
readonly location?: string;
|
|
39
|
+
readonly project?: string;
|
|
40
|
+
}) => {
|
|
41
|
+
accessToken: string | undefined;
|
|
42
|
+
baseURL: string | undefined;
|
|
43
|
+
headers: Readonly<Record<string, string>> | undefined;
|
|
44
|
+
http: {
|
|
45
|
+
body: Readonly<Record<string, unknown>>;
|
|
46
|
+
} | undefined;
|
|
47
|
+
location: string | undefined;
|
|
48
|
+
project: string | undefined;
|
|
49
|
+
providerOptions: Omit<ProviderPackage.Settings & Options & {
|
|
50
|
+
readonly accessToken?: string;
|
|
51
|
+
readonly apiKey?: never;
|
|
52
|
+
readonly baseURL?: string;
|
|
53
|
+
readonly location?: string;
|
|
54
|
+
readonly project?: string;
|
|
55
|
+
}, "accessToken" | "apiKey" | "baseURL" | "body" | "headers" | "location" | "project">;
|
|
56
|
+
};
|
|
27
57
|
export * as GoogleVertexShared from "./google-vertex-shared.js";
|
|
@@ -101,4 +101,29 @@ export const oauth = (input, project) => {
|
|
|
101
101
|
return Auth.bearer(input.accessToken);
|
|
102
102
|
return adc(project);
|
|
103
103
|
};
|
|
104
|
+
export const oauthRoute = (route, label, input, url) => {
|
|
105
|
+
if ("apiKey" in input && input.apiKey !== undefined)
|
|
106
|
+
throw new ProviderConfigurationError({ provider: id, message: `Google Vertex ${label} does not support API keys` });
|
|
107
|
+
const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
|
|
108
|
+
const resolvedLocation = location(inputLocation);
|
|
109
|
+
const resolvedProject = project(inputProject);
|
|
110
|
+
return route.with({
|
|
111
|
+
...rest,
|
|
112
|
+
endpoint: { baseURL: baseURL ?? url(requireProject(resolvedProject), resolvedLocation) },
|
|
113
|
+
auth: oauth(input, resolvedProject),
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
export const oauthSettings = (label, { accessToken, apiKey, baseURL, body, headers, location, project, ...providerOptions }) => {
|
|
117
|
+
if (apiKey !== undefined)
|
|
118
|
+
throw new ProviderConfigurationError({ provider: id, message: `Google Vertex ${label} does not support API keys` });
|
|
119
|
+
return {
|
|
120
|
+
accessToken,
|
|
121
|
+
baseURL,
|
|
122
|
+
headers,
|
|
123
|
+
http: body === undefined ? undefined : { body },
|
|
124
|
+
location,
|
|
125
|
+
project,
|
|
126
|
+
providerOptions,
|
|
127
|
+
};
|
|
128
|
+
};
|
|
104
129
|
export * as GoogleVertexShared from "./google-vertex-shared.js";
|
package/dist/providers/groq.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
2
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
3
|
-
import {
|
|
3
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
4
4
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
5
5
|
import { Protocol } from "../route/protocol.js";
|
|
6
6
|
import { type ModelID } from "../schema/index.js";
|
package/dist/providers/groq.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
2
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
3
3
|
import { ProviderShared } from "../protocols/shared.js";
|
|
4
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
5
4
|
import { Route } from "../route/client.js";
|
|
6
5
|
import { Endpoint } from "../route/endpoint.js";
|
|
7
6
|
import { Protocol } from "../route/protocol.js";
|
|
8
7
|
import { ProviderID } from "../schema/index.js";
|
|
9
|
-
import { toConfig } from "./settings.js";
|
|
8
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
10
9
|
export const id = ProviderID.make("groq");
|
|
11
10
|
const baseURL = "https://api.groq.com/openai/v1";
|
|
12
11
|
const Options = Schema.Struct({
|
|
@@ -44,12 +43,7 @@ export const route = Route.make({
|
|
|
44
43
|
framing: OpenAIChat.framing,
|
|
45
44
|
});
|
|
46
45
|
export const configure = (input = {}) => {
|
|
47
|
-
const
|
|
48
|
-
const configured = route.with({
|
|
49
|
-
...defaults,
|
|
50
|
-
endpoint: { baseURL: endpoint ?? baseURL },
|
|
51
|
-
auth: AuthOptions.bearer(input, "GROQ_API_KEY"),
|
|
52
|
-
});
|
|
46
|
+
const configured = route.with(bearerRouteDefaults(input, "GROQ_API_KEY", baseURL));
|
|
53
47
|
return {
|
|
54
48
|
id,
|
|
55
49
|
model: (modelID) => configured.model({
|
package/dist/providers/meta.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
2
|
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
3
3
|
import { MetaImages } from "../protocols/meta-images.js";
|
|
4
|
-
import {
|
|
4
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
5
5
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
6
6
|
import { ToolDefinition, type ModelID, type OpenString } from "../schema/index.js";
|
|
7
7
|
import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js";
|
package/dist/providers/meta.js
CHANGED
|
@@ -3,12 +3,11 @@ import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
|
3
3
|
import { MetaResponses } from "../protocols/meta-responses.js";
|
|
4
4
|
import { MetaMessages } from "../protocols/meta-messages.js";
|
|
5
5
|
import { MetaImages } from "../protocols/meta-images.js";
|
|
6
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
7
6
|
import { Route } from "../route/client.js";
|
|
8
7
|
import { Endpoint } from "../route/endpoint.js";
|
|
9
8
|
import { MediaRoute } from "../route/media.js";
|
|
10
9
|
import { ProviderID, ToolDefinition } from "../schema/index.js";
|
|
11
|
-
import { toConfig } from "./settings.js";
|
|
10
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
12
11
|
export const id = ProviderID.make("meta");
|
|
13
12
|
const baseURL = "https://api.meta.ai/v1";
|
|
14
13
|
export const webSearch = (options = {}) => ToolDefinition.make({
|
|
@@ -68,12 +67,7 @@ const messagesRoute = Route.make({
|
|
|
68
67
|
});
|
|
69
68
|
export const routes = [responsesRoute, chatRoute, messagesRoute];
|
|
70
69
|
export const configure = (input = {}) => {
|
|
71
|
-
const
|
|
72
|
-
const options = {
|
|
73
|
-
...defaults,
|
|
74
|
-
endpoint: { baseURL: endpoint ?? baseURL },
|
|
75
|
-
auth: AuthOptions.bearer(input, "META_API_KEY"),
|
|
76
|
-
};
|
|
70
|
+
const options = bearerRouteDefaults(input, "META_API_KEY", baseURL);
|
|
77
71
|
const configuredResponses = responsesRoute.with(options);
|
|
78
72
|
const configuredChat = chatRoute.with(options);
|
|
79
73
|
const configuredMessages = messagesRoute.with(options);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
2
|
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
3
3
|
import { type MiniMaxImageOptions } from "../protocols/minimax-images.js";
|
|
4
|
-
import {
|
|
4
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
5
5
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
6
6
|
import { type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
7
7
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
@@ -4,14 +4,13 @@ import { MiniMaxImages } from "../protocols/minimax-images.js";
|
|
|
4
4
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
5
5
|
import { OpenResponses } from "../protocols/open-responses.js";
|
|
6
6
|
import { ProviderShared } from "../protocols/shared.js";
|
|
7
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
8
7
|
import { Route } from "../route/client.js";
|
|
9
8
|
import { Endpoint } from "../route/endpoint.js";
|
|
10
9
|
import { Framing } from "../route/framing.js";
|
|
11
10
|
import { MediaRoute } from "../route/media.js";
|
|
12
11
|
import { Protocol } from "../route/protocol.js";
|
|
13
12
|
import { ProviderID } from "../schema/index.js";
|
|
14
|
-
import { toConfig } from "./settings.js";
|
|
13
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
15
14
|
export const id = ProviderID.make("minimax");
|
|
16
15
|
const ChatOptions = Schema.Struct({
|
|
17
16
|
thinking: Schema.optional(Schema.Struct({ type: Schema.String })),
|
|
@@ -64,13 +63,7 @@ const responsesRoute = Route.make({
|
|
|
64
63
|
});
|
|
65
64
|
export const routes = [messagesRoute, chatRoute, responsesRoute];
|
|
66
65
|
export const configure = (input = {}) => {
|
|
67
|
-
const
|
|
68
|
-
const auth = AuthOptions.bearer(input, "MINIMAX_API_KEY");
|
|
69
|
-
const defaults = {
|
|
70
|
-
...rest,
|
|
71
|
-
endpoint: baseURL === undefined ? undefined : { baseURL },
|
|
72
|
-
auth,
|
|
73
|
-
};
|
|
66
|
+
const defaults = bearerRouteDefaults(input, "MINIMAX_API_KEY");
|
|
74
67
|
const messages = (modelID) => messagesRoute.with(defaults).model({
|
|
75
68
|
id: modelID,
|
|
76
69
|
compatibility: { requireSignature: false },
|
|
@@ -80,7 +73,7 @@ export const configure = (input = {}) => {
|
|
|
80
73
|
compatibility: { supportsStrictMode: false },
|
|
81
74
|
});
|
|
82
75
|
const responses = (modelID) => responsesRoute.with(defaults).model({ id: modelID });
|
|
83
|
-
const media = MediaRoute.deployment(input, auth);
|
|
76
|
+
const media = MediaRoute.deployment(input, defaults.auth);
|
|
84
77
|
const image = (modelID, providerOptions) => MiniMaxImages.model({ ...media, id: modelID, providerOptions });
|
|
85
78
|
return { id, model: messages, messages, chat, responses, image, configure };
|
|
86
79
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
2
|
import { MistralChat } from "../protocols/mistral-chat.js";
|
|
3
|
-
import {
|
|
3
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
4
4
|
import type { RouteDefaultsInput } from "../route/client.js";
|
|
5
5
|
import { type ModelID } from "../schema/index.js";
|
|
6
6
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|