@opencode-ai/ai 0.0.0-bootstrap.0 → 0.0.0-next-15617
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 +176 -1
- package/dist/cache-policy.d.ts +2 -0
- package/dist/cache-policy.js +108 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +9 -0
- package/dist/llm.d.ts +223 -0
- package/dist/llm.js +81 -0
- package/dist/protocols/anthropic-messages.d.ts +503 -0
- package/dist/protocols/anthropic-messages.js +745 -0
- package/dist/protocols/bedrock-converse.d.ts +476 -0
- package/dist/protocols/bedrock-converse.js +526 -0
- package/dist/protocols/bedrock-event-stream.d.ts +9 -0
- package/dist/protocols/bedrock-event-stream.js +64 -0
- package/dist/protocols/gemini.d.ts +220 -0
- package/dist/protocols/gemini.js +420 -0
- package/dist/protocols/google-vertex-anthropic.d.ts +494 -0
- package/dist/protocols/google-vertex-anthropic.js +33 -0
- package/dist/protocols/google-vertex-gemini.d.ts +59 -0
- package/dist/protocols/google-vertex-gemini.js +18 -0
- package/dist/protocols/index.d.ts +9 -0
- package/dist/protocols/index.js +9 -0
- package/dist/protocols/openai-chat.d.ts +391 -0
- package/dist/protocols/openai-chat.js +423 -0
- package/dist/protocols/openai-compatible-chat.d.ts +73 -0
- package/dist/protocols/openai-compatible-chat.js +20 -0
- package/dist/protocols/openai-compatible-responses.d.ts +85 -0
- package/dist/protocols/openai-compatible-responses.js +18 -0
- package/dist/protocols/openai-responses.d.ts +613 -0
- package/dist/protocols/openai-responses.js +828 -0
- package/dist/protocols/shared.d.ts +192 -0
- package/dist/protocols/shared.js +236 -0
- package/dist/protocols/utils/bedrock-auth.d.ts +18 -0
- package/dist/protocols/utils/bedrock-auth.js +41 -0
- package/dist/protocols/utils/bedrock-cache.d.ts +15 -0
- package/dist/protocols/utils/bedrock-cache.js +29 -0
- package/dist/protocols/utils/bedrock-media.d.ts +49 -0
- package/dist/protocols/utils/bedrock-media.js +68 -0
- package/dist/protocols/utils/cache.d.ts +6 -0
- package/dist/protocols/utils/cache.js +8 -0
- package/dist/protocols/utils/gemini-tool-schema.d.ts +2 -0
- package/dist/protocols/utils/gemini-tool-schema.js +83 -0
- package/dist/protocols/utils/lifecycle.d.ts +19 -0
- package/dist/protocols/utils/lifecycle.js +65 -0
- package/dist/protocols/utils/openai-options.d.ts +22 -0
- package/dist/protocols/utils/openai-options.js +64 -0
- package/dist/protocols/utils/tool-schema.d.ts +7 -0
- package/dist/protocols/utils/tool-schema.js +79 -0
- package/dist/protocols/utils/tool-stream.d.ts +155 -0
- package/dist/protocols/utils/tool-stream.js +136 -0
- package/dist/protocols.d.ts +1 -0
- package/dist/protocols.js +1 -0
- package/dist/provider-error.d.ts +13 -0
- package/dist/provider-error.js +122 -0
- package/dist/provider-package.d.ts +13 -0
- package/dist/provider-package.js +1 -0
- package/dist/provider.d.ts +23 -0
- package/dist/provider.js +2 -0
- package/dist/providers/amazon-bedrock.d.ts +150 -0
- package/dist/providers/amazon-bedrock.js +41 -0
- package/dist/providers/anthropic-compatible.d.ts +183 -0
- package/dist/providers/anthropic-compatible.js +44 -0
- package/dist/providers/anthropic.d.ts +181 -0
- package/dist/providers/anthropic.js +39 -0
- package/dist/providers/azure/chat.d.ts +2 -0
- package/dist/providers/azure/chat.js +1 -0
- package/dist/providers/azure/responses.d.ts +2 -0
- package/dist/providers/azure/responses.js +1 -0
- package/dist/providers/azure.d.ts +183 -0
- package/dist/providers/azure.js +89 -0
- package/dist/providers/cloudflare.d.ts +232 -0
- package/dist/providers/cloudflare.js +87 -0
- package/dist/providers/github-copilot.d.ts +167 -0
- package/dist/providers/github-copilot.js +47 -0
- package/dist/providers/google-vertex/anthropic.d.ts +2 -0
- package/dist/providers/google-vertex/anthropic.js +1 -0
- package/dist/providers/google-vertex-anthropic.d.ts +181 -0
- package/dist/providers/google-vertex-anthropic.js +46 -0
- package/dist/providers/google-vertex-shared.d.ts +22 -0
- package/dist/providers/google-vertex-shared.js +61 -0
- package/dist/providers/google-vertex.d.ts +93 -0
- package/dist/providers/google-vertex.js +49 -0
- package/dist/providers/google.d.ts +85 -0
- package/dist/providers/google.js +33 -0
- package/dist/providers/index.d.ts +15 -0
- package/dist/providers/index.js +15 -0
- package/dist/providers/openai/chat.d.ts +2 -0
- package/dist/providers/openai/chat.js +1 -0
- package/dist/providers/openai/responses.d.ts +2 -0
- package/dist/providers/openai/responses.js +1 -0
- package/dist/providers/openai-compatible/responses.d.ts +1 -0
- package/dist/providers/openai-compatible/responses.js +1 -0
- package/dist/providers/openai-compatible-profile.d.ts +43 -0
- package/dist/providers/openai-compatible-profile.js +12 -0
- package/dist/providers/openai-compatible-responses.d.ts +107 -0
- package/dist/providers/openai-compatible-responses.js +33 -0
- package/dist/providers/openai-compatible.d.ts +130 -0
- package/dist/providers/openai-compatible.js +55 -0
- package/dist/providers/openai-options.d.ts +30 -0
- package/dist/providers/openai-options.js +42 -0
- package/dist/providers/openai.d.ts +264 -0
- package/dist/providers/openai.js +62 -0
- package/dist/providers/openrouter.d.ts +321 -0
- package/dist/providers/openrouter.js +65 -0
- package/dist/providers/xai.d.ts +169 -0
- package/dist/providers/xai.js +43 -0
- package/dist/providers.d.ts +1 -0
- package/dist/providers.js +1 -0
- package/dist/route/auth-options.d.ts +34 -0
- package/dist/route/auth-options.js +14 -0
- package/dist/route/auth.d.ts +49 -0
- package/dist/route/auth.js +89 -0
- package/dist/route/client.d.ts +330 -0
- package/dist/route/client.js +211 -0
- package/dist/route/endpoint.d.ts +28 -0
- package/dist/route/endpoint.js +21 -0
- package/dist/route/executor.d.ts +12 -0
- package/dist/route/executor.js +229 -0
- package/dist/route/framing.d.ts +23 -0
- package/dist/route/framing.js +4 -0
- package/dist/route/index.d.ts +16 -0
- package/dist/route/index.js +9 -0
- package/dist/route/protocol.d.ts +76 -0
- package/dist/route/protocol.js +17 -0
- package/dist/route/transport/http.d.ts +33 -0
- package/dist/route/transport/http.js +98 -0
- package/dist/route/transport/index.d.ts +27 -0
- package/dist/route/transport/index.js +4 -0
- package/dist/route/transport/websocket.d.ts +56 -0
- package/dist/route/transport/websocket.js +181 -0
- package/dist/route.d.ts +1 -0
- package/dist/route.js +1 -0
- package/dist/schema/errors.d.ts +153 -0
- package/dist/schema/errors.js +150 -0
- package/dist/schema/events.d.ts +4292 -0
- package/dist/schema/events.js +482 -0
- package/dist/schema/ids.d.ts +30 -0
- package/dist/schema/ids.js +18 -0
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.js +5 -0
- package/dist/schema/messages.d.ts +385 -0
- package/dist/schema/messages.js +246 -0
- package/dist/schema/options.d.ts +143 -0
- package/dist/schema/options.js +195 -0
- package/dist/tool-runtime.d.ts +15 -0
- package/dist/tool-runtime.js +35 -0
- package/dist/tool.d.ts +134 -0
- package/dist/tool.js +66 -0
- package/dist/utils/record.d.ts +2 -0
- package/dist/utils/record.js +2 -0
- package/package.json +36 -9
- package/index.js +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const profiles = {
|
|
2
|
+
baseten: { provider: "baseten", baseURL: "https://inference.baseten.co/v1" },
|
|
3
|
+
cerebras: { provider: "cerebras", baseURL: "https://api.cerebras.ai/v1" },
|
|
4
|
+
deepinfra: { provider: "deepinfra", baseURL: "https://api.deepinfra.com/v1/openai" },
|
|
5
|
+
deepseek: { provider: "deepseek", baseURL: "https://api.deepseek.com/v1" },
|
|
6
|
+
fireworks: { provider: "fireworks", baseURL: "https://api.fireworks.ai/inference/v1" },
|
|
7
|
+
groq: { provider: "groq", baseURL: "https://api.groq.com/openai/v1" },
|
|
8
|
+
openrouter: { provider: "openrouter", baseURL: "https://openrouter.ai/api/v1" },
|
|
9
|
+
togetherai: { provider: "togetherai", baseURL: "https://api.together.xyz/v1" },
|
|
10
|
+
xai: { provider: "xai", baseURL: "https://api.x.ai/v1" },
|
|
11
|
+
};
|
|
12
|
+
export const byProvider = Object.fromEntries(Object.values(profiles).map((profile) => [profile.provider, profile]));
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { ProviderPackage } from "../provider-package";
|
|
2
|
+
import { type ProviderAuthOption } from "../route/auth-options";
|
|
3
|
+
import type { RouteDefaultsInput } from "../route/client";
|
|
4
|
+
import { type ModelID } from "../schema";
|
|
5
|
+
import type { OpenAIProviderOptionsInput } from "./openai-options";
|
|
6
|
+
export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
7
|
+
export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
|
|
8
|
+
readonly provider?: string;
|
|
9
|
+
readonly baseURL: string;
|
|
10
|
+
};
|
|
11
|
+
export interface Settings extends ProviderPackage.Settings {
|
|
12
|
+
readonly apiKey?: string;
|
|
13
|
+
readonly baseURL: string;
|
|
14
|
+
readonly provider?: string;
|
|
15
|
+
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
16
|
+
}
|
|
17
|
+
export declare const routes: import("../route").Route<{
|
|
18
|
+
readonly stream: true;
|
|
19
|
+
readonly model: string;
|
|
20
|
+
readonly input: readonly ({
|
|
21
|
+
readonly role: "system";
|
|
22
|
+
readonly content: string;
|
|
23
|
+
} | {
|
|
24
|
+
readonly role: "user";
|
|
25
|
+
readonly content: readonly ({
|
|
26
|
+
readonly type: "input_text";
|
|
27
|
+
readonly text: string;
|
|
28
|
+
} | {
|
|
29
|
+
readonly type: "input_image";
|
|
30
|
+
readonly image_url: string;
|
|
31
|
+
})[];
|
|
32
|
+
} | {
|
|
33
|
+
readonly role: "assistant";
|
|
34
|
+
readonly content: readonly {
|
|
35
|
+
readonly type: "output_text";
|
|
36
|
+
readonly text: string;
|
|
37
|
+
}[];
|
|
38
|
+
} | {
|
|
39
|
+
readonly type: "reasoning";
|
|
40
|
+
readonly summary: readonly {
|
|
41
|
+
readonly type: "summary_text";
|
|
42
|
+
readonly text: string;
|
|
43
|
+
}[];
|
|
44
|
+
readonly id?: string | undefined;
|
|
45
|
+
readonly encrypted_content?: string | null | undefined;
|
|
46
|
+
} | {
|
|
47
|
+
readonly type: "item_reference";
|
|
48
|
+
readonly id: string;
|
|
49
|
+
} | {
|
|
50
|
+
readonly type: "function_call";
|
|
51
|
+
readonly call_id: string;
|
|
52
|
+
readonly name: string;
|
|
53
|
+
readonly arguments: string;
|
|
54
|
+
} | {
|
|
55
|
+
readonly type: "function_call_output";
|
|
56
|
+
readonly call_id: string;
|
|
57
|
+
readonly output: string | readonly ({
|
|
58
|
+
readonly type: "input_text";
|
|
59
|
+
readonly text: string;
|
|
60
|
+
} | {
|
|
61
|
+
readonly type: "input_image";
|
|
62
|
+
readonly image_url: string;
|
|
63
|
+
})[];
|
|
64
|
+
})[];
|
|
65
|
+
readonly instructions?: string | undefined;
|
|
66
|
+
readonly tools?: readonly {
|
|
67
|
+
readonly type: "function";
|
|
68
|
+
readonly name: string;
|
|
69
|
+
readonly description: string;
|
|
70
|
+
readonly parameters: {
|
|
71
|
+
readonly [x: string]: unknown;
|
|
72
|
+
};
|
|
73
|
+
readonly strict?: boolean | undefined;
|
|
74
|
+
}[] | undefined;
|
|
75
|
+
readonly tool_choice?: "required" | "none" | "auto" | {
|
|
76
|
+
readonly type: "function";
|
|
77
|
+
readonly name: string;
|
|
78
|
+
} | undefined;
|
|
79
|
+
readonly store?: boolean | undefined;
|
|
80
|
+
readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
|
|
81
|
+
readonly prompt_cache_key?: string | undefined;
|
|
82
|
+
readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
|
|
83
|
+
readonly reasoning?: {
|
|
84
|
+
readonly effort?: string | undefined;
|
|
85
|
+
readonly summary?: "auto" | undefined;
|
|
86
|
+
} | undefined;
|
|
87
|
+
readonly text?: {
|
|
88
|
+
readonly verbosity?: "low" | "medium" | "high" | undefined;
|
|
89
|
+
} | undefined;
|
|
90
|
+
readonly max_output_tokens?: number | undefined;
|
|
91
|
+
readonly temperature?: number | undefined;
|
|
92
|
+
readonly top_p?: number | undefined;
|
|
93
|
+
}, import("../route/transport/http").HttpPrepared<string>>[];
|
|
94
|
+
export declare const configure: (input: Config) => {
|
|
95
|
+
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
96
|
+
model: (modelID: string | ModelID) => import("..").Model;
|
|
97
|
+
configure: (input: Config) => /*elided*/ any;
|
|
98
|
+
};
|
|
99
|
+
export declare const provider: {
|
|
100
|
+
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
101
|
+
configure: (input: Config) => {
|
|
102
|
+
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
103
|
+
model: (modelID: string | ModelID) => import("..").Model;
|
|
104
|
+
configure: /*elided*/ any;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
export declare const model: ProviderPackage.Definition<Settings>["model"];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { OpenAICompatibleResponses } from "../protocols/openai-compatible-responses";
|
|
2
|
+
import { AuthOptions } from "../route/auth-options";
|
|
3
|
+
import { ProviderID } from "../schema";
|
|
4
|
+
export const id = ProviderID.make("openai-compatible");
|
|
5
|
+
export const routes = [OpenAICompatibleResponses.route];
|
|
6
|
+
export const configure = (input) => {
|
|
7
|
+
const provider = input.provider ?? "openai-compatible";
|
|
8
|
+
const { provider: _, baseURL, apiKey: _apiKey, auth: _auth, ...rest } = input;
|
|
9
|
+
const route = OpenAICompatibleResponses.route.with({
|
|
10
|
+
...rest,
|
|
11
|
+
provider,
|
|
12
|
+
endpoint: { baseURL },
|
|
13
|
+
auth: AuthOptions.bearer(input, []),
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
id: ProviderID.make(provider),
|
|
17
|
+
model: (modelID) => route.model({ id: modelID }),
|
|
18
|
+
configure,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export const provider = {
|
|
22
|
+
id,
|
|
23
|
+
configure,
|
|
24
|
+
};
|
|
25
|
+
export const model = (modelID, settings) => configure({
|
|
26
|
+
apiKey: settings.apiKey,
|
|
27
|
+
baseURL: settings.baseURL,
|
|
28
|
+
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
29
|
+
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
30
|
+
limits: settings.limits,
|
|
31
|
+
provider: settings.provider,
|
|
32
|
+
providerOptions: settings.providerOptions,
|
|
33
|
+
}).model(modelID);
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { type ModelID } from "../schema";
|
|
2
|
+
import type { RouteDefaultsInput } from "../route/client";
|
|
3
|
+
import { type ProviderAuthOption } from "../route/auth-options";
|
|
4
|
+
import type { ProviderPackage } from "../provider-package";
|
|
5
|
+
export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
6
|
+
type GenericModelOptions = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
|
|
7
|
+
readonly provider?: string;
|
|
8
|
+
readonly baseURL: string;
|
|
9
|
+
};
|
|
10
|
+
export interface Settings extends ProviderPackage.Settings {
|
|
11
|
+
readonly apiKey?: string;
|
|
12
|
+
readonly baseURL: string;
|
|
13
|
+
readonly provider?: string;
|
|
14
|
+
}
|
|
15
|
+
export type FamilyModelOptions = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
|
|
16
|
+
readonly baseURL?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const routes: import("../route").Route<{
|
|
19
|
+
readonly model: string;
|
|
20
|
+
readonly messages: readonly ({
|
|
21
|
+
readonly role: "system";
|
|
22
|
+
readonly content: string;
|
|
23
|
+
} | {
|
|
24
|
+
readonly role: "user";
|
|
25
|
+
readonly content: string | readonly ({
|
|
26
|
+
readonly type: "text";
|
|
27
|
+
readonly text: string;
|
|
28
|
+
} | {
|
|
29
|
+
readonly type: "image_url";
|
|
30
|
+
readonly image_url: {
|
|
31
|
+
readonly url: string;
|
|
32
|
+
};
|
|
33
|
+
})[];
|
|
34
|
+
} | {
|
|
35
|
+
readonly role: "assistant";
|
|
36
|
+
readonly content: string | null;
|
|
37
|
+
readonly tool_calls?: readonly {
|
|
38
|
+
readonly id: string;
|
|
39
|
+
readonly type: "function";
|
|
40
|
+
readonly function: {
|
|
41
|
+
readonly name: string;
|
|
42
|
+
readonly arguments: string;
|
|
43
|
+
};
|
|
44
|
+
}[] | undefined;
|
|
45
|
+
readonly reasoning_content?: string | undefined;
|
|
46
|
+
} | {
|
|
47
|
+
readonly role: "tool";
|
|
48
|
+
readonly tool_call_id: string;
|
|
49
|
+
readonly content: string;
|
|
50
|
+
})[];
|
|
51
|
+
readonly stream: true;
|
|
52
|
+
readonly tools?: readonly {
|
|
53
|
+
readonly type: "function";
|
|
54
|
+
readonly function: {
|
|
55
|
+
readonly name: string;
|
|
56
|
+
readonly description: string;
|
|
57
|
+
readonly parameters: {
|
|
58
|
+
readonly [x: string]: unknown;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
}[] | undefined;
|
|
62
|
+
readonly tool_choice?: "required" | "none" | "auto" | {
|
|
63
|
+
readonly type: "function";
|
|
64
|
+
readonly function: {
|
|
65
|
+
readonly name: string;
|
|
66
|
+
};
|
|
67
|
+
} | undefined;
|
|
68
|
+
readonly stream_options?: {
|
|
69
|
+
readonly include_usage: boolean;
|
|
70
|
+
} | undefined;
|
|
71
|
+
readonly store?: boolean | undefined;
|
|
72
|
+
readonly reasoning_effort?: string | undefined;
|
|
73
|
+
readonly max_tokens?: number | undefined;
|
|
74
|
+
readonly temperature?: number | undefined;
|
|
75
|
+
readonly top_p?: number | undefined;
|
|
76
|
+
readonly frequency_penalty?: number | undefined;
|
|
77
|
+
readonly presence_penalty?: number | undefined;
|
|
78
|
+
readonly seed?: number | undefined;
|
|
79
|
+
readonly stop?: readonly string[] | undefined;
|
|
80
|
+
}, import("../route/transport/http").HttpPrepared<string>>[];
|
|
81
|
+
export declare const configure: (input: GenericModelOptions) => {
|
|
82
|
+
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
83
|
+
model: (modelID: string | ModelID) => import("..").Model;
|
|
84
|
+
configure: (input: GenericModelOptions) => /*elided*/ any;
|
|
85
|
+
};
|
|
86
|
+
export declare const provider: {
|
|
87
|
+
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
88
|
+
configure: (input: GenericModelOptions) => {
|
|
89
|
+
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
90
|
+
model: (modelID: string | ModelID) => import("..").Model;
|
|
91
|
+
configure: /*elided*/ any;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
export declare const model: ProviderPackage.Definition<Settings>["model"];
|
|
95
|
+
export declare const baseten: {
|
|
96
|
+
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
97
|
+
model: (modelID: string | ModelID) => import("..").Model;
|
|
98
|
+
configure: (input?: FamilyModelOptions) => /*elided*/ any;
|
|
99
|
+
};
|
|
100
|
+
export declare const cerebras: {
|
|
101
|
+
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
102
|
+
model: (modelID: string | ModelID) => import("..").Model;
|
|
103
|
+
configure: (input?: FamilyModelOptions) => /*elided*/ any;
|
|
104
|
+
};
|
|
105
|
+
export declare const deepinfra: {
|
|
106
|
+
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
107
|
+
model: (modelID: string | ModelID) => import("..").Model;
|
|
108
|
+
configure: (input?: FamilyModelOptions) => /*elided*/ any;
|
|
109
|
+
};
|
|
110
|
+
export declare const deepseek: {
|
|
111
|
+
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
112
|
+
model: (modelID: string | ModelID) => import("..").Model;
|
|
113
|
+
configure: (input?: FamilyModelOptions) => /*elided*/ any;
|
|
114
|
+
};
|
|
115
|
+
export declare const fireworks: {
|
|
116
|
+
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
117
|
+
model: (modelID: string | ModelID) => import("..").Model;
|
|
118
|
+
configure: (input?: FamilyModelOptions) => /*elided*/ any;
|
|
119
|
+
};
|
|
120
|
+
export declare const groq: {
|
|
121
|
+
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
122
|
+
model: (modelID: string | ModelID) => import("..").Model;
|
|
123
|
+
configure: (input?: FamilyModelOptions) => /*elided*/ any;
|
|
124
|
+
};
|
|
125
|
+
export declare const togetherai: {
|
|
126
|
+
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
127
|
+
model: (modelID: string | ModelID) => import("..").Model;
|
|
128
|
+
configure: (input?: FamilyModelOptions) => /*elided*/ any;
|
|
129
|
+
};
|
|
130
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ProviderID } from "../schema";
|
|
2
|
+
import * as OpenAICompatibleChat from "../protocols/openai-compatible-chat";
|
|
3
|
+
import { AuthOptions } from "../route/auth-options";
|
|
4
|
+
import { profiles } from "./openai-compatible-profile";
|
|
5
|
+
export const id = ProviderID.make("openai-compatible");
|
|
6
|
+
export const routes = [OpenAICompatibleChat.route];
|
|
7
|
+
export const configure = (input) => {
|
|
8
|
+
const provider = input.provider ?? "openai-compatible";
|
|
9
|
+
const { provider: _, baseURL, apiKey: _apiKey, auth: _auth, ...rest } = input;
|
|
10
|
+
const route = OpenAICompatibleChat.route.with({
|
|
11
|
+
...rest,
|
|
12
|
+
provider,
|
|
13
|
+
endpoint: { baseURL },
|
|
14
|
+
auth: AuthOptions.bearer(input, []),
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
id: ProviderID.make(provider),
|
|
18
|
+
model: (modelID) => route.model({ id: modelID, provider: ProviderID.make(provider) }),
|
|
19
|
+
configure,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const define = (profile) => {
|
|
23
|
+
const configureProfile = (input = {}) => {
|
|
24
|
+
const facade = configure({
|
|
25
|
+
...input,
|
|
26
|
+
baseURL: input.baseURL ?? profile.baseURL,
|
|
27
|
+
provider: profile.provider,
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
id: ProviderID.make(profile.provider),
|
|
31
|
+
model: facade.model,
|
|
32
|
+
configure: configureProfile,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
return configureProfile();
|
|
36
|
+
};
|
|
37
|
+
export const provider = {
|
|
38
|
+
id,
|
|
39
|
+
configure,
|
|
40
|
+
};
|
|
41
|
+
export const model = (modelID, settings) => configure({
|
|
42
|
+
apiKey: settings.apiKey,
|
|
43
|
+
baseURL: settings.baseURL,
|
|
44
|
+
headers: settings.headers === undefined ? undefined : { ...settings.headers },
|
|
45
|
+
http: settings.body === undefined ? undefined : { body: { ...settings.body } },
|
|
46
|
+
limits: settings.limits,
|
|
47
|
+
provider: settings.provider,
|
|
48
|
+
}).model(modelID);
|
|
49
|
+
export const baseten = define(profiles.baseten);
|
|
50
|
+
export const cerebras = define(profiles.cerebras);
|
|
51
|
+
export const deepinfra = define(profiles.deepinfra);
|
|
52
|
+
export const deepseek = define(profiles.deepseek);
|
|
53
|
+
export const fireworks = define(profiles.fireworks);
|
|
54
|
+
export const groq = define(profiles.groq);
|
|
55
|
+
export const togetherai = define(profiles.togetherai);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ProviderOptions, ReasoningEffort, TextVerbosity } from "../schema";
|
|
2
|
+
import type { OpenAIResponseIncludable, OpenAIServiceTier } from "../protocols/utils/openai-options";
|
|
3
|
+
export type { OpenAIResponseIncludable, OpenAIServiceTier } from "../protocols/utils/openai-options";
|
|
4
|
+
export interface OpenAIOptionsInput {
|
|
5
|
+
readonly [key: string]: unknown;
|
|
6
|
+
readonly store?: boolean;
|
|
7
|
+
readonly promptCacheKey?: string;
|
|
8
|
+
readonly reasoningEffort?: ReasoningEffort;
|
|
9
|
+
readonly reasoningSummary?: "auto";
|
|
10
|
+
readonly include?: ReadonlyArray<OpenAIResponseIncludable>;
|
|
11
|
+
readonly textVerbosity?: TextVerbosity;
|
|
12
|
+
readonly serviceTier?: OpenAIServiceTier;
|
|
13
|
+
}
|
|
14
|
+
export type OpenAIProviderOptionsInput = ProviderOptions & {
|
|
15
|
+
readonly openai?: OpenAIOptionsInput;
|
|
16
|
+
};
|
|
17
|
+
export declare const gpt5DefaultOptions: (modelID: string, options?: {
|
|
18
|
+
readonly textVerbosity?: boolean;
|
|
19
|
+
}) => ProviderOptions | undefined;
|
|
20
|
+
export declare const openAIDefaultOptions: (modelID: string, options?: {
|
|
21
|
+
readonly textVerbosity?: boolean;
|
|
22
|
+
}) => ProviderOptions | undefined;
|
|
23
|
+
export declare const withOpenAIOptions: <Options extends {
|
|
24
|
+
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
25
|
+
}>(modelID: string, options: Options, defaults?: {
|
|
26
|
+
readonly textVerbosity?: boolean;
|
|
27
|
+
}) => Omit<Options, "providerOptions"> & {
|
|
28
|
+
readonly providerOptions?: ProviderOptions;
|
|
29
|
+
};
|
|
30
|
+
export * as OpenAIProviderOptions from "./openai-options";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { mergeProviderOptions } from "../schema";
|
|
2
|
+
const definedEntries = (input) => Object.entries(input).filter((entry) => entry[1] !== undefined);
|
|
3
|
+
const openAIProviderOptions = (options) => {
|
|
4
|
+
const openai = Object.fromEntries(definedEntries({
|
|
5
|
+
store: options?.store,
|
|
6
|
+
promptCacheKey: options?.promptCacheKey,
|
|
7
|
+
reasoningEffort: options?.reasoningEffort,
|
|
8
|
+
reasoningSummary: options?.reasoningSummary,
|
|
9
|
+
include: options?.include,
|
|
10
|
+
textVerbosity: options?.textVerbosity,
|
|
11
|
+
serviceTier: options?.serviceTier,
|
|
12
|
+
}));
|
|
13
|
+
if (Object.keys(openai).length === 0)
|
|
14
|
+
return undefined;
|
|
15
|
+
return { openai };
|
|
16
|
+
};
|
|
17
|
+
export const gpt5DefaultOptions = (modelID, options = {}) => {
|
|
18
|
+
const id = modelID.toLowerCase();
|
|
19
|
+
if (!id.includes("gpt-5") || id.includes("gpt-5-chat") || id.includes("gpt-5-pro"))
|
|
20
|
+
return undefined;
|
|
21
|
+
return openAIProviderOptions({
|
|
22
|
+
reasoningEffort: "medium",
|
|
23
|
+
reasoningSummary: "auto",
|
|
24
|
+
// GPT-5 reasoning models are configured stateless (`store: false`) by
|
|
25
|
+
// `openAIDefaultOptions` below, so the only way a follow-up turn can
|
|
26
|
+
// carry reasoning state is via the encrypted reasoning include. Without
|
|
27
|
+
// this, callers using the default model facade get reasoning summaries
|
|
28
|
+
// they cannot replay statelessly.
|
|
29
|
+
include: ["reasoning.encrypted_content"],
|
|
30
|
+
textVerbosity: options.textVerbosity === true && id.includes("gpt-5.") && !id.includes("codex") && !id.includes("-chat")
|
|
31
|
+
? "low"
|
|
32
|
+
: undefined,
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
export const openAIDefaultOptions = (modelID, options = {}) => mergeProviderOptions(openAIProviderOptions({ store: false }), gpt5DefaultOptions(modelID, options));
|
|
36
|
+
export const withOpenAIOptions = (modelID, options, defaults = {}) => {
|
|
37
|
+
return {
|
|
38
|
+
...options,
|
|
39
|
+
providerOptions: mergeProviderOptions(openAIDefaultOptions(modelID, defaults), options.providerOptions),
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export * as OpenAIProviderOptions from "./openai-options";
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { type ProviderAuthOption } from "../route/auth-options";
|
|
2
|
+
import type { Route, RouteDefaultsInput } from "../route/client";
|
|
3
|
+
import type { ProviderPackage } from "../provider-package";
|
|
4
|
+
import { type ModelID } from "../schema";
|
|
5
|
+
import { type OpenAIProviderOptionsInput } from "./openai-options";
|
|
6
|
+
export type { OpenAIOptionsInput, OpenAIResponseIncludable } from "./openai-options";
|
|
7
|
+
export declare const id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
8
|
+
export declare const routes: (Route<{
|
|
9
|
+
readonly model: string;
|
|
10
|
+
readonly messages: readonly ({
|
|
11
|
+
readonly role: "system";
|
|
12
|
+
readonly content: string;
|
|
13
|
+
} | {
|
|
14
|
+
readonly role: "user";
|
|
15
|
+
readonly content: string | readonly ({
|
|
16
|
+
readonly type: "text";
|
|
17
|
+
readonly text: string;
|
|
18
|
+
} | {
|
|
19
|
+
readonly type: "image_url";
|
|
20
|
+
readonly image_url: {
|
|
21
|
+
readonly url: string;
|
|
22
|
+
};
|
|
23
|
+
})[];
|
|
24
|
+
} | {
|
|
25
|
+
readonly role: "assistant";
|
|
26
|
+
readonly content: string | null;
|
|
27
|
+
readonly tool_calls?: readonly {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
readonly type: "function";
|
|
30
|
+
readonly function: {
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly arguments: string;
|
|
33
|
+
};
|
|
34
|
+
}[] | undefined;
|
|
35
|
+
readonly reasoning_content?: string | undefined;
|
|
36
|
+
} | {
|
|
37
|
+
readonly role: "tool";
|
|
38
|
+
readonly tool_call_id: string;
|
|
39
|
+
readonly content: string;
|
|
40
|
+
})[];
|
|
41
|
+
readonly stream: true;
|
|
42
|
+
readonly tools?: readonly {
|
|
43
|
+
readonly type: "function";
|
|
44
|
+
readonly function: {
|
|
45
|
+
readonly name: string;
|
|
46
|
+
readonly description: string;
|
|
47
|
+
readonly parameters: {
|
|
48
|
+
readonly [x: string]: unknown;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}[] | undefined;
|
|
52
|
+
readonly tool_choice?: "required" | "none" | "auto" | {
|
|
53
|
+
readonly type: "function";
|
|
54
|
+
readonly function: {
|
|
55
|
+
readonly name: string;
|
|
56
|
+
};
|
|
57
|
+
} | undefined;
|
|
58
|
+
readonly stream_options?: {
|
|
59
|
+
readonly include_usage: boolean;
|
|
60
|
+
} | undefined;
|
|
61
|
+
readonly store?: boolean | undefined;
|
|
62
|
+
readonly reasoning_effort?: string | undefined;
|
|
63
|
+
readonly max_tokens?: number | undefined;
|
|
64
|
+
readonly temperature?: number | undefined;
|
|
65
|
+
readonly top_p?: number | undefined;
|
|
66
|
+
readonly frequency_penalty?: number | undefined;
|
|
67
|
+
readonly presence_penalty?: number | undefined;
|
|
68
|
+
readonly seed?: number | undefined;
|
|
69
|
+
readonly stop?: readonly string[] | undefined;
|
|
70
|
+
}, import("../route/transport/http").HttpPrepared<string>> | Route<{
|
|
71
|
+
readonly stream: true;
|
|
72
|
+
readonly model: string;
|
|
73
|
+
readonly input: readonly ({
|
|
74
|
+
readonly role: "system";
|
|
75
|
+
readonly content: string;
|
|
76
|
+
} | {
|
|
77
|
+
readonly role: "user";
|
|
78
|
+
readonly content: readonly ({
|
|
79
|
+
readonly type: "input_text";
|
|
80
|
+
readonly text: string;
|
|
81
|
+
} | {
|
|
82
|
+
readonly type: "input_image";
|
|
83
|
+
readonly image_url: string;
|
|
84
|
+
})[];
|
|
85
|
+
} | {
|
|
86
|
+
readonly role: "assistant";
|
|
87
|
+
readonly content: readonly {
|
|
88
|
+
readonly type: "output_text";
|
|
89
|
+
readonly text: string;
|
|
90
|
+
}[];
|
|
91
|
+
} | {
|
|
92
|
+
readonly type: "reasoning";
|
|
93
|
+
readonly summary: readonly {
|
|
94
|
+
readonly type: "summary_text";
|
|
95
|
+
readonly text: string;
|
|
96
|
+
}[];
|
|
97
|
+
readonly id?: string | undefined;
|
|
98
|
+
readonly encrypted_content?: string | null | undefined;
|
|
99
|
+
} | {
|
|
100
|
+
readonly type: "item_reference";
|
|
101
|
+
readonly id: string;
|
|
102
|
+
} | {
|
|
103
|
+
readonly type: "function_call";
|
|
104
|
+
readonly call_id: string;
|
|
105
|
+
readonly name: string;
|
|
106
|
+
readonly arguments: string;
|
|
107
|
+
} | {
|
|
108
|
+
readonly type: "function_call_output";
|
|
109
|
+
readonly call_id: string;
|
|
110
|
+
readonly output: string | readonly ({
|
|
111
|
+
readonly type: "input_text";
|
|
112
|
+
readonly text: string;
|
|
113
|
+
} | {
|
|
114
|
+
readonly type: "input_image";
|
|
115
|
+
readonly image_url: string;
|
|
116
|
+
})[];
|
|
117
|
+
})[];
|
|
118
|
+
readonly instructions?: string | undefined;
|
|
119
|
+
readonly tools?: readonly {
|
|
120
|
+
readonly type: "function";
|
|
121
|
+
readonly name: string;
|
|
122
|
+
readonly description: string;
|
|
123
|
+
readonly parameters: {
|
|
124
|
+
readonly [x: string]: unknown;
|
|
125
|
+
};
|
|
126
|
+
readonly strict?: boolean | undefined;
|
|
127
|
+
}[] | undefined;
|
|
128
|
+
readonly tool_choice?: "required" | "none" | "auto" | {
|
|
129
|
+
readonly type: "function";
|
|
130
|
+
readonly name: string;
|
|
131
|
+
} | undefined;
|
|
132
|
+
readonly store?: boolean | undefined;
|
|
133
|
+
readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
|
|
134
|
+
readonly prompt_cache_key?: string | undefined;
|
|
135
|
+
readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
|
|
136
|
+
readonly reasoning?: {
|
|
137
|
+
readonly effort?: string | undefined;
|
|
138
|
+
readonly summary?: "auto" | undefined;
|
|
139
|
+
} | undefined;
|
|
140
|
+
readonly text?: {
|
|
141
|
+
readonly verbosity?: "low" | "medium" | "high" | undefined;
|
|
142
|
+
} | undefined;
|
|
143
|
+
readonly max_output_tokens?: number | undefined;
|
|
144
|
+
readonly temperature?: number | undefined;
|
|
145
|
+
readonly top_p?: number | undefined;
|
|
146
|
+
}, import("../route/transport/http").HttpPrepared<string>> | Route<{
|
|
147
|
+
readonly stream: true;
|
|
148
|
+
readonly model: string;
|
|
149
|
+
readonly input: readonly ({
|
|
150
|
+
readonly role: "system";
|
|
151
|
+
readonly content: string;
|
|
152
|
+
} | {
|
|
153
|
+
readonly role: "user";
|
|
154
|
+
readonly content: readonly ({
|
|
155
|
+
readonly type: "input_text";
|
|
156
|
+
readonly text: string;
|
|
157
|
+
} | {
|
|
158
|
+
readonly type: "input_image";
|
|
159
|
+
readonly image_url: string;
|
|
160
|
+
})[];
|
|
161
|
+
} | {
|
|
162
|
+
readonly role: "assistant";
|
|
163
|
+
readonly content: readonly {
|
|
164
|
+
readonly type: "output_text";
|
|
165
|
+
readonly text: string;
|
|
166
|
+
}[];
|
|
167
|
+
} | {
|
|
168
|
+
readonly type: "reasoning";
|
|
169
|
+
readonly summary: readonly {
|
|
170
|
+
readonly type: "summary_text";
|
|
171
|
+
readonly text: string;
|
|
172
|
+
}[];
|
|
173
|
+
readonly id?: string | undefined;
|
|
174
|
+
readonly encrypted_content?: string | null | undefined;
|
|
175
|
+
} | {
|
|
176
|
+
readonly type: "item_reference";
|
|
177
|
+
readonly id: string;
|
|
178
|
+
} | {
|
|
179
|
+
readonly type: "function_call";
|
|
180
|
+
readonly call_id: string;
|
|
181
|
+
readonly name: string;
|
|
182
|
+
readonly arguments: string;
|
|
183
|
+
} | {
|
|
184
|
+
readonly type: "function_call_output";
|
|
185
|
+
readonly call_id: string;
|
|
186
|
+
readonly output: string | readonly ({
|
|
187
|
+
readonly type: "input_text";
|
|
188
|
+
readonly text: string;
|
|
189
|
+
} | {
|
|
190
|
+
readonly type: "input_image";
|
|
191
|
+
readonly image_url: string;
|
|
192
|
+
})[];
|
|
193
|
+
})[];
|
|
194
|
+
readonly instructions?: string | undefined;
|
|
195
|
+
readonly tools?: readonly {
|
|
196
|
+
readonly type: "function";
|
|
197
|
+
readonly name: string;
|
|
198
|
+
readonly description: string;
|
|
199
|
+
readonly parameters: {
|
|
200
|
+
readonly [x: string]: unknown;
|
|
201
|
+
};
|
|
202
|
+
readonly strict?: boolean | undefined;
|
|
203
|
+
}[] | undefined;
|
|
204
|
+
readonly tool_choice?: "required" | "none" | "auto" | {
|
|
205
|
+
readonly type: "function";
|
|
206
|
+
readonly name: string;
|
|
207
|
+
} | undefined;
|
|
208
|
+
readonly store?: boolean | undefined;
|
|
209
|
+
readonly service_tier?: "auto" | "default" | "flex" | "priority" | undefined;
|
|
210
|
+
readonly prompt_cache_key?: string | undefined;
|
|
211
|
+
readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
|
|
212
|
+
readonly reasoning?: {
|
|
213
|
+
readonly effort?: string | undefined;
|
|
214
|
+
readonly summary?: "auto" | undefined;
|
|
215
|
+
} | undefined;
|
|
216
|
+
readonly text?: {
|
|
217
|
+
readonly verbosity?: "low" | "medium" | "high" | undefined;
|
|
218
|
+
} | undefined;
|
|
219
|
+
readonly max_output_tokens?: number | undefined;
|
|
220
|
+
readonly temperature?: number | undefined;
|
|
221
|
+
readonly top_p?: number | undefined;
|
|
222
|
+
}, import("../route/transport/websocket").JsonPrepared>)[];
|
|
223
|
+
export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
|
|
224
|
+
readonly baseURL?: string;
|
|
225
|
+
readonly queryParams?: Record<string, string>;
|
|
226
|
+
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
227
|
+
};
|
|
228
|
+
export interface Settings extends ProviderPackage.Settings {
|
|
229
|
+
readonly apiKey?: string;
|
|
230
|
+
readonly baseURL?: string;
|
|
231
|
+
readonly organization?: string;
|
|
232
|
+
readonly project?: string;
|
|
233
|
+
readonly queryParams?: Readonly<Record<string, string>>;
|
|
234
|
+
readonly transport?: "http" | "websocket";
|
|
235
|
+
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
236
|
+
}
|
|
237
|
+
export declare const configure: (input?: Config) => {
|
|
238
|
+
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
239
|
+
model: (id: string | ModelID) => import("..").Model;
|
|
240
|
+
responses: (id: string | ModelID) => import("..").Model;
|
|
241
|
+
responsesWebSocket: (id: string | ModelID) => import("..").Model;
|
|
242
|
+
chat: (id: string | ModelID) => import("..").Model;
|
|
243
|
+
configure: (input?: Config) => /*elided*/ any;
|
|
244
|
+
};
|
|
245
|
+
export declare const provider: {
|
|
246
|
+
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
247
|
+
model: (id: string | ModelID) => import("..").Model;
|
|
248
|
+
responses: (id: string | ModelID) => import("..").Model;
|
|
249
|
+
responsesWebSocket: (id: string | ModelID) => import("..").Model;
|
|
250
|
+
chat: (id: string | ModelID) => import("..").Model;
|
|
251
|
+
configure: (input?: Config) => {
|
|
252
|
+
id: string & import("effect/Brand").Brand<"LLM.ProviderID">;
|
|
253
|
+
model: (id: string | ModelID) => import("..").Model;
|
|
254
|
+
responses: (id: string | ModelID) => import("..").Model;
|
|
255
|
+
responsesWebSocket: (id: string | ModelID) => import("..").Model;
|
|
256
|
+
chat: (id: string | ModelID) => import("..").Model;
|
|
257
|
+
configure: /*elided*/ any;
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
export declare const model: ProviderPackage.Definition<Settings>["model"];
|
|
261
|
+
export declare const chatModel: ProviderPackage.Definition<Settings>["model"];
|
|
262
|
+
export declare const responses: (id: string | ModelID) => import("..").Model;
|
|
263
|
+
export declare const responsesWebSocket: (id: string | ModelID) => import("..").Model;
|
|
264
|
+
export declare const chat: (id: string | ModelID) => import("..").Model;
|