@hebo-ai/gateway 0.1.2 → 0.2.0
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 +172 -67
- package/dist/config.js +2 -12
- package/dist/endpoints/chat-completions/converters.d.ts +28 -24
- package/dist/endpoints/chat-completions/converters.js +99 -73
- package/dist/endpoints/chat-completions/handler.js +36 -30
- package/dist/endpoints/chat-completions/schema.d.ts +394 -272
- package/dist/endpoints/chat-completions/schema.js +124 -57
- package/dist/endpoints/embeddings/converters.d.ts +4 -4
- package/dist/endpoints/embeddings/converters.js +8 -9
- package/dist/endpoints/embeddings/handler.js +32 -26
- package/dist/endpoints/embeddings/schema.d.ts +28 -38
- package/dist/endpoints/embeddings/schema.js +10 -10
- package/dist/endpoints/models/converters.d.ts +2 -2
- package/dist/endpoints/models/converters.js +9 -12
- package/dist/endpoints/models/handler.js +8 -9
- package/dist/endpoints/models/schema.d.ts +37 -31
- package/dist/endpoints/models/schema.js +23 -12
- package/dist/gateway.d.ts +8 -9
- package/dist/gateway.js +7 -10
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lifecycle.d.ts +2 -0
- package/dist/{utils/hooks.js → lifecycle.js} +16 -8
- package/dist/middleware/common.d.ts +4 -0
- package/dist/middleware/common.js +44 -0
- package/dist/middleware/matcher.d.ts +18 -0
- package/dist/middleware/matcher.js +83 -0
- package/dist/models/amazon/index.d.ts +2 -0
- package/dist/models/amazon/index.js +2 -0
- package/dist/models/amazon/middleware.d.ts +2 -0
- package/dist/models/amazon/middleware.js +20 -0
- package/dist/models/amazon/presets.d.ts +2390 -0
- package/dist/models/amazon/presets.js +80 -0
- package/dist/models/anthropic/index.d.ts +2 -0
- package/dist/models/anthropic/index.js +2 -0
- package/dist/models/anthropic/middleware.d.ts +5 -0
- package/dist/models/anthropic/middleware.js +67 -0
- package/dist/models/anthropic/presets.d.ts +4106 -0
- package/dist/models/anthropic/presets.js +113 -0
- package/dist/models/catalog.d.ts +3 -1
- package/dist/models/catalog.js +3 -2
- package/dist/models/cohere/index.d.ts +2 -0
- package/dist/models/cohere/index.js +2 -0
- package/dist/models/cohere/middleware.d.ts +2 -0
- package/dist/models/cohere/middleware.js +18 -0
- package/dist/models/cohere/presets.d.ts +2918 -0
- package/dist/models/cohere/presets.js +129 -0
- package/dist/models/google/index.d.ts +2 -0
- package/dist/models/google/index.js +2 -0
- package/dist/models/google/middleware.d.ts +2 -0
- package/dist/models/google/middleware.js +20 -0
- package/dist/models/{presets/gemini.d.ts → google/presets.d.ts} +400 -174
- package/dist/models/{presets/gemini.js → google/presets.js} +20 -5
- package/dist/models/meta/index.d.ts +1 -0
- package/dist/models/meta/index.js +1 -0
- package/dist/models/meta/presets.d.ts +3254 -0
- package/dist/models/{presets/llama.js → meta/presets.js} +44 -7
- package/dist/models/openai/index.d.ts +2 -0
- package/dist/models/openai/index.js +2 -0
- package/dist/models/openai/middleware.d.ts +2 -0
- package/dist/models/openai/middleware.js +20 -0
- package/dist/models/openai/presets.d.ts +6252 -0
- package/dist/models/openai/presets.js +206 -0
- package/dist/models/types.d.ts +3 -3
- package/dist/models/types.js +27 -0
- package/dist/models/voyage/index.d.ts +2 -0
- package/dist/models/voyage/index.js +2 -0
- package/dist/models/voyage/middleware.d.ts +2 -0
- package/dist/models/voyage/middleware.js +18 -0
- package/dist/models/{presets/voyage.d.ts → voyage/presets.d.ts} +322 -323
- package/dist/providers/anthropic/canonical.d.ts +3 -0
- package/dist/providers/anthropic/canonical.js +9 -0
- package/dist/providers/anthropic/index.d.ts +1 -0
- package/dist/providers/anthropic/index.js +1 -0
- package/dist/providers/bedrock/canonical.d.ts +15 -0
- package/dist/providers/{canonical/bedrock.js → bedrock/canonical.js} +13 -15
- package/dist/providers/bedrock/index.d.ts +1 -0
- package/dist/providers/bedrock/index.js +1 -0
- package/dist/providers/cohere/canonical.d.ts +3 -0
- package/dist/providers/{canonical/cohere.js → cohere/canonical.js} +6 -6
- package/dist/providers/cohere/index.d.ts +1 -0
- package/dist/providers/cohere/index.js +1 -0
- package/dist/providers/groq/canonical.d.ts +3 -0
- package/dist/providers/groq/canonical.js +12 -0
- package/dist/providers/groq/index.d.ts +1 -0
- package/dist/providers/groq/index.js +1 -0
- package/dist/providers/openai/canonical.d.ts +3 -0
- package/dist/providers/openai/canonical.js +8 -0
- package/dist/providers/openai/index.d.ts +1 -0
- package/dist/providers/openai/index.js +1 -0
- package/dist/providers/registry.d.ts +16 -26
- package/dist/providers/registry.js +19 -26
- package/dist/providers/types.d.ts +1 -1
- package/dist/providers/types.js +1 -0
- package/dist/providers/vertex/canonical.d.ts +3 -0
- package/dist/providers/vertex/canonical.js +8 -0
- package/dist/providers/vertex/index.d.ts +1 -0
- package/dist/providers/vertex/index.js +1 -0
- package/dist/providers/voyage/canonical.d.ts +3 -0
- package/dist/providers/voyage/canonical.js +7 -0
- package/dist/providers/voyage/index.d.ts +1 -0
- package/dist/providers/voyage/index.js +1 -0
- package/dist/types.d.ts +60 -30
- package/dist/utils/errors.js +2 -0
- package/dist/utils/preset.d.ts +1 -7
- package/dist/utils/preset.js +1 -1
- package/dist/utils/response.d.ts +1 -0
- package/dist/utils/response.js +10 -0
- package/package.json +79 -70
- package/src/config.ts +2 -18
- package/src/endpoints/chat-completions/converters.test.ts +39 -0
- package/src/endpoints/chat-completions/converters.ts +191 -112
- package/src/endpoints/chat-completions/handler.test.ts +47 -18
- package/src/endpoints/chat-completions/handler.ts +40 -34
- package/src/endpoints/chat-completions/schema.ts +161 -88
- package/src/endpoints/embeddings/converters.ts +15 -11
- package/src/endpoints/embeddings/handler.test.ts +27 -30
- package/src/endpoints/embeddings/handler.ts +34 -28
- package/src/endpoints/embeddings/schema.ts +10 -10
- package/src/endpoints/models/converters.ts +22 -14
- package/src/endpoints/models/handler.test.ts +26 -29
- package/src/endpoints/models/handler.ts +10 -12
- package/src/endpoints/models/schema.ts +26 -20
- package/src/gateway.ts +10 -24
- package/src/index.ts +3 -0
- package/src/{utils/hooks.ts → lifecycle.ts} +21 -11
- package/src/middleware/common.ts +68 -0
- package/src/middleware/matcher.ts +117 -0
- package/src/models/amazon/index.ts +2 -0
- package/src/models/amazon/middleware.ts +25 -0
- package/src/models/amazon/presets.ts +104 -0
- package/src/models/anthropic/index.ts +2 -0
- package/src/models/anthropic/middleware.test.ts +184 -0
- package/src/models/anthropic/middleware.ts +75 -0
- package/src/models/anthropic/presets.ts +161 -0
- package/src/models/catalog.ts +10 -2
- package/src/models/cohere/index.ts +2 -0
- package/src/models/cohere/middleware.ts +23 -0
- package/src/models/cohere/presets.ts +181 -0
- package/src/models/google/index.ts +2 -0
- package/src/models/google/middleware.ts +25 -0
- package/src/models/{presets/gemini.ts → google/presets.ts} +25 -5
- package/src/models/meta/index.ts +1 -0
- package/src/models/{presets/llama.ts → meta/presets.ts} +68 -7
- package/src/models/openai/index.ts +2 -0
- package/src/models/openai/middleware.ts +25 -0
- package/src/models/openai/presets.ts +269 -0
- package/src/models/types.ts +29 -2
- package/src/models/voyage/index.ts +2 -0
- package/src/models/voyage/middleware.ts +23 -0
- package/src/providers/anthropic/canonical.ts +17 -0
- package/src/providers/anthropic/index.ts +1 -0
- package/src/providers/{canonical/bedrock.ts → bedrock/canonical.ts} +22 -32
- package/src/providers/bedrock/index.ts +1 -0
- package/src/providers/cohere/canonical.ts +26 -0
- package/src/providers/cohere/index.ts +1 -0
- package/src/providers/groq/canonical.ts +21 -0
- package/src/providers/groq/index.ts +1 -0
- package/src/providers/openai/canonical.ts +16 -0
- package/src/providers/openai/index.ts +1 -0
- package/src/providers/registry.test.ts +12 -10
- package/src/providers/registry.ts +43 -43
- package/src/providers/types.ts +1 -0
- package/src/providers/vertex/canonical.ts +17 -0
- package/src/providers/vertex/index.ts +1 -0
- package/src/providers/voyage/canonical.ts +16 -0
- package/src/providers/voyage/index.ts +1 -0
- package/src/types.ts +64 -28
- package/src/utils/errors.ts +2 -0
- package/src/utils/preset.ts +2 -6
- package/src/utils/response.ts +15 -0
- package/dist/models/presets/claude.d.ts +0 -1165
- package/dist/models/presets/claude.js +0 -40
- package/dist/models/presets/cohere.d.ts +0 -383
- package/dist/models/presets/cohere.js +0 -26
- package/dist/models/presets/gpt-oss.d.ts +0 -779
- package/dist/models/presets/gpt-oss.js +0 -40
- package/dist/models/presets/llama.d.ts +0 -1400
- package/dist/providers/canonical/anthropic.d.ts +0 -25
- package/dist/providers/canonical/anthropic.js +0 -14
- package/dist/providers/canonical/bedrock.d.ts +0 -26
- package/dist/providers/canonical/cohere.d.ts +0 -17
- package/dist/providers/canonical/groq.d.ts +0 -17
- package/dist/providers/canonical/groq.js +0 -10
- package/dist/providers/canonical/openai.d.ts +0 -17
- package/dist/providers/canonical/openai.js +0 -8
- package/dist/providers/canonical/vertex.d.ts +0 -17
- package/dist/providers/canonical/vertex.js +0 -10
- package/dist/providers/canonical/voyage.d.ts +0 -17
- package/dist/providers/canonical/voyage.js +0 -8
- package/dist/utils/hooks.d.ts +0 -2
- package/src/models/presets/claude.ts +0 -59
- package/src/models/presets/cohere.ts +0 -37
- package/src/models/presets/gpt-oss.ts +0 -55
- package/src/providers/canonical/anthropic.ts +0 -32
- package/src/providers/canonical/cohere.ts +0 -36
- package/src/providers/canonical/groq.ts +0 -25
- package/src/providers/canonical/openai.ts +0 -16
- package/src/providers/canonical/vertex.ts +0 -18
- package/src/providers/canonical/voyage.ts +0 -16
- package/dist/models/{presets/voyage.js → voyage/presets.js} +10 -10
- package/src/models/{presets/voyage.ts → voyage/presets.ts} +10 -10
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { EmbeddingModelMiddleware } from "ai";
|
|
2
|
+
|
|
3
|
+
import { modelMiddlewareMatcher } from "../../middleware/matcher";
|
|
4
|
+
|
|
5
|
+
// Convert `dimensions` (OpenAI) to `outputDimension` (Cohere)
|
|
6
|
+
export const cohereEmbeddingModelMiddleware: EmbeddingModelMiddleware = {
|
|
7
|
+
specificationVersion: "v3",
|
|
8
|
+
// eslint-disable-next-line require-await
|
|
9
|
+
transformParams: async ({ params }) => {
|
|
10
|
+
const unknown = params.providerOptions?.["unknown"];
|
|
11
|
+
if (!unknown) return params;
|
|
12
|
+
|
|
13
|
+
let dimensions = unknown["dimensions"] as number;
|
|
14
|
+
if (!dimensions) dimensions = 1024;
|
|
15
|
+
|
|
16
|
+
(params.providerOptions!["cohere"] ??= {})["outputDimension"] = dimensions;
|
|
17
|
+
delete unknown["dimensions"];
|
|
18
|
+
|
|
19
|
+
return params;
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
modelMiddlewareMatcher.useForModel("cohere/embed-*", { embedding: cohereEmbeddingModelMiddleware });
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import type { CanonicalProviderId } from "../../providers/types";
|
|
2
|
+
import type { CanonicalModelId, CatalogModel } from "../types";
|
|
3
|
+
|
|
4
|
+
import { presetFor, type DeepPartial } from "../../utils/preset";
|
|
5
|
+
|
|
6
|
+
const COMMAND_BASE = {
|
|
7
|
+
modalities: {
|
|
8
|
+
input: ["text"] as const,
|
|
9
|
+
output: ["text"] as const,
|
|
10
|
+
},
|
|
11
|
+
capabilities: ["tool_call", "structured_output", "reasoning", "temperature"] as const,
|
|
12
|
+
providers: ["cohere"] as const satisfies readonly CanonicalProviderId[],
|
|
13
|
+
knowledge: "2024-06",
|
|
14
|
+
} satisfies DeepPartial<CatalogModel>;
|
|
15
|
+
|
|
16
|
+
const COMMAND_VISION_BASE = {
|
|
17
|
+
modalities: {
|
|
18
|
+
input: ["text", "image"] as const,
|
|
19
|
+
output: ["text"] as const,
|
|
20
|
+
},
|
|
21
|
+
capabilities: ["structured_output", "reasoning", "temperature"] as const,
|
|
22
|
+
providers: ["cohere"] as const satisfies readonly CanonicalProviderId[],
|
|
23
|
+
knowledge: "2024-06",
|
|
24
|
+
} satisfies DeepPartial<CatalogModel>;
|
|
25
|
+
|
|
26
|
+
const EMBED_V3_BASE = {
|
|
27
|
+
modalities: {
|
|
28
|
+
input: ["text", "image"] as const,
|
|
29
|
+
output: ["embeddings"] as const,
|
|
30
|
+
},
|
|
31
|
+
providers: ["cohere", "bedrock"] as const satisfies readonly CanonicalProviderId[],
|
|
32
|
+
} satisfies DeepPartial<CatalogModel>;
|
|
33
|
+
|
|
34
|
+
const EMBED_V4_BASE = {
|
|
35
|
+
modalities: {
|
|
36
|
+
input: ["text", "image", "pdf"] as const,
|
|
37
|
+
output: ["embeddings"] as const,
|
|
38
|
+
},
|
|
39
|
+
providers: ["cohere", "bedrock"] as const satisfies readonly CanonicalProviderId[],
|
|
40
|
+
} satisfies DeepPartial<CatalogModel>;
|
|
41
|
+
|
|
42
|
+
export const commandA = presetFor<CanonicalModelId, CatalogModel>()("cohere/command-a" as const, {
|
|
43
|
+
...COMMAND_BASE,
|
|
44
|
+
name: "Cohere Command A",
|
|
45
|
+
created: "2025-03-13",
|
|
46
|
+
context: 256000,
|
|
47
|
+
} satisfies CatalogModel);
|
|
48
|
+
|
|
49
|
+
export const commandAReasoning = presetFor<CanonicalModelId, CatalogModel>()(
|
|
50
|
+
"cohere/command-a-reasoning" as const,
|
|
51
|
+
{
|
|
52
|
+
...COMMAND_BASE,
|
|
53
|
+
name: "Cohere Command A Reasoning",
|
|
54
|
+
created: "2025-08-21",
|
|
55
|
+
context: 256000,
|
|
56
|
+
} satisfies CatalogModel,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
export const commandATranslate = presetFor<CanonicalModelId, CatalogModel>()(
|
|
60
|
+
"cohere/command-a-translate" as const,
|
|
61
|
+
{
|
|
62
|
+
...COMMAND_BASE,
|
|
63
|
+
name: "Cohere Command A Translate",
|
|
64
|
+
created: "2025-08-28",
|
|
65
|
+
context: 8000,
|
|
66
|
+
} satisfies CatalogModel,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
export const commandAVision = presetFor<CanonicalModelId, CatalogModel>()(
|
|
70
|
+
"cohere/command-a-vision" as const,
|
|
71
|
+
{
|
|
72
|
+
...COMMAND_VISION_BASE,
|
|
73
|
+
name: "Cohere Command A Vision",
|
|
74
|
+
created: "2025-07-31",
|
|
75
|
+
context: 128000,
|
|
76
|
+
} satisfies CatalogModel,
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
export const commandR = presetFor<CanonicalModelId, CatalogModel>()("cohere/command-r" as const, {
|
|
80
|
+
...COMMAND_BASE,
|
|
81
|
+
name: "Cohere Command R",
|
|
82
|
+
created: "2024-08-01",
|
|
83
|
+
context: 128000,
|
|
84
|
+
providers: ["cohere", "bedrock"],
|
|
85
|
+
} satisfies CatalogModel);
|
|
86
|
+
|
|
87
|
+
export const commandRPlus = presetFor<CanonicalModelId, CatalogModel>()(
|
|
88
|
+
"cohere/command-r-plus" as const,
|
|
89
|
+
{
|
|
90
|
+
...COMMAND_BASE,
|
|
91
|
+
name: "Cohere Command R+",
|
|
92
|
+
created: "2024-08-01",
|
|
93
|
+
context: 128000,
|
|
94
|
+
providers: ["cohere", "bedrock"],
|
|
95
|
+
} satisfies CatalogModel,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
export const commandR7b = presetFor<CanonicalModelId, CatalogModel>()(
|
|
99
|
+
"cohere/command-r7b" as const,
|
|
100
|
+
{
|
|
101
|
+
...COMMAND_BASE,
|
|
102
|
+
name: "Cohere Command R7B",
|
|
103
|
+
created: "2024-12-13",
|
|
104
|
+
context: 128000,
|
|
105
|
+
} satisfies CatalogModel,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
export const embed4 = presetFor<CanonicalModelId, CatalogModel>()("cohere/embed-v4.0" as const, {
|
|
109
|
+
...EMBED_V4_BASE,
|
|
110
|
+
name: "Cohere 4 Embeddings",
|
|
111
|
+
created: "2025-04-15",
|
|
112
|
+
context: 128000,
|
|
113
|
+
} satisfies CatalogModel);
|
|
114
|
+
|
|
115
|
+
export const embedEnglishV3 = presetFor<CanonicalModelId, CatalogModel>()(
|
|
116
|
+
"cohere/embed-english-v3.0" as const,
|
|
117
|
+
{
|
|
118
|
+
...EMBED_V3_BASE,
|
|
119
|
+
name: "Cohere Embed English v3",
|
|
120
|
+
created: "2024-02-07",
|
|
121
|
+
context: 512,
|
|
122
|
+
} satisfies CatalogModel,
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
export const embedEnglishLightV3 = presetFor<CanonicalModelId, CatalogModel>()(
|
|
126
|
+
"cohere/embed-english-light-v3.0" as const,
|
|
127
|
+
{
|
|
128
|
+
...EMBED_V3_BASE,
|
|
129
|
+
name: "Cohere Embed English Light v3",
|
|
130
|
+
created: "2024-02-07",
|
|
131
|
+
context: 512,
|
|
132
|
+
} satisfies CatalogModel,
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
export const embedMultilingualV3 = presetFor<CanonicalModelId, CatalogModel>()(
|
|
136
|
+
"cohere/embed-multilingual-v3.0" as const,
|
|
137
|
+
{
|
|
138
|
+
...EMBED_V3_BASE,
|
|
139
|
+
name: "Cohere Embed Multilingual v3",
|
|
140
|
+
created: "2024-02-07",
|
|
141
|
+
context: 512,
|
|
142
|
+
} satisfies CatalogModel,
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
export const embedMultilingualLightV3 = presetFor<CanonicalModelId, CatalogModel>()(
|
|
146
|
+
"cohere/embed-multilingual-light-v3.0" as const,
|
|
147
|
+
{
|
|
148
|
+
...EMBED_V3_BASE,
|
|
149
|
+
name: "Cohere Embed Multilingual Light v3",
|
|
150
|
+
created: "2024-02-07",
|
|
151
|
+
context: 512,
|
|
152
|
+
} satisfies CatalogModel,
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
const commandAtomic = {
|
|
156
|
+
A: [commandA, commandAReasoning, commandATranslate, commandAVision],
|
|
157
|
+
R: [commandR, commandRPlus, commandR7b],
|
|
158
|
+
} as const;
|
|
159
|
+
|
|
160
|
+
const commandGroups = {} as const;
|
|
161
|
+
|
|
162
|
+
export const command = {
|
|
163
|
+
...commandAtomic,
|
|
164
|
+
...commandGroups,
|
|
165
|
+
latest: [commandA],
|
|
166
|
+
all: Object.values(commandAtomic).flat(),
|
|
167
|
+
} as const;
|
|
168
|
+
|
|
169
|
+
const embedAtomic = {
|
|
170
|
+
v4: [embed4],
|
|
171
|
+
v3: [embedEnglishV3, embedEnglishLightV3, embedMultilingualV3, embedMultilingualLightV3],
|
|
172
|
+
} as const;
|
|
173
|
+
|
|
174
|
+
const embedGroups = {} as const;
|
|
175
|
+
|
|
176
|
+
export const embed = {
|
|
177
|
+
...embedAtomic,
|
|
178
|
+
...embedGroups,
|
|
179
|
+
latest: [embed4],
|
|
180
|
+
all: Object.values(embedAtomic).flat(),
|
|
181
|
+
} as const;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { EmbeddingModelMiddleware } from "ai";
|
|
2
|
+
|
|
3
|
+
import { modelMiddlewareMatcher } from "../../middleware/matcher";
|
|
4
|
+
|
|
5
|
+
// Convert `dimensions` (OpenAI) to `outputDimensionality` (Google)
|
|
6
|
+
export const geminiEmbeddingModelMiddleware: EmbeddingModelMiddleware = {
|
|
7
|
+
specificationVersion: "v3",
|
|
8
|
+
// eslint-disable-next-line require-await
|
|
9
|
+
transformParams: async ({ params }) => {
|
|
10
|
+
const unknown = params.providerOptions?.["unknown"];
|
|
11
|
+
if (!unknown) return params;
|
|
12
|
+
|
|
13
|
+
let dimensions = unknown["dimensions"] as number;
|
|
14
|
+
if (!dimensions) dimensions = 1024;
|
|
15
|
+
|
|
16
|
+
(params.providerOptions!["google"] ??= {})["outputDimensionality"] = dimensions;
|
|
17
|
+
delete unknown["dimensions"];
|
|
18
|
+
|
|
19
|
+
return params;
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
modelMiddlewareMatcher.useForModel("google/gemini-*embedding-*", {
|
|
24
|
+
embedding: geminiEmbeddingModelMiddleware,
|
|
25
|
+
});
|
|
@@ -19,59 +19,78 @@ const GEMINI_BASE = {
|
|
|
19
19
|
providers: ["vertex"] as const satisfies readonly CanonicalProviderId[],
|
|
20
20
|
} satisfies DeepPartial<CatalogModel>;
|
|
21
21
|
|
|
22
|
+
const GEMINI_EMBEDDINGS_BASE = {
|
|
23
|
+
modalities: {
|
|
24
|
+
input: ["text"] as const,
|
|
25
|
+
output: ["embeddings"] as const,
|
|
26
|
+
},
|
|
27
|
+
providers: ["vertex"] as const satisfies readonly CanonicalProviderId[],
|
|
28
|
+
} satisfies DeepPartial<CatalogModel>;
|
|
29
|
+
|
|
30
|
+
export const geminiEmbedding001 = presetFor<CanonicalModelId, CatalogModel>()(
|
|
31
|
+
"google/embedding-001" as const,
|
|
32
|
+
{
|
|
33
|
+
...GEMINI_EMBEDDINGS_BASE,
|
|
34
|
+
name: "Gemini Embedding 001",
|
|
35
|
+
created: "2025-05-20",
|
|
36
|
+
context: 8192,
|
|
37
|
+
} satisfies CatalogModel,
|
|
38
|
+
);
|
|
39
|
+
|
|
22
40
|
export const gemini3FlashPreview = presetFor<CanonicalModelId, CatalogModel>()(
|
|
23
41
|
"google/gemini-3-flash-preview" as const,
|
|
24
42
|
{
|
|
43
|
+
...GEMINI_BASE,
|
|
25
44
|
name: "Gemini 3 Flash (Preview)",
|
|
26
45
|
created: "2025-12-17",
|
|
27
46
|
knowledge: "2025-01",
|
|
28
|
-
...GEMINI_BASE,
|
|
29
47
|
} satisfies DeepPartial<CatalogModel>,
|
|
30
48
|
);
|
|
31
49
|
|
|
32
50
|
export const gemini3ProPreview = presetFor<CanonicalModelId, CatalogModel>()(
|
|
33
51
|
"google/gemini-3-pro-preview" as const,
|
|
34
52
|
{
|
|
53
|
+
...GEMINI_BASE,
|
|
35
54
|
name: "Gemini 3 Pro (Preview)",
|
|
36
55
|
created: "2025-11-18",
|
|
37
56
|
knowledge: "2025-01",
|
|
38
|
-
...GEMINI_BASE,
|
|
39
57
|
} satisfies DeepPartial<CatalogModel>,
|
|
40
58
|
);
|
|
41
59
|
|
|
42
60
|
export const gemini25FlashLite = presetFor<CanonicalModelId, CatalogModel>()(
|
|
43
61
|
"google/gemini-2.5-flash-lite" as const,
|
|
44
62
|
{
|
|
63
|
+
...GEMINI_BASE,
|
|
45
64
|
name: "Gemini 2.5 Flash Lite",
|
|
46
65
|
created: "2025-06-17",
|
|
47
66
|
knowledge: "2025-01",
|
|
48
|
-
...GEMINI_BASE,
|
|
49
67
|
} satisfies DeepPartial<CatalogModel>,
|
|
50
68
|
);
|
|
51
69
|
|
|
52
70
|
export const gemini25Flash = presetFor<CanonicalModelId, CatalogModel>()(
|
|
53
71
|
"google/gemini-2.5-flash" as const,
|
|
54
72
|
{
|
|
73
|
+
...GEMINI_BASE,
|
|
55
74
|
name: "Gemini 2.5 Flash",
|
|
56
75
|
created: "2025-03-20",
|
|
57
76
|
knowledge: "2025-01",
|
|
58
|
-
...GEMINI_BASE,
|
|
59
77
|
} satisfies DeepPartial<CatalogModel>,
|
|
60
78
|
);
|
|
61
79
|
|
|
62
80
|
export const gemini25Pro = presetFor<CanonicalModelId, CatalogModel>()(
|
|
63
81
|
"google/gemini-2.5-pro" as const,
|
|
64
82
|
{
|
|
83
|
+
...GEMINI_BASE,
|
|
65
84
|
name: "Gemini 2.5 Pro",
|
|
66
85
|
created: "2025-03-20",
|
|
67
86
|
knowledge: "2025-01",
|
|
68
|
-
...GEMINI_BASE,
|
|
69
87
|
} satisfies DeepPartial<CatalogModel>,
|
|
70
88
|
);
|
|
71
89
|
|
|
72
90
|
const geminiAtomic = {
|
|
73
91
|
"v2.5": [gemini25FlashLite, gemini25Flash, gemini25Pro],
|
|
74
92
|
"v3-preview": [gemini3FlashPreview, gemini3ProPreview],
|
|
93
|
+
embeddings: [geminiEmbedding001],
|
|
75
94
|
} as const;
|
|
76
95
|
|
|
77
96
|
const geminiGroups = {
|
|
@@ -84,5 +103,6 @@ export const gemini = {
|
|
|
84
103
|
...geminiGroups,
|
|
85
104
|
latest: [...geminiAtomic["v2.5"]],
|
|
86
105
|
preview: [...geminiAtomic["v3-preview"]],
|
|
106
|
+
embeddings: [...geminiAtomic["embeddings"]],
|
|
87
107
|
all: Object.values(geminiAtomic).flat(),
|
|
88
108
|
} as const;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./presets";
|
|
@@ -16,20 +16,80 @@ const LLAMA_3_BASE = {
|
|
|
16
16
|
export const llama31_8b = presetFor<CanonicalModelId, CatalogModel>()(
|
|
17
17
|
"meta/llama-3.1-8b" as const,
|
|
18
18
|
{
|
|
19
|
+
...LLAMA_3_BASE,
|
|
19
20
|
name: "Llama 3.1 8B",
|
|
20
21
|
created: "2024-07-23",
|
|
21
22
|
knowledge: "2023-12",
|
|
23
|
+
} satisfies CatalogModel,
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export const llama31_70b = presetFor<CanonicalModelId, CatalogModel>()(
|
|
27
|
+
"meta/llama-3.1-70b" as const,
|
|
28
|
+
{
|
|
22
29
|
...LLAMA_3_BASE,
|
|
30
|
+
name: "Llama 3.1 70B",
|
|
31
|
+
created: "2024-07-23",
|
|
32
|
+
knowledge: "2023-12",
|
|
33
|
+
} satisfies CatalogModel,
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
export const llama31_405b = presetFor<CanonicalModelId, CatalogModel>()(
|
|
37
|
+
"meta/llama-3.1-405b" as const,
|
|
38
|
+
{
|
|
39
|
+
...LLAMA_3_BASE,
|
|
40
|
+
name: "Llama 3.1 405B",
|
|
41
|
+
created: "2024-07-23",
|
|
42
|
+
knowledge: "2023-12",
|
|
43
|
+
} satisfies CatalogModel,
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
export const llama32_1b = presetFor<CanonicalModelId, CatalogModel>()(
|
|
47
|
+
"meta/llama-3.2-1b" as const,
|
|
48
|
+
{
|
|
49
|
+
...LLAMA_3_BASE,
|
|
50
|
+
name: "Llama 3.2 1B",
|
|
51
|
+
created: "2024-09-25",
|
|
52
|
+
knowledge: "2023-12",
|
|
53
|
+
} satisfies CatalogModel,
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
export const llama32_3b = presetFor<CanonicalModelId, CatalogModel>()(
|
|
57
|
+
"meta/llama-3.2-3b" as const,
|
|
58
|
+
{
|
|
59
|
+
...LLAMA_3_BASE,
|
|
60
|
+
name: "Llama 3.2 3B",
|
|
61
|
+
created: "2024-09-25",
|
|
62
|
+
knowledge: "2023-12",
|
|
63
|
+
} satisfies CatalogModel,
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
export const llama32_11b = presetFor<CanonicalModelId, CatalogModel>()(
|
|
67
|
+
"meta/llama-3.2-11b" as const,
|
|
68
|
+
{
|
|
69
|
+
...LLAMA_3_BASE,
|
|
70
|
+
name: "Llama 3.2 11B",
|
|
71
|
+
created: "2024-09-25",
|
|
72
|
+
knowledge: "2023-12",
|
|
73
|
+
} satisfies CatalogModel,
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
export const llama32_90b = presetFor<CanonicalModelId, CatalogModel>()(
|
|
77
|
+
"meta/llama-3.2-90b" as const,
|
|
78
|
+
{
|
|
79
|
+
...LLAMA_3_BASE,
|
|
80
|
+
name: "Llama 3.2 90B",
|
|
81
|
+
created: "2024-09-25",
|
|
82
|
+
knowledge: "2023-12",
|
|
23
83
|
} satisfies CatalogModel,
|
|
24
84
|
);
|
|
25
85
|
|
|
26
86
|
export const llama33_70b = presetFor<CanonicalModelId, CatalogModel>()(
|
|
27
87
|
"meta/llama-3.3-70b" as const,
|
|
28
88
|
{
|
|
89
|
+
...LLAMA_3_BASE,
|
|
29
90
|
name: "Llama 3.3 70B",
|
|
30
91
|
created: "2024-12-06",
|
|
31
92
|
knowledge: "2023-12",
|
|
32
|
-
...LLAMA_3_BASE,
|
|
33
93
|
} satisfies CatalogModel,
|
|
34
94
|
);
|
|
35
95
|
|
|
@@ -38,39 +98,40 @@ const LLAMA_4_BASE = {
|
|
|
38
98
|
input: ["text", "image", "file"] as const,
|
|
39
99
|
output: ["text"] as const,
|
|
40
100
|
},
|
|
41
|
-
capabilities: ["attachments", "
|
|
101
|
+
capabilities: ["attachments", "tool_call", "temperature"] as const,
|
|
42
102
|
context: 1000000,
|
|
43
|
-
providers: ["groq"] as const,
|
|
103
|
+
providers: ["groq", "vertex", "bedrock"] as const,
|
|
44
104
|
} satisfies DeepPartial<CatalogModel>;
|
|
45
105
|
|
|
46
106
|
export const llama4Scout = presetFor<CanonicalModelId, CatalogModel>()(
|
|
47
107
|
"meta/llama-4-scout" as const,
|
|
48
108
|
{
|
|
109
|
+
...LLAMA_4_BASE,
|
|
49
110
|
name: "Llama 4 Scout",
|
|
50
111
|
created: "2025-08-05",
|
|
51
112
|
knowledge: "2024-06",
|
|
52
|
-
...LLAMA_4_BASE,
|
|
53
113
|
} satisfies CatalogModel,
|
|
54
114
|
);
|
|
55
115
|
|
|
56
116
|
export const llama4Maverick = presetFor<CanonicalModelId, CatalogModel>()(
|
|
57
117
|
"meta/llama-4-maverick" as const,
|
|
58
118
|
{
|
|
119
|
+
...LLAMA_4_BASE,
|
|
59
120
|
name: "Llama 4 Maverick",
|
|
60
121
|
created: "2025-08-05",
|
|
61
122
|
knowledge: "2024-06",
|
|
62
|
-
...LLAMA_4_BASE,
|
|
63
123
|
} satisfies CatalogModel,
|
|
64
124
|
);
|
|
65
125
|
|
|
66
126
|
const llamaAtomic = {
|
|
67
|
-
"v3.1": [llama31_8b],
|
|
127
|
+
"v3.1": [llama31_8b, llama31_70b, llama31_405b],
|
|
128
|
+
"v3.2": [llama32_1b, llama32_3b, llama32_11b, llama32_90b],
|
|
68
129
|
"v3.3": [llama33_70b],
|
|
69
130
|
v4: [llama4Scout, llama4Maverick],
|
|
70
131
|
} as const;
|
|
71
132
|
|
|
72
133
|
const llamaGroups = {
|
|
73
|
-
"v3.x": [...llamaAtomic["v3.1"], ...llamaAtomic["v3.3"]],
|
|
134
|
+
"v3.x": [...llamaAtomic["v3.1"], ...llamaAtomic["v3.2"], ...llamaAtomic["v3.3"]],
|
|
74
135
|
"v4.x": [...llamaAtomic["v4"]],
|
|
75
136
|
} as const;
|
|
76
137
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { EmbeddingModelMiddleware } from "ai";
|
|
2
|
+
|
|
3
|
+
import { modelMiddlewareMatcher } from "../../middleware/matcher";
|
|
4
|
+
|
|
5
|
+
// Convert `dimensions` (OpenAI) to `dimensions` (OpenAI)
|
|
6
|
+
export const openAIEmbeddingModelMiddleware: EmbeddingModelMiddleware = {
|
|
7
|
+
specificationVersion: "v3",
|
|
8
|
+
// eslint-disable-next-line require-await
|
|
9
|
+
transformParams: async ({ params }) => {
|
|
10
|
+
const unknown = params.providerOptions?.["unknown"];
|
|
11
|
+
if (!unknown) return params;
|
|
12
|
+
|
|
13
|
+
let dimensions = unknown["dimensions"] as number;
|
|
14
|
+
if (!dimensions) dimensions = 1024;
|
|
15
|
+
|
|
16
|
+
(params.providerOptions!["openai"] ??= {})["dimensions"] = dimensions;
|
|
17
|
+
delete unknown["dimensions"];
|
|
18
|
+
|
|
19
|
+
return params;
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
modelMiddlewareMatcher.useForModel("openai/text-embedding-*", {
|
|
24
|
+
embedding: openAIEmbeddingModelMiddleware,
|
|
25
|
+
});
|