@opencode/ai 2.2.5 → 2.2.7
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 +228 -72
- package/dist/ai-client.d.ts +2 -2
- package/dist/ai-client.js +2 -1
- package/dist/cache-policy.d.ts +1 -1
- package/dist/cache-policy.js +16 -4
- package/dist/decision-client.d.ts +3 -3
- package/dist/decision.d.ts +30 -125
- package/dist/decision.js +27 -15
- package/dist/effect.d.ts +10 -15
- package/dist/effect.js +6 -6
- package/dist/effort-updates.d.ts +3 -3
- package/dist/effort-updates.js +2 -2
- package/dist/embedding-client.d.ts +21 -0
- package/dist/embedding-client.js +30 -0
- package/dist/embedding.d.ts +111 -0
- package/dist/embedding.js +75 -0
- package/dist/experimental/cloudflare-run-extraction.d.ts +7 -3
- package/dist/experimental/cloudflare-run-extraction.js +4 -1
- package/dist/experimental/extraction.d.ts +10 -40
- package/dist/experimental/extraction.js +14 -13
- package/dist/experimental.d.ts +8 -8
- package/dist/experimental.js +4 -4
- package/dist/generation.d.ts +0 -2
- package/dist/generation.js +2 -2
- package/dist/image-client.d.ts +13 -7
- package/dist/image-client.js +1 -1
- package/dist/image.d.ts +357 -465
- package/dist/image.js +17 -18
- package/dist/index.d.ts +35 -467
- package/dist/index.js +23 -17
- package/dist/llm.d.ts +65 -266
- package/dist/llm.js +101 -92
- package/dist/loop.d.ts +38 -0
- package/dist/loop.js +136 -0
- package/dist/media-model.d.ts +1 -1
- package/dist/media-model.js +8 -6
- package/dist/media.d.ts +9 -0
- package/dist/media.js +37 -2
- package/dist/protocols/alibaba-chat.d.ts +9 -1
- package/dist/protocols/alibaba-chat.js +3 -3
- package/dist/protocols/alibaba-images.d.ts +2 -2
- package/dist/protocols/alibaba-messages.js +3 -3
- package/dist/protocols/alibaba-responses.js +8 -20
- package/dist/protocols/anthropic-messages.d.ts +1 -1
- package/dist/protocols/anthropic-messages.js +57 -176
- package/dist/protocols/assemblyai-transcription.d.ts +2 -2
- package/dist/protocols/bedrock-converse.js +10 -16
- package/dist/protocols/cartesia-speech.d.ts +2 -2
- package/dist/protocols/cloudflare-workers-ai-images.d.ts +2 -2
- package/dist/protocols/cohere-chat.js +9 -12
- package/dist/protocols/deepgram-speech.d.ts +2 -2
- package/dist/protocols/deepgram-transcription.d.ts +2 -2
- package/dist/protocols/elevenlabs-speech.d.ts +2 -2
- package/dist/protocols/elevenlabs-transcription.d.ts +2 -2
- package/dist/protocols/gemini.d.ts +3 -0
- package/dist/protocols/gemini.js +54 -72
- package/dist/protocols/google-embed-content.d.ts +34 -0
- package/dist/protocols/google-embed-content.js +110 -0
- package/dist/protocols/google-images.d.ts +2 -2
- package/dist/protocols/google-interactions.d.ts +3 -4
- package/dist/protocols/google-interactions.js +44 -30
- package/dist/protocols/google-speech.d.ts +2 -2
- package/dist/protocols/google-transcription.d.ts +2 -2
- package/dist/protocols/google-vertex-predict-embeddings.d.ts +18 -0
- package/dist/protocols/google-vertex-predict-embeddings.js +74 -0
- package/dist/protocols/google-video.d.ts +2 -2
- package/dist/protocols/index.d.ts +3 -0
- package/dist/protocols/index.js +3 -0
- package/dist/protocols/meta-images.d.ts +2 -2
- package/dist/protocols/meta-responses.js +26 -23
- package/dist/protocols/minimax-images.d.ts +2 -2
- package/dist/protocols/mistral-chat.js +7 -10
- 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/open-responses.d.ts +2 -22
- package/dist/protocols/open-responses.js +41 -23
- package/dist/protocols/openai-chat.d.ts +27 -23
- package/dist/protocols/openai-chat.js +62 -57
- package/dist/protocols/openai-compatible-chat.d.ts +2 -1
- package/dist/protocols/openai-compatible-responses.d.ts +2 -2
- package/dist/protocols/openai-compatible-responses.js +1 -1
- package/dist/protocols/openai-decisions.js +15 -2
- package/dist/protocols/openai-embeddings.d.ts +16 -0
- package/dist/protocols/openai-embeddings.js +76 -0
- package/dist/protocols/openai-images.d.ts +2 -2
- package/dist/protocols/openai-responses.js +10 -29
- package/dist/protocols/openai-speech.d.ts +2 -2
- package/dist/protocols/openai-transcription.d.ts +2 -2
- package/dist/protocols/runway-video.d.ts +2 -2
- package/dist/protocols/shared.d.ts +14 -7
- package/dist/protocols/shared.js +40 -15
- package/dist/protocols/system-one.d.ts +4 -4
- package/dist/protocols/system-one.js +8 -1
- package/dist/protocols/utils/bedrock-cache.js +2 -5
- package/dist/protocols/utils/bedrock-media.d.ts +0 -3
- package/dist/protocols/utils/cache.d.ts +3 -0
- package/dist/protocols/utils/cache.js +15 -2
- package/dist/protocols/utils/image-sizing.d.ts +1 -1
- package/dist/protocols/utils/responses-checkpoint.js +1 -1
- package/dist/protocols/utils/responses-compaction.d.ts +1 -1
- package/dist/protocols/utils/responses-compaction.js +6 -5
- package/dist/protocols/utils/responses-hosted-tools.d.ts +97 -1
- package/dist/protocols/utils/responses-hosted-tools.js +31 -0
- package/dist/protocols/utils/tool-stream.d.ts +5 -271
- package/dist/protocols/utils/tool-stream.js +3 -13
- package/dist/protocols/venice-chat.d.ts +7 -1
- package/dist/protocols/venice-chat.js +4 -4
- package/dist/protocols/xai-images.d.ts +2 -2
- package/dist/protocols/xai-responses.js +5 -25
- package/dist/protocols/xai-video.d.ts +2 -2
- package/dist/protocols/zai-chat.d.ts +9 -1
- package/dist/protocols/zai-chat.js +1 -1
- package/dist/protocols/zai-images.d.ts +2 -2
- package/dist/protocols/zai-messages.js +3 -3
- package/dist/provider-error.d.ts +0 -1
- package/dist/provider-error.js +7 -80
- package/dist/providers/alibaba/embeddings.d.ts +2 -0
- package/dist/providers/alibaba/embeddings.js +1 -0
- package/dist/providers/alibaba.d.ts +70 -4
- package/dist/providers/alibaba.js +20 -2
- package/dist/providers/amazon-bedrock-mantle.d.ts +7 -3
- package/dist/providers/amazon-bedrock-mantle.js +6 -3
- package/dist/providers/amazon-bedrock.d.ts +6 -7
- package/dist/providers/amazon-bedrock.js +1 -1
- package/dist/providers/anthropic-compatible.d.ts +7 -8
- package/dist/providers/anthropic-compatible.js +2 -5
- package/dist/providers/anthropic.d.ts +8 -9
- package/dist/providers/anthropic.js +2 -7
- package/dist/providers/assemblyai.d.ts +2 -2
- package/dist/providers/assemblyai.js +2 -7
- package/dist/providers/azure/embeddings.d.ts +2 -0
- package/dist/providers/azure/embeddings.js +1 -0
- package/dist/providers/azure/messages.d.ts +2 -0
- package/dist/providers/azure/messages.js +1 -0
- package/dist/providers/azure.d.ts +325 -7
- package/dist/providers/azure.js +40 -9
- package/dist/providers/baseten.d.ts +7 -5
- package/dist/providers/baseten.js +7 -21
- package/dist/providers/cartesia.d.ts +1 -1
- package/dist/providers/cerebras.d.ts +7 -5
- package/dist/providers/cerebras.js +4 -15
- package/dist/providers/cloudflare-ai-gateway.d.ts +23 -13
- package/dist/providers/cloudflare-ai-gateway.js +28 -40
- package/dist/providers/cloudflare-shared.d.ts +9 -0
- package/dist/providers/cloudflare-shared.js +25 -0
- package/dist/providers/cloudflare-workers-ai.d.ts +6 -4
- package/dist/providers/cloudflare-workers-ai.js +4 -20
- package/dist/providers/cohere/chat.js +2 -7
- package/dist/providers/cohere/embeddings.d.ts +2 -0
- package/dist/providers/cohere/embeddings.js +1 -0
- package/dist/providers/cohere.d.ts +14 -5
- package/dist/providers/cohere.js +23 -13
- package/dist/providers/deepgram.d.ts +2 -2
- package/dist/providers/deepgram.js +2 -7
- package/dist/providers/deepinfra/embeddings.d.ts +2 -0
- package/dist/providers/deepinfra/embeddings.js +1 -0
- package/dist/providers/deepinfra.d.ts +10 -5
- package/dist/providers/deepinfra.js +20 -14
- package/dist/providers/deepseek.d.ts +7 -5
- package/dist/providers/deepseek.js +3 -14
- package/dist/providers/digitalocean/embeddings.d.ts +2 -0
- package/dist/providers/digitalocean/embeddings.js +1 -0
- package/dist/providers/digitalocean.d.ts +18 -5
- package/dist/providers/digitalocean.js +28 -14
- package/dist/providers/elevenlabs.d.ts +2 -2
- package/dist/providers/elevenlabs.js +2 -7
- package/dist/providers/fireworks/embeddings.d.ts +2 -0
- package/dist/providers/fireworks/embeddings.js +1 -0
- package/dist/providers/fireworks.d.ts +10 -5
- package/dist/providers/fireworks.js +17 -14
- package/dist/providers/google/embeddings.d.ts +2 -0
- package/dist/providers/google/embeddings.js +1 -0
- package/dist/providers/google/interactions.d.ts +1 -1
- package/dist/providers/google/interactions.js +2 -7
- package/dist/providers/google-vertex/embeddings.d.ts +2 -0
- package/dist/providers/google-vertex/embeddings.js +1 -0
- package/dist/providers/google-vertex-chat.d.ts +4 -3
- package/dist/providers/google-vertex-chat.js +3 -29
- package/dist/providers/google-vertex-interactions.d.ts +3 -3
- package/dist/providers/google-vertex-messages.d.ts +3 -3
- package/dist/providers/google-vertex-messages.js +3 -29
- package/dist/providers/google-vertex-mistral.d.ts +3 -3
- package/dist/providers/google-vertex-mistral.js +3 -29
- package/dist/providers/google-vertex-responses.d.ts +3 -3
- package/dist/providers/google-vertex-responses.js +4 -30
- package/dist/providers/google-vertex-shared.d.ts +31 -0
- package/dist/providers/google-vertex-shared.js +25 -0
- package/dist/providers/google-vertex.d.ts +10 -3
- package/dist/providers/google-vertex.js +52 -0
- package/dist/providers/google.d.ts +21 -13
- package/dist/providers/google.js +23 -19
- package/dist/providers/groq.d.ts +10 -5
- package/dist/providers/groq.js +4 -15
- package/dist/providers/meta.d.ts +6 -5
- package/dist/providers/meta.js +10 -23
- package/dist/providers/minimax/chat.js +2 -7
- package/dist/providers/minimax/responses.js +2 -7
- package/dist/providers/minimax.d.ts +6 -5
- package/dist/providers/minimax.js +7 -22
- package/dist/providers/mistral.d.ts +10 -11
- package/dist/providers/mistral.js +3 -14
- package/dist/providers/moonshot/messages.js +2 -7
- package/dist/providers/moonshot/responses.js +2 -7
- package/dist/providers/moonshot.d.ts +6 -5
- package/dist/providers/moonshot.js +4 -16
- package/dist/providers/openai/embeddings.d.ts +2 -0
- package/dist/providers/openai/embeddings.js +1 -0
- package/dist/providers/openai-compatible/embeddings.d.ts +2 -0
- package/dist/providers/openai-compatible/embeddings.js +1 -0
- package/dist/providers/openai-compatible-responses.d.ts +6 -7
- package/dist/providers/openai-compatible-responses.js +2 -8
- package/dist/providers/openai-compatible.d.ts +10 -7
- package/dist/providers/openai-compatible.js +17 -10
- package/dist/providers/openai.d.ts +11 -4
- package/dist/providers/openai.js +17 -3
- package/dist/providers/opencode.d.ts +4 -4
- package/dist/providers/opencode.js +6 -2
- package/dist/providers/openrouter/embeddings.d.ts +2 -0
- package/dist/providers/openrouter/embeddings.js +1 -0
- package/dist/providers/openrouter.d.ts +24 -5
- package/dist/providers/openrouter.js +31 -24
- package/dist/providers/runway.d.ts +1 -1
- package/dist/providers/settings.d.ts +40 -0
- package/dist/providers/settings.js +19 -0
- package/dist/providers/togetherai.d.ts +7 -5
- package/dist/providers/togetherai.js +5 -15
- package/dist/providers/typesafe-ai.d.ts +4 -4
- package/dist/providers/typesafe-ai.js +6 -2
- package/dist/providers/venice.d.ts +5 -4
- package/dist/providers/venice.js +6 -2
- package/dist/providers/vercel-ai-gateway/embeddings.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/embeddings.js +1 -0
- package/dist/providers/vercel-ai-gateway.d.ts +9 -5
- package/dist/providers/vercel-ai-gateway.js +30 -29
- package/dist/providers/xai.d.ts +5 -4
- package/dist/providers/xai.js +4 -12
- package/dist/providers/zai-coding-plan/messages.js +2 -7
- package/dist/providers/zai-coding-plan/responses.js +2 -7
- package/dist/providers/zai-coding-plan.d.ts +6 -5
- package/dist/providers/zai-coding-plan.js +8 -15
- package/dist/providers/zai.d.ts +6 -5
- package/dist/providers/zai.js +10 -22
- package/dist/public.d.ts +14 -0
- package/dist/public.js +6 -0
- package/dist/route/auth-options.d.ts +9 -5
- package/dist/route/auth-options.js +10 -7
- package/dist/route/client.d.ts +50 -37
- package/dist/route/client.js +42 -53
- package/dist/route/decision.d.ts +8 -8
- package/dist/route/decision.js +3 -3
- package/dist/route/embedding.d.ts +61 -0
- package/dist/route/embedding.js +88 -0
- package/dist/route/executor.d.ts +5 -0
- package/dist/route/executor.js +10 -0
- package/dist/route/index.d.ts +5 -7
- package/dist/route/index.js +1 -1
- package/dist/route/media.d.ts +7 -11
- package/dist/route/media.js +22 -26
- package/dist/route/transport/http.js +6 -5
- package/dist/route/transport/websocket.js +7 -1
- package/dist/schema/errors.d.ts +16 -17
- package/dist/schema/errors.js +63 -12
- package/dist/schema/events.d.ts +2563 -2954
- package/dist/schema/events.js +54 -109
- package/dist/schema/messages.d.ts +194 -137
- package/dist/schema/messages.js +66 -83
- package/dist/schema/options.d.ts +112 -65
- package/dist/schema/options.js +52 -101
- package/dist/speech-client.d.ts +7 -7
- package/dist/speech.d.ts +306 -316
- package/dist/speech.js +16 -14
- package/dist/testing.d.ts +31 -175
- package/dist/testing.js +60 -5
- package/dist/tool-history.d.ts +1 -1
- package/dist/tool-history.js +3 -10
- package/dist/tool-runtime.d.ts +9 -2
- package/dist/tool-runtime.js +17 -31
- package/dist/tool.d.ts +39 -43
- package/dist/tool.js +16 -26
- package/dist/transcription-client.d.ts +7 -7
- package/dist/transcription.d.ts +314 -265
- package/dist/transcription.js +16 -14
- package/dist/utils/provider-codes.d.ts +3 -0
- package/dist/utils/provider-codes.js +41 -0
- package/dist/video-client.d.ts +7 -7
- package/dist/video-client.js +1 -1
- package/dist/video.d.ts +269 -287
- package/dist/video.js +16 -14
- package/package.json +309 -257
- package/dist/experimental/testing.d.ts +0 -3
- package/dist/experimental/testing.js +0 -3
- package/dist/testing/decision.d.ts +0 -16
- package/dist/testing/decision.js +0 -20
- package/dist/testing/image.d.ts +0 -14
- package/dist/testing/image.js +0 -12
- package/dist/testing/media.d.ts +0 -18
- package/dist/testing/media.js +0 -36
- package/dist/testing/script.d.ts +0 -28
- package/dist/testing/script.js +0 -60
- package/dist/testing/speech.d.ts +0 -14
- package/dist/testing/speech.js +0 -12
- package/dist/testing/transcription.d.ts +0 -14
- package/dist/testing/transcription.js +0 -12
- package/dist/testing/video.d.ts +0 -14
- package/dist/testing/video.js +0 -12
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { Auth } from "../route/auth.js";
|
|
2
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
2
3
|
import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
|
|
3
4
|
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
4
5
|
import { AnthropicCompatible } from "./anthropic-compatible.js";
|
|
5
6
|
export const id = ProviderID.make("anthropic");
|
|
6
7
|
export const routes = [AnthropicMessages.route];
|
|
7
|
-
const auth = (options) =>
|
|
8
|
-
if ("auth" in options && options.auth)
|
|
9
|
-
return options.auth;
|
|
10
|
-
return Auth.optional("apiKey" in options ? options.apiKey : undefined, "apiKey")
|
|
11
|
-
.orElse(Auth.config("ANTHROPIC_API_KEY"))
|
|
12
|
-
.pipe(Auth.header("x-api-key"));
|
|
13
|
-
};
|
|
8
|
+
const auth = (options) => AuthOptions.apiKey(options, "ANTHROPIC_API_KEY", Auth.header("x-api-key"));
|
|
14
9
|
export const configure = (input = {}) => {
|
|
15
10
|
const { apiKey: _, auth: _auth, baseURL, ...rest } = input;
|
|
16
11
|
const compatible = AnthropicCompatible.configure({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
2
2
|
import { type HttpOptions, type ModelID } from "../schema/index.js";
|
|
3
3
|
export type { AssemblyAITranscriptionOptions } from "../protocols/assemblyai-transcription.js";
|
|
4
4
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
@@ -6,7 +6,7 @@ export type Config = ProviderAuthOption<"optional"> & {
|
|
|
6
6
|
/** `https://api.eu.assemblyai.com` for the EU region. */
|
|
7
7
|
readonly baseURL?: string;
|
|
8
8
|
readonly headers?: Record<string, string>;
|
|
9
|
-
readonly http?: HttpOptions
|
|
9
|
+
readonly http?: HttpOptions;
|
|
10
10
|
};
|
|
11
11
|
export declare const configure: (input?: Config) => {
|
|
12
12
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { Auth } from "../route/auth.js";
|
|
2
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
2
3
|
import { MediaRoute } from "../route/media.js";
|
|
3
4
|
import { ProviderID } from "../schema/index.js";
|
|
4
5
|
import { AssemblyAITranscription } from "../protocols/assemblyai-transcription.js";
|
|
5
6
|
export const id = ProviderID.make("assemblyai");
|
|
6
7
|
// The key is the whole `authorization` value, without a scheme.
|
|
7
|
-
const auth = (options) =>
|
|
8
|
-
if ("auth" in options && options.auth)
|
|
9
|
-
return options.auth;
|
|
10
|
-
return Auth.optional("apiKey" in options ? options.apiKey : undefined, "apiKey")
|
|
11
|
-
.orElse(Auth.config("ASSEMBLYAI_API_KEY"))
|
|
12
|
-
.pipe(Auth.header("authorization"));
|
|
13
|
-
};
|
|
8
|
+
const auth = (options) => AuthOptions.apiKey(options, "ASSEMBLYAI_API_KEY", Auth.header("authorization"));
|
|
14
9
|
export const configure = (input = {}) => {
|
|
15
10
|
const media = MediaRoute.deployment(input, auth(input));
|
|
16
11
|
const transcription = (modelID) => AssemblyAITranscription.model({ ...media, id: modelID });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { embeddingModel as model } from "../azure.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { messagesModel as model } from "../azure.js";
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { type AtLeastOne, type ProviderAuthOption } from "../route/auth-options.js";
|
|
2
|
-
import type { Route,
|
|
2
|
+
import type { Route, CompactionOperations } from "../route/client.js";
|
|
3
3
|
import type { ProviderPackage } from "../provider-package.js";
|
|
4
|
-
import { type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
4
|
+
import { type ModelID, type ProviderOptions, type RequestOptions } from "../schema/index.js";
|
|
5
|
+
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
5
6
|
import { type OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
6
7
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
7
8
|
type AzureURL = AtLeastOne<{
|
|
8
9
|
readonly resourceName: string;
|
|
9
10
|
readonly baseURL: string;
|
|
10
11
|
}>;
|
|
11
|
-
export type Config = AzureURL &
|
|
12
|
+
export type Config = AzureURL & RequestOptions & ProviderAuthOption<"optional"> & {
|
|
12
13
|
readonly apiVersion?: string;
|
|
13
14
|
readonly queryParams?: Record<string, string>;
|
|
14
15
|
readonly useDeploymentBasedUrls?: boolean;
|
|
15
|
-
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
16
|
+
readonly providerOptions?: OpenAIProviderOptionsInput | AnthropicMessages.ProviderOptionsInput;
|
|
16
17
|
};
|
|
17
|
-
export type Settings = ProviderPackage.Settings &
|
|
18
|
-
readonly apiKey?: string;
|
|
18
|
+
export type Settings<Options = OpenAIProviderOptionsInput> = ProviderPackage.Settings & Options & AzureURL & {
|
|
19
|
+
readonly apiKey?: string | false;
|
|
19
20
|
readonly apiVersion?: string;
|
|
20
21
|
readonly queryParams?: Readonly<Record<string, string>>;
|
|
21
22
|
readonly useDeploymentBasedUrls?: boolean;
|
|
22
23
|
};
|
|
24
|
+
export type MessagesSettings = Settings<AnthropicMessages.ProviderOptionsInput>;
|
|
23
25
|
declare const responsesRoute: Route<{
|
|
24
26
|
readonly model: string;
|
|
25
27
|
readonly input: readonly ({
|
|
@@ -253,6 +255,313 @@ declare const responsesRoute: Route<{
|
|
|
253
255
|
endpoint: import("../route/client.js").CompactOperation;
|
|
254
256
|
}>;
|
|
255
257
|
export declare const routes: (Route<{
|
|
258
|
+
readonly context_management?: {
|
|
259
|
+
readonly edits: readonly {
|
|
260
|
+
readonly type: "compact_20260112";
|
|
261
|
+
readonly trigger?: {
|
|
262
|
+
readonly type: "input_tokens";
|
|
263
|
+
readonly value: number;
|
|
264
|
+
} | undefined;
|
|
265
|
+
readonly pause_after_compaction?: boolean | undefined;
|
|
266
|
+
readonly instructions?: string | undefined;
|
|
267
|
+
}[];
|
|
268
|
+
} | undefined;
|
|
269
|
+
readonly model: string;
|
|
270
|
+
readonly system?: readonly {
|
|
271
|
+
readonly type: "text";
|
|
272
|
+
readonly text: string;
|
|
273
|
+
readonly cache_control?: {
|
|
274
|
+
readonly type: "ephemeral";
|
|
275
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
276
|
+
} | undefined;
|
|
277
|
+
}[] | undefined;
|
|
278
|
+
readonly messages: readonly ({
|
|
279
|
+
readonly role: "user";
|
|
280
|
+
readonly content: readonly ({
|
|
281
|
+
readonly type: "text";
|
|
282
|
+
readonly text: string;
|
|
283
|
+
readonly cache_control?: {
|
|
284
|
+
readonly type: "ephemeral";
|
|
285
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
286
|
+
} | undefined;
|
|
287
|
+
} | {
|
|
288
|
+
readonly type: "image";
|
|
289
|
+
readonly source: {
|
|
290
|
+
readonly type: "base64";
|
|
291
|
+
readonly media_type: string;
|
|
292
|
+
readonly data: string;
|
|
293
|
+
} | {
|
|
294
|
+
readonly type: "url";
|
|
295
|
+
readonly url: string;
|
|
296
|
+
} | {
|
|
297
|
+
readonly type: "file";
|
|
298
|
+
readonly file_id: string;
|
|
299
|
+
};
|
|
300
|
+
readonly cache_control?: {
|
|
301
|
+
readonly type: "ephemeral";
|
|
302
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
303
|
+
} | undefined;
|
|
304
|
+
readonly transformations?: {
|
|
305
|
+
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
306
|
+
} | undefined;
|
|
307
|
+
} | {
|
|
308
|
+
readonly type: "video";
|
|
309
|
+
readonly source: {
|
|
310
|
+
readonly type: "base64";
|
|
311
|
+
readonly media_type: string;
|
|
312
|
+
readonly data: string;
|
|
313
|
+
} | {
|
|
314
|
+
readonly type: "url";
|
|
315
|
+
readonly url: string;
|
|
316
|
+
} | {
|
|
317
|
+
readonly type: "file";
|
|
318
|
+
readonly file_id: string;
|
|
319
|
+
};
|
|
320
|
+
readonly cache_control?: {
|
|
321
|
+
readonly type: "ephemeral";
|
|
322
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
323
|
+
} | undefined;
|
|
324
|
+
} | {
|
|
325
|
+
readonly type: "document";
|
|
326
|
+
readonly source: {
|
|
327
|
+
readonly type: "base64";
|
|
328
|
+
readonly media_type: "application/pdf";
|
|
329
|
+
readonly data: string;
|
|
330
|
+
} | {
|
|
331
|
+
readonly type: "text";
|
|
332
|
+
readonly media_type: "text/plain";
|
|
333
|
+
readonly data: string;
|
|
334
|
+
} | {
|
|
335
|
+
readonly type: "url";
|
|
336
|
+
readonly url: string;
|
|
337
|
+
} | {
|
|
338
|
+
readonly type: "file";
|
|
339
|
+
readonly file_id: string;
|
|
340
|
+
};
|
|
341
|
+
readonly cache_control?: {
|
|
342
|
+
readonly type: "ephemeral";
|
|
343
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
344
|
+
} | undefined;
|
|
345
|
+
readonly title?: string | undefined;
|
|
346
|
+
readonly context?: string | undefined;
|
|
347
|
+
readonly citations?: {
|
|
348
|
+
readonly enabled: boolean;
|
|
349
|
+
} | undefined;
|
|
350
|
+
} | {
|
|
351
|
+
readonly type: "tool_result";
|
|
352
|
+
readonly tool_use_id: string;
|
|
353
|
+
readonly content: string | readonly ({
|
|
354
|
+
readonly type: "text";
|
|
355
|
+
readonly text: string;
|
|
356
|
+
readonly cache_control?: {
|
|
357
|
+
readonly type: "ephemeral";
|
|
358
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
359
|
+
} | undefined;
|
|
360
|
+
} | {
|
|
361
|
+
readonly type: "image";
|
|
362
|
+
readonly source: {
|
|
363
|
+
readonly type: "base64";
|
|
364
|
+
readonly media_type: string;
|
|
365
|
+
readonly data: string;
|
|
366
|
+
} | {
|
|
367
|
+
readonly type: "url";
|
|
368
|
+
readonly url: string;
|
|
369
|
+
} | {
|
|
370
|
+
readonly type: "file";
|
|
371
|
+
readonly file_id: string;
|
|
372
|
+
};
|
|
373
|
+
readonly cache_control?: {
|
|
374
|
+
readonly type: "ephemeral";
|
|
375
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
376
|
+
} | undefined;
|
|
377
|
+
readonly transformations?: {
|
|
378
|
+
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
379
|
+
} | undefined;
|
|
380
|
+
} | {
|
|
381
|
+
readonly type: "video";
|
|
382
|
+
readonly source: {
|
|
383
|
+
readonly type: "base64";
|
|
384
|
+
readonly media_type: string;
|
|
385
|
+
readonly data: string;
|
|
386
|
+
} | {
|
|
387
|
+
readonly type: "url";
|
|
388
|
+
readonly url: string;
|
|
389
|
+
} | {
|
|
390
|
+
readonly type: "file";
|
|
391
|
+
readonly file_id: string;
|
|
392
|
+
};
|
|
393
|
+
readonly cache_control?: {
|
|
394
|
+
readonly type: "ephemeral";
|
|
395
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
396
|
+
} | undefined;
|
|
397
|
+
} | {
|
|
398
|
+
readonly type: "document";
|
|
399
|
+
readonly source: {
|
|
400
|
+
readonly type: "base64";
|
|
401
|
+
readonly media_type: "application/pdf";
|
|
402
|
+
readonly data: string;
|
|
403
|
+
} | {
|
|
404
|
+
readonly type: "text";
|
|
405
|
+
readonly media_type: "text/plain";
|
|
406
|
+
readonly data: string;
|
|
407
|
+
} | {
|
|
408
|
+
readonly type: "url";
|
|
409
|
+
readonly url: string;
|
|
410
|
+
} | {
|
|
411
|
+
readonly type: "file";
|
|
412
|
+
readonly file_id: string;
|
|
413
|
+
};
|
|
414
|
+
readonly cache_control?: {
|
|
415
|
+
readonly type: "ephemeral";
|
|
416
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
417
|
+
} | undefined;
|
|
418
|
+
readonly title?: string | undefined;
|
|
419
|
+
readonly context?: string | undefined;
|
|
420
|
+
readonly citations?: {
|
|
421
|
+
readonly enabled: boolean;
|
|
422
|
+
} | undefined;
|
|
423
|
+
})[];
|
|
424
|
+
readonly is_error?: boolean | undefined;
|
|
425
|
+
readonly cache_control?: {
|
|
426
|
+
readonly type: "ephemeral";
|
|
427
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
428
|
+
} | undefined;
|
|
429
|
+
})[];
|
|
430
|
+
} | {
|
|
431
|
+
readonly role: "assistant";
|
|
432
|
+
readonly content: readonly ({
|
|
433
|
+
readonly type: "compaction";
|
|
434
|
+
readonly content: string | null;
|
|
435
|
+
} | {
|
|
436
|
+
readonly type: "text";
|
|
437
|
+
readonly text: string;
|
|
438
|
+
readonly cache_control?: {
|
|
439
|
+
readonly type: "ephemeral";
|
|
440
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
441
|
+
} | undefined;
|
|
442
|
+
} | {
|
|
443
|
+
readonly type: "thinking";
|
|
444
|
+
readonly thinking: string;
|
|
445
|
+
readonly signature: string;
|
|
446
|
+
readonly cache_control?: {
|
|
447
|
+
readonly type: "ephemeral";
|
|
448
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
449
|
+
} | undefined;
|
|
450
|
+
} | {
|
|
451
|
+
readonly type: "redacted_thinking";
|
|
452
|
+
readonly data: string;
|
|
453
|
+
readonly cache_control?: {
|
|
454
|
+
readonly type: "ephemeral";
|
|
455
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
456
|
+
} | undefined;
|
|
457
|
+
} | {
|
|
458
|
+
readonly type: "tool_use";
|
|
459
|
+
readonly id: string;
|
|
460
|
+
readonly name: string;
|
|
461
|
+
readonly input: unknown;
|
|
462
|
+
readonly cache_control?: {
|
|
463
|
+
readonly type: "ephemeral";
|
|
464
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
465
|
+
} | undefined;
|
|
466
|
+
} | {
|
|
467
|
+
readonly type: "server_tool_use";
|
|
468
|
+
readonly id: string;
|
|
469
|
+
readonly name: string;
|
|
470
|
+
readonly input: unknown;
|
|
471
|
+
readonly cache_control?: {
|
|
472
|
+
readonly type: "ephemeral";
|
|
473
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
474
|
+
} | undefined;
|
|
475
|
+
} | {
|
|
476
|
+
readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
|
|
477
|
+
readonly tool_use_id: string;
|
|
478
|
+
readonly content: unknown;
|
|
479
|
+
readonly cache_control?: {
|
|
480
|
+
readonly type: "ephemeral";
|
|
481
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
482
|
+
} | undefined;
|
|
483
|
+
})[];
|
|
484
|
+
} | {
|
|
485
|
+
readonly role: "system";
|
|
486
|
+
readonly content: readonly {
|
|
487
|
+
readonly type: "text";
|
|
488
|
+
readonly text: string;
|
|
489
|
+
readonly cache_control?: {
|
|
490
|
+
readonly type: "ephemeral";
|
|
491
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
492
|
+
} | undefined;
|
|
493
|
+
}[];
|
|
494
|
+
readonly output_config?: {
|
|
495
|
+
readonly effort: string;
|
|
496
|
+
} | undefined;
|
|
497
|
+
})[];
|
|
498
|
+
readonly tools?: readonly {
|
|
499
|
+
readonly name: string;
|
|
500
|
+
readonly description: string;
|
|
501
|
+
readonly input_schema: {
|
|
502
|
+
readonly [x: string]: unknown;
|
|
503
|
+
};
|
|
504
|
+
readonly cache_control?: {
|
|
505
|
+
readonly type: "ephemeral";
|
|
506
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
507
|
+
} | undefined;
|
|
508
|
+
}[] | undefined;
|
|
509
|
+
readonly tool_choice?: {
|
|
510
|
+
readonly type: "any" | "auto" | "none";
|
|
511
|
+
readonly disable_parallel_tool_use?: boolean | undefined;
|
|
512
|
+
} | {
|
|
513
|
+
readonly type: "tool";
|
|
514
|
+
readonly name: string;
|
|
515
|
+
readonly disable_parallel_tool_use?: boolean | undefined;
|
|
516
|
+
} | undefined;
|
|
517
|
+
readonly stream: true;
|
|
518
|
+
readonly max_tokens: number;
|
|
519
|
+
readonly temperature?: number | undefined;
|
|
520
|
+
readonly top_p?: number | undefined;
|
|
521
|
+
readonly top_k?: number | undefined;
|
|
522
|
+
readonly stop_sequences?: readonly string[] | undefined;
|
|
523
|
+
readonly thinking?: {
|
|
524
|
+
readonly type: "between_tools" | "disabled";
|
|
525
|
+
} | {
|
|
526
|
+
readonly display?: import("../schema/options.js").OpenString<"omitted" | "summarized"> | undefined;
|
|
527
|
+
readonly block_binding?: {
|
|
528
|
+
readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"drop_block" | "error"> | undefined;
|
|
529
|
+
} | undefined;
|
|
530
|
+
readonly type: "enabled";
|
|
531
|
+
readonly budget_tokens: number;
|
|
532
|
+
} | {
|
|
533
|
+
readonly display?: import("../schema/options.js").OpenString<"omitted" | "summarized"> | undefined;
|
|
534
|
+
readonly block_binding?: {
|
|
535
|
+
readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"drop_block" | "error"> | undefined;
|
|
536
|
+
} | undefined;
|
|
537
|
+
readonly type: "adaptive";
|
|
538
|
+
} | undefined;
|
|
539
|
+
readonly output_config?: {
|
|
540
|
+
readonly effort?: string | undefined;
|
|
541
|
+
readonly format?: {
|
|
542
|
+
readonly type: "json_schema";
|
|
543
|
+
readonly schema: {
|
|
544
|
+
readonly [x: string]: unknown;
|
|
545
|
+
};
|
|
546
|
+
} | null | undefined;
|
|
547
|
+
} | undefined;
|
|
548
|
+
readonly cache_control?: {
|
|
549
|
+
readonly type: "ephemeral";
|
|
550
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
551
|
+
} | undefined;
|
|
552
|
+
readonly container?: string | {
|
|
553
|
+
readonly id?: string | null | undefined;
|
|
554
|
+
readonly skills?: readonly {
|
|
555
|
+
readonly [x: string]: unknown;
|
|
556
|
+
}[] | null | undefined;
|
|
557
|
+
} | null | undefined;
|
|
558
|
+
readonly inference_geo?: string | null | undefined;
|
|
559
|
+
readonly metadata?: {
|
|
560
|
+
readonly user_id?: string | null | undefined;
|
|
561
|
+
} | undefined;
|
|
562
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
|
|
563
|
+
readonly speed?: import("../schema/options.js").OpenString<"fast" | "standard"> | undefined;
|
|
564
|
+
}, import("../route/transport/http.js").HttpPrepared<string>, CompactionOperations | undefined> | Route<{
|
|
256
565
|
readonly model: string;
|
|
257
566
|
readonly messages: readonly ({
|
|
258
567
|
readonly role: "system";
|
|
@@ -352,6 +661,7 @@ export declare const routes: (Route<{
|
|
|
352
661
|
readonly reasoning?: string | undefined;
|
|
353
662
|
readonly reasoning_text?: string | undefined;
|
|
354
663
|
readonly reasoning_details?: unknown;
|
|
664
|
+
readonly reasoning_opaque?: string | undefined;
|
|
355
665
|
})[];
|
|
356
666
|
readonly tools?: readonly ({
|
|
357
667
|
readonly type: "function";
|
|
@@ -666,7 +976,9 @@ export declare const configure: (input: Config) => {
|
|
|
666
976
|
endpoint: import("../route/client.js").CompactOperation;
|
|
667
977
|
}>;
|
|
668
978
|
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, CompactionOperations | undefined>;
|
|
979
|
+
messages: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.OptionsInput, CompactionOperations | undefined>;
|
|
669
980
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
981
|
+
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<import("../embedding.js").EmbeddingOptions>;
|
|
670
982
|
configure: typeof configure;
|
|
671
983
|
};
|
|
672
984
|
export declare const provider: {
|
|
@@ -675,8 +987,14 @@ export declare const provider: {
|
|
|
675
987
|
};
|
|
676
988
|
export declare const responsesModel: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput, typeof responsesRoute.compact>;
|
|
677
989
|
export declare const chatModel: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
|
|
990
|
+
export declare const messagesModel: ProviderPackage.Model<MessagesSettings, AnthropicMessages.ProviderOptionsInput>;
|
|
678
991
|
export declare const imageModel: (modelID: string, settings: Settings) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
679
|
-
export declare const
|
|
992
|
+
export declare const embeddingModel: (modelID: string, settings: Settings) => import("../embedding.js").EmbeddingModel<import("../embedding.js").EmbeddingOptions>;
|
|
993
|
+
export declare const model: ProviderPackage.Model<Settings<import("./openai-options.js").OpenAIOptionsInput>, import("./openai-options.js").OpenAIOptionsInput, {
|
|
994
|
+
endpoint: import("../route/client.js").CompactOperation;
|
|
995
|
+
}>;
|
|
996
|
+
export declare const responses: ProviderPackage.Model<Settings<import("./openai-options.js").OpenAIOptionsInput>, import("./openai-options.js").OpenAIOptionsInput, {
|
|
680
997
|
endpoint: import("../route/client.js").CompactOperation;
|
|
681
998
|
}>;
|
|
999
|
+
export declare const chat: ProviderPackage.Model<Settings<import("./openai-options.js").OpenAIOptionsInput>, import("./openai-options.js").OpenAIOptionsInput, CompactionOperations | undefined>;
|
|
682
1000
|
export {};
|
package/dist/providers/azure.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Auth } from "../route/auth.js";
|
|
2
|
-
import {} from "../route/auth-options.js";
|
|
2
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
3
3
|
import { Endpoint } from "../route/endpoint.js";
|
|
4
4
|
import { MediaRoute } from "../route/media.js";
|
|
5
|
-
import {
|
|
5
|
+
import { ProviderConfigurationError, ProviderID, } from "../schema/index.js";
|
|
6
|
+
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
6
7
|
import { OpenAIImages } from "../protocols/openai-images.js";
|
|
8
|
+
import { OpenAIEmbeddings } from "../protocols/openai-embeddings.js";
|
|
7
9
|
import * as OpenAIChat from "../protocols/openai-chat.js";
|
|
8
10
|
import * as OpenAIResponses from "../protocols/openai-responses.js";
|
|
9
11
|
import { withOpenAIOptions } from "./openai-options.js";
|
|
@@ -39,7 +41,10 @@ const chatRoute = OpenAIChat.route.with({
|
|
|
39
41
|
provider: id,
|
|
40
42
|
auth: routeAuth,
|
|
41
43
|
});
|
|
42
|
-
|
|
44
|
+
// Claude on Foundry serves Anthropic Messages under the resource's `services.ai.azure.com` host and accepts the
|
|
45
|
+
// resource key as `x-api-key`; it rejects `api-key`.
|
|
46
|
+
const messagesRoute = AnthropicMessages.route.with({ id: "azure-anthropic-messages", provider: id });
|
|
47
|
+
export const routes = [responsesRoute, chatRoute, messagesRoute];
|
|
43
48
|
const defaults = (input) => {
|
|
44
49
|
const { apiKey: _, apiVersion: _apiVersion, resourceName: _resourceName, useDeploymentBasedUrls: _useDeploymentBasedUrls, baseURL: _baseURL, queryParams: _queryParams, ...rest } = input;
|
|
45
50
|
if ("auth" in rest) {
|
|
@@ -48,12 +53,10 @@ const defaults = (input) => {
|
|
|
48
53
|
}
|
|
49
54
|
return rest;
|
|
50
55
|
};
|
|
51
|
-
const auth = (input) => {
|
|
56
|
+
const auth = (input, header = "api-key") => {
|
|
52
57
|
if ("auth" in input && input.auth)
|
|
53
58
|
return input.auth;
|
|
54
|
-
return Auth.remove("authorization").andThen(
|
|
55
|
-
.orElse(Auth.config("AZURE_OPENAI_API_KEY"))
|
|
56
|
-
.pipe(Auth.header("api-key")));
|
|
59
|
+
return Auth.remove("authorization").andThen(AuthOptions.apiKey(input, "AZURE_OPENAI_API_KEY", Auth.header(header)));
|
|
57
60
|
};
|
|
58
61
|
const configuredRoute = (route, input, modelID) => route.with({
|
|
59
62
|
auth: auth(input),
|
|
@@ -76,7 +79,17 @@ export const configure = (input) => {
|
|
|
76
79
|
.model({ id: modelID });
|
|
77
80
|
const chat = (modelID) => configuredRoute(chatRoute, input, modelID)
|
|
78
81
|
.with(withOpenAIOptions(modelID, modelDefaults))
|
|
79
|
-
.model({ id: modelID,
|
|
82
|
+
.model({ id: modelID, capabilities: { promptCacheKey: true } });
|
|
83
|
+
const messages = (modelID) => messagesRoute
|
|
84
|
+
.with({
|
|
85
|
+
...modelDefaults,
|
|
86
|
+
auth: auth(input, "x-api-key"),
|
|
87
|
+
endpoint: {
|
|
88
|
+
baseURL: Endpoint.trimBaseUrl(input.baseURL ?? `https://${input.resourceName.trim()}.services.ai.azure.com/anthropic/v1`),
|
|
89
|
+
query: input.queryParams,
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
.model({ id: modelID });
|
|
80
93
|
const image = (modelID, providerOptions) => {
|
|
81
94
|
const target = endpoint(input, modelID);
|
|
82
95
|
const media = MediaRoute.deployment({ ...input, baseURL: target.baseURL }, auth(input));
|
|
@@ -85,15 +98,26 @@ export const configure = (input) => {
|
|
|
85
98
|
id: modelID,
|
|
86
99
|
provider: id,
|
|
87
100
|
providerOptions,
|
|
88
|
-
http:
|
|
101
|
+
http: { ...media.http, query: { ...media.http?.query, ...target.query } },
|
|
89
102
|
});
|
|
90
103
|
};
|
|
104
|
+
const embedding = (modelID, providerOptions) => OpenAIEmbeddings.route
|
|
105
|
+
.with({
|
|
106
|
+
provider: id,
|
|
107
|
+
endpoint: endpoint(input, modelID),
|
|
108
|
+
auth: auth(input),
|
|
109
|
+
headers: input.headers,
|
|
110
|
+
http: input.http,
|
|
111
|
+
})
|
|
112
|
+
.model({ id: modelID, providerOptions });
|
|
91
113
|
return {
|
|
92
114
|
id,
|
|
93
115
|
model: responses,
|
|
94
116
|
responses,
|
|
95
117
|
chat,
|
|
118
|
+
messages,
|
|
96
119
|
image,
|
|
120
|
+
embedding,
|
|
97
121
|
configure,
|
|
98
122
|
};
|
|
99
123
|
};
|
|
@@ -119,8 +143,15 @@ const config = ({ apiKey, apiVersion, baseURL, body, headers, queryParams, resou
|
|
|
119
143
|
};
|
|
120
144
|
export const responsesModel = (modelID, settings) => configure(config(settings)).responses(modelID);
|
|
121
145
|
export const chatModel = (modelID, settings) => configure(config(settings)).chat(modelID);
|
|
146
|
+
export const messagesModel = (modelID, settings) => configure(config(settings)).messages(modelID);
|
|
122
147
|
export const imageModel = (modelID, settings) => {
|
|
123
148
|
const input = config(settings);
|
|
124
149
|
return configure(input).image(modelID, input.providerOptions);
|
|
125
150
|
};
|
|
151
|
+
export const embeddingModel = (modelID, settings) => {
|
|
152
|
+
const input = config(settings);
|
|
153
|
+
return configure(input).embedding(modelID, input.providerOptions);
|
|
154
|
+
};
|
|
126
155
|
export const model = responsesModel;
|
|
156
|
+
export const responses = responsesModel;
|
|
157
|
+
export const chat = chatModel;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
-
import {
|
|
3
|
-
import { Route
|
|
4
|
-
import { type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
2
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
3
|
+
import { Route } from "../route/client.js";
|
|
4
|
+
import { type ModelID, type ProviderOptions, type RequestOptions } from "../schema/index.js";
|
|
5
5
|
import type { OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
6
6
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
7
|
-
export type Config = Omit<
|
|
7
|
+
export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
8
8
|
readonly baseURL?: string;
|
|
9
9
|
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
10
10
|
};
|
|
@@ -13,7 +13,7 @@ export interface BasetenDecisionOptions {
|
|
|
13
13
|
readonly max_len?: number;
|
|
14
14
|
}
|
|
15
15
|
export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
|
|
16
|
-
readonly apiKey?: string;
|
|
16
|
+
readonly apiKey?: string | false;
|
|
17
17
|
readonly baseURL?: string;
|
|
18
18
|
};
|
|
19
19
|
export declare const route: Route<{
|
|
@@ -116,6 +116,7 @@ export declare const route: Route<{
|
|
|
116
116
|
readonly reasoning?: string | undefined;
|
|
117
117
|
readonly reasoning_text?: string | undefined;
|
|
118
118
|
readonly reasoning_details?: unknown;
|
|
119
|
+
readonly reasoning_opaque?: string | undefined;
|
|
119
120
|
})[];
|
|
120
121
|
readonly tools?: readonly ({
|
|
121
122
|
readonly type: "function";
|
|
@@ -290,6 +291,7 @@ export declare const routes: Route<{
|
|
|
290
291
|
readonly reasoning?: string | undefined;
|
|
291
292
|
readonly reasoning_text?: string | undefined;
|
|
292
293
|
readonly reasoning_details?: unknown;
|
|
294
|
+
readonly reasoning_opaque?: string | undefined;
|
|
293
295
|
})[];
|
|
294
296
|
readonly tools?: readonly ({
|
|
295
297
|
readonly type: "function";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
3
3
|
import { SystemOne } from "../protocols/system-one.js";
|
|
4
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
5
4
|
import { Route } from "../route/client.js";
|
|
6
5
|
import { DecisionRoute } from "../route/decision.js";
|
|
7
6
|
import { Endpoint } from "../route/endpoint.js";
|
|
8
7
|
import { ProviderID } from "../schema/index.js";
|
|
8
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
9
9
|
export const id = ProviderID.make("baseten");
|
|
10
10
|
const baseURL = "https://inference.baseten.co/v1";
|
|
11
11
|
export const route = Route.make({
|
|
@@ -27,20 +27,15 @@ const decisionProtocol = DecisionRoute.protocol({
|
|
|
27
27
|
},
|
|
28
28
|
});
|
|
29
29
|
export const configure = (input = {}) => {
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const configured = route.with({
|
|
33
|
-
...defaults,
|
|
34
|
-
endpoint: { baseURL: endpoint ?? baseURL },
|
|
35
|
-
auth,
|
|
36
|
-
});
|
|
30
|
+
const options = bearerRouteDefaults(input, "BASETEN_API_KEY", baseURL);
|
|
31
|
+
const configured = route.with(options);
|
|
37
32
|
const decisionRoute = DecisionRoute.make({
|
|
38
33
|
id: decisionProtocol.id,
|
|
39
34
|
provider: id,
|
|
40
35
|
providerMetadataKey: "baseten",
|
|
41
36
|
protocol: decisionProtocol,
|
|
42
|
-
endpoint: Endpoint.path("/systemone", { baseURL: endpoint
|
|
43
|
-
auth,
|
|
37
|
+
endpoint: Endpoint.path("/systemone", { baseURL: options.endpoint.baseURL }),
|
|
38
|
+
auth: options.auth,
|
|
44
39
|
headers: input.headers,
|
|
45
40
|
http: input.http,
|
|
46
41
|
});
|
|
@@ -54,18 +49,9 @@ export const configure = (input = {}) => {
|
|
|
54
49
|
};
|
|
55
50
|
export const provider = configure();
|
|
56
51
|
export const decision = provider.decision;
|
|
57
|
-
export const model = (modelID, settings) => configure(
|
|
52
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
58
53
|
export const decisionModel = (modelID, settings) => {
|
|
59
|
-
const input =
|
|
54
|
+
const input = toConfig(settings);
|
|
60
55
|
return configure(input).decision(modelID, input.providerOptions);
|
|
61
56
|
};
|
|
62
|
-
function config({ apiKey, baseURL, body, headers, ...providerOptions } = {}) {
|
|
63
|
-
return {
|
|
64
|
-
apiKey,
|
|
65
|
-
baseURL,
|
|
66
|
-
headers,
|
|
67
|
-
http: body === undefined ? undefined : { body },
|
|
68
|
-
providerOptions,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
57
|
export * as Baseten from "./baseten.js";
|
|
@@ -5,7 +5,7 @@ export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
|
5
5
|
export type Config = ProviderAuthOption<"optional"> & {
|
|
6
6
|
readonly baseURL?: string;
|
|
7
7
|
readonly headers?: Record<string, string>;
|
|
8
|
-
readonly http?: HttpOptions
|
|
8
|
+
readonly http?: HttpOptions;
|
|
9
9
|
};
|
|
10
10
|
export declare const configure: (input?: Config) => {
|
|
11
11
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|