@hebo-ai/gateway 0.5.2 → 0.6.0-rc0
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 +32 -1
- package/package.json +17 -12
- package/src/endpoints/chat-completions/converters.test.ts +85 -1
- package/src/endpoints/chat-completions/converters.ts +139 -18
- package/src/endpoints/chat-completions/handler.test.ts +2 -0
- package/src/endpoints/chat-completions/index.ts +1 -0
- package/src/endpoints/chat-completions/otel.ts +1 -0
- package/src/endpoints/chat-completions/schema.ts +38 -4
- package/src/endpoints/embeddings/index.ts +1 -0
- package/src/lifecycle.ts +2 -2
- package/src/models/anthropic/middleware.test.ts +45 -1
- package/src/models/anthropic/middleware.ts +21 -1
- package/src/models/google/middleware.test.ts +30 -1
- package/src/models/google/middleware.ts +20 -1
- package/src/models/openai/middleware.test.ts +32 -1
- package/src/models/openai/middleware.ts +25 -1
- package/src/providers/bedrock/middleware.test.ts +121 -1
- package/src/providers/bedrock/middleware.ts +61 -1
- package/src/telemetry/fetch.ts +31 -4
- package/src/telemetry/index.ts +1 -0
- package/dist/config.d.ts +0 -2
- package/dist/config.js +0 -81
- package/dist/endpoints/chat-completions/converters.d.ts +0 -43
- package/dist/endpoints/chat-completions/converters.js +0 -551
- package/dist/endpoints/chat-completions/handler.d.ts +0 -2
- package/dist/endpoints/chat-completions/handler.js +0 -145
- package/dist/endpoints/chat-completions/index.d.ts +0 -3
- package/dist/endpoints/chat-completions/index.js +0 -3
- package/dist/endpoints/chat-completions/otel.d.ts +0 -6
- package/dist/endpoints/chat-completions/otel.js +0 -134
- package/dist/endpoints/chat-completions/schema.d.ts +0 -946
- package/dist/endpoints/chat-completions/schema.js +0 -257
- package/dist/endpoints/embeddings/converters.d.ts +0 -10
- package/dist/endpoints/embeddings/converters.js +0 -31
- package/dist/endpoints/embeddings/handler.d.ts +0 -2
- package/dist/endpoints/embeddings/handler.js +0 -101
- package/dist/endpoints/embeddings/index.d.ts +0 -3
- package/dist/endpoints/embeddings/index.js +0 -3
- package/dist/endpoints/embeddings/otel.d.ts +0 -6
- package/dist/endpoints/embeddings/otel.js +0 -35
- package/dist/endpoints/embeddings/schema.d.ts +0 -38
- package/dist/endpoints/embeddings/schema.js +0 -26
- package/dist/endpoints/models/converters.d.ts +0 -6
- package/dist/endpoints/models/converters.js +0 -42
- package/dist/endpoints/models/handler.d.ts +0 -2
- package/dist/endpoints/models/handler.js +0 -29
- package/dist/endpoints/models/index.d.ts +0 -3
- package/dist/endpoints/models/index.js +0 -3
- package/dist/endpoints/models/schema.d.ts +0 -42
- package/dist/endpoints/models/schema.js +0 -31
- package/dist/errors/ai-sdk.d.ts +0 -2
- package/dist/errors/ai-sdk.js +0 -52
- package/dist/errors/gateway.d.ts +0 -5
- package/dist/errors/gateway.js +0 -13
- package/dist/errors/openai.d.ts +0 -20
- package/dist/errors/openai.js +0 -40
- package/dist/errors/utils.d.ts +0 -22
- package/dist/errors/utils.js +0 -44
- package/dist/gateway.d.ts +0 -9
- package/dist/gateway.js +0 -34
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -13
- package/dist/lifecycle.d.ts +0 -2
- package/dist/lifecycle.js +0 -94
- package/dist/logger/default.d.ts +0 -4
- package/dist/logger/default.js +0 -81
- package/dist/logger/index.d.ts +0 -14
- package/dist/logger/index.js +0 -25
- package/dist/middleware/common.d.ts +0 -12
- package/dist/middleware/common.js +0 -145
- package/dist/middleware/matcher.d.ts +0 -27
- package/dist/middleware/matcher.js +0 -112
- package/dist/middleware/utils.d.ts +0 -2
- package/dist/middleware/utils.js +0 -27
- package/dist/models/amazon/index.d.ts +0 -2
- package/dist/models/amazon/index.js +0 -2
- package/dist/models/amazon/middleware.d.ts +0 -3
- package/dist/models/amazon/middleware.js +0 -65
- package/dist/models/amazon/presets.d.ts +0 -2390
- package/dist/models/amazon/presets.js +0 -80
- package/dist/models/anthropic/index.d.ts +0 -2
- package/dist/models/anthropic/index.js +0 -2
- package/dist/models/anthropic/middleware.d.ts +0 -4
- package/dist/models/anthropic/middleware.js +0 -111
- package/dist/models/anthropic/presets.d.ts +0 -4802
- package/dist/models/anthropic/presets.js +0 -135
- package/dist/models/catalog.d.ts +0 -4
- package/dist/models/catalog.js +0 -4
- package/dist/models/cohere/index.d.ts +0 -2
- package/dist/models/cohere/index.js +0 -2
- package/dist/models/cohere/middleware.d.ts +0 -3
- package/dist/models/cohere/middleware.js +0 -60
- package/dist/models/cohere/presets.d.ts +0 -2918
- package/dist/models/cohere/presets.js +0 -134
- package/dist/models/google/index.d.ts +0 -2
- package/dist/models/google/index.js +0 -2
- package/dist/models/google/middleware.d.ts +0 -7
- package/dist/models/google/middleware.js +0 -103
- package/dist/models/google/presets.d.ts +0 -2553
- package/dist/models/google/presets.js +0 -83
- package/dist/models/meta/index.d.ts +0 -1
- package/dist/models/meta/index.js +0 -1
- package/dist/models/meta/presets.d.ts +0 -3254
- package/dist/models/meta/presets.js +0 -95
- package/dist/models/openai/index.d.ts +0 -2
- package/dist/models/openai/index.js +0 -2
- package/dist/models/openai/middleware.d.ts +0 -3
- package/dist/models/openai/middleware.js +0 -62
- package/dist/models/openai/presets.d.ts +0 -6634
- package/dist/models/openai/presets.js +0 -213
- package/dist/models/types.d.ts +0 -20
- package/dist/models/types.js +0 -84
- package/dist/models/voyage/index.d.ts +0 -2
- package/dist/models/voyage/index.js +0 -2
- package/dist/models/voyage/middleware.d.ts +0 -2
- package/dist/models/voyage/middleware.js +0 -18
- package/dist/models/voyage/presets.d.ts +0 -3471
- package/dist/models/voyage/presets.js +0 -85
- package/dist/providers/anthropic/canonical.d.ts +0 -3
- package/dist/providers/anthropic/canonical.js +0 -9
- package/dist/providers/anthropic/index.d.ts +0 -1
- package/dist/providers/anthropic/index.js +0 -1
- package/dist/providers/bedrock/canonical.d.ts +0 -17
- package/dist/providers/bedrock/canonical.js +0 -61
- package/dist/providers/bedrock/index.d.ts +0 -2
- package/dist/providers/bedrock/index.js +0 -2
- package/dist/providers/bedrock/middleware.d.ts +0 -3
- package/dist/providers/bedrock/middleware.js +0 -55
- package/dist/providers/cohere/canonical.d.ts +0 -3
- package/dist/providers/cohere/canonical.js +0 -17
- package/dist/providers/cohere/index.d.ts +0 -1
- package/dist/providers/cohere/index.js +0 -1
- package/dist/providers/groq/canonical.d.ts +0 -3
- package/dist/providers/groq/canonical.js +0 -12
- package/dist/providers/groq/index.d.ts +0 -1
- package/dist/providers/groq/index.js +0 -1
- package/dist/providers/openai/canonical.d.ts +0 -3
- package/dist/providers/openai/canonical.js +0 -8
- package/dist/providers/openai/index.d.ts +0 -1
- package/dist/providers/openai/index.js +0 -1
- package/dist/providers/registry.d.ts +0 -24
- package/dist/providers/registry.js +0 -100
- package/dist/providers/types.d.ts +0 -7
- package/dist/providers/types.js +0 -11
- package/dist/providers/vertex/canonical.d.ts +0 -3
- package/dist/providers/vertex/canonical.js +0 -8
- package/dist/providers/vertex/index.d.ts +0 -1
- package/dist/providers/vertex/index.js +0 -1
- package/dist/providers/voyage/canonical.d.ts +0 -3
- package/dist/providers/voyage/canonical.js +0 -7
- package/dist/providers/voyage/index.d.ts +0 -1
- package/dist/providers/voyage/index.js +0 -1
- package/dist/telemetry/ai-sdk.d.ts +0 -2
- package/dist/telemetry/ai-sdk.js +0 -31
- package/dist/telemetry/baggage.d.ts +0 -1
- package/dist/telemetry/baggage.js +0 -24
- package/dist/telemetry/fetch.d.ts +0 -2
- package/dist/telemetry/fetch.js +0 -24
- package/dist/telemetry/gen-ai.d.ts +0 -5
- package/dist/telemetry/gen-ai.js +0 -60
- package/dist/telemetry/http.d.ts +0 -3
- package/dist/telemetry/http.js +0 -54
- package/dist/telemetry/memory.d.ts +0 -2
- package/dist/telemetry/memory.js +0 -27
- package/dist/telemetry/span.d.ts +0 -13
- package/dist/telemetry/span.js +0 -60
- package/dist/telemetry/stream.d.ts +0 -3
- package/dist/telemetry/stream.js +0 -51
- package/dist/types.d.ts +0 -176
- package/dist/types.js +0 -1
- package/dist/utils/env.d.ts +0 -2
- package/dist/utils/env.js +0 -5
- package/dist/utils/headers.d.ts +0 -4
- package/dist/utils/headers.js +0 -22
- package/dist/utils/preset.d.ts +0 -9
- package/dist/utils/preset.js +0 -41
- package/dist/utils/request.d.ts +0 -2
- package/dist/utils/request.js +0 -14
- package/dist/utils/response.d.ts +0 -3
- package/dist/utils/response.js +0 -68
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { presetFor } from "../../utils/preset";
|
|
2
|
-
const COMMAND_BASE = {
|
|
3
|
-
modalities: {
|
|
4
|
-
input: ["text"],
|
|
5
|
-
output: ["text"],
|
|
6
|
-
},
|
|
7
|
-
capabilities: ["tool_call", "structured_output", "reasoning", "temperature"],
|
|
8
|
-
providers: ["cohere"],
|
|
9
|
-
knowledge: "2024-06",
|
|
10
|
-
};
|
|
11
|
-
const COMMAND_VISION_BASE = {
|
|
12
|
-
modalities: {
|
|
13
|
-
input: ["text", "image"],
|
|
14
|
-
output: ["text"],
|
|
15
|
-
},
|
|
16
|
-
capabilities: ["structured_output", "reasoning", "temperature"],
|
|
17
|
-
providers: ["cohere"],
|
|
18
|
-
knowledge: "2024-06",
|
|
19
|
-
};
|
|
20
|
-
const EMBED_V3_BASE = {
|
|
21
|
-
modalities: {
|
|
22
|
-
input: ["text", "image"],
|
|
23
|
-
output: ["embedding"],
|
|
24
|
-
},
|
|
25
|
-
providers: ["cohere"],
|
|
26
|
-
};
|
|
27
|
-
const EMBED_V4_BASE = {
|
|
28
|
-
modalities: {
|
|
29
|
-
input: ["text", "image", "pdf"],
|
|
30
|
-
output: ["embedding"],
|
|
31
|
-
},
|
|
32
|
-
providers: ["cohere"],
|
|
33
|
-
};
|
|
34
|
-
export const commandA = presetFor()("cohere/command-a", {
|
|
35
|
-
...COMMAND_BASE,
|
|
36
|
-
name: "Cohere Command A",
|
|
37
|
-
created: "2025-03-13",
|
|
38
|
-
context: 256000,
|
|
39
|
-
});
|
|
40
|
-
export const commandAReasoning = presetFor()("cohere/command-a-reasoning", {
|
|
41
|
-
...COMMAND_BASE,
|
|
42
|
-
name: "Cohere Command A Reasoning",
|
|
43
|
-
created: "2025-08-21",
|
|
44
|
-
context: 256000,
|
|
45
|
-
});
|
|
46
|
-
export const commandATranslate = presetFor()("cohere/command-a-translate", {
|
|
47
|
-
...COMMAND_BASE,
|
|
48
|
-
name: "Cohere Command A Translate",
|
|
49
|
-
created: "2025-08-28",
|
|
50
|
-
context: 8000,
|
|
51
|
-
});
|
|
52
|
-
export const commandAVision = presetFor()("cohere/command-a-vision", {
|
|
53
|
-
...COMMAND_VISION_BASE,
|
|
54
|
-
name: "Cohere Command A Vision",
|
|
55
|
-
created: "2025-07-31",
|
|
56
|
-
context: 128000,
|
|
57
|
-
});
|
|
58
|
-
export const commandR = presetFor()("cohere/command-r", {
|
|
59
|
-
...COMMAND_BASE,
|
|
60
|
-
name: "Cohere Command R",
|
|
61
|
-
created: "2024-08-01",
|
|
62
|
-
context: 128000,
|
|
63
|
-
providers: ["cohere", "bedrock"],
|
|
64
|
-
});
|
|
65
|
-
export const commandRPlus = presetFor()("cohere/command-r-plus", {
|
|
66
|
-
...COMMAND_BASE,
|
|
67
|
-
name: "Cohere Command R+",
|
|
68
|
-
created: "2024-08-01",
|
|
69
|
-
context: 128000,
|
|
70
|
-
providers: ["cohere", "bedrock"],
|
|
71
|
-
});
|
|
72
|
-
export const commandR7b = presetFor()("cohere/command-r7b", {
|
|
73
|
-
...COMMAND_BASE,
|
|
74
|
-
name: "Cohere Command R7B",
|
|
75
|
-
created: "2024-12-13",
|
|
76
|
-
context: 128000,
|
|
77
|
-
});
|
|
78
|
-
export const embed4 = presetFor()("cohere/embed-v4.0", {
|
|
79
|
-
...EMBED_V4_BASE,
|
|
80
|
-
name: "Cohere 4 Embeddings",
|
|
81
|
-
created: "2025-04-15",
|
|
82
|
-
context: 128000,
|
|
83
|
-
providers: ["cohere", "bedrock"],
|
|
84
|
-
});
|
|
85
|
-
export const embedEnglishV3 = presetFor()("cohere/embed-english-v3.0", {
|
|
86
|
-
...EMBED_V3_BASE,
|
|
87
|
-
name: "Cohere Embed English v3",
|
|
88
|
-
created: "2024-02-07",
|
|
89
|
-
context: 512,
|
|
90
|
-
providers: ["cohere", "bedrock"],
|
|
91
|
-
});
|
|
92
|
-
export const embedEnglishLightV3 = presetFor()("cohere/embed-english-light-v3.0", {
|
|
93
|
-
...EMBED_V3_BASE,
|
|
94
|
-
name: "Cohere Embed English Light v3",
|
|
95
|
-
created: "2024-02-07",
|
|
96
|
-
context: 512,
|
|
97
|
-
providers: ["cohere"],
|
|
98
|
-
});
|
|
99
|
-
export const embedMultilingualV3 = presetFor()("cohere/embed-multilingual-v3.0", {
|
|
100
|
-
...EMBED_V3_BASE,
|
|
101
|
-
name: "Cohere Embed Multilingual v3",
|
|
102
|
-
created: "2024-02-07",
|
|
103
|
-
context: 512,
|
|
104
|
-
providers: ["cohere", "bedrock"],
|
|
105
|
-
});
|
|
106
|
-
export const embedMultilingualLightV3 = presetFor()("cohere/embed-multilingual-light-v3.0", {
|
|
107
|
-
...EMBED_V3_BASE,
|
|
108
|
-
name: "Cohere Embed Multilingual Light v3",
|
|
109
|
-
created: "2024-02-07",
|
|
110
|
-
context: 512,
|
|
111
|
-
providers: ["cohere"],
|
|
112
|
-
});
|
|
113
|
-
const commandAtomic = {
|
|
114
|
-
A: [commandA, commandAReasoning, commandATranslate, commandAVision],
|
|
115
|
-
R: [commandR, commandRPlus, commandR7b],
|
|
116
|
-
};
|
|
117
|
-
const commandGroups = {};
|
|
118
|
-
export const command = {
|
|
119
|
-
...commandAtomic,
|
|
120
|
-
...commandGroups,
|
|
121
|
-
latest: [commandA],
|
|
122
|
-
all: Object.values(commandAtomic).flat(),
|
|
123
|
-
};
|
|
124
|
-
const embedAtomic = {
|
|
125
|
-
v4: [embed4],
|
|
126
|
-
v3: [embedEnglishV3, embedEnglishLightV3, embedMultilingualV3, embedMultilingualLightV3],
|
|
127
|
-
};
|
|
128
|
-
const embedGroups = {};
|
|
129
|
-
export const embed = {
|
|
130
|
-
...embedAtomic,
|
|
131
|
-
...embedGroups,
|
|
132
|
-
latest: [embed4],
|
|
133
|
-
all: Object.values(embedAtomic).flat(),
|
|
134
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { EmbeddingModelMiddleware, LanguageModelMiddleware } from "ai";
|
|
2
|
-
import type { ChatCompletionsReasoningEffort } from "../../endpoints/chat-completions/schema";
|
|
3
|
-
export declare const geminiDimensionsMiddleware: EmbeddingModelMiddleware;
|
|
4
|
-
export declare function mapGeminiReasoningEffort(effort: ChatCompletionsReasoningEffort, modelId: string): ChatCompletionsReasoningEffort | undefined;
|
|
5
|
-
export declare const GEMINI_DEFAULT_MAX_OUTPUT_TOKENS = 65536;
|
|
6
|
-
export declare const GEMINI_2_5_PRO_MIN_THINKING_BUDGET = 128;
|
|
7
|
-
export declare const geminiReasoningMiddleware: LanguageModelMiddleware;
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { modelMiddlewareMatcher } from "../../middleware/matcher";
|
|
2
|
-
import { calculateReasoningBudgetFromEffort } from "../../middleware/utils";
|
|
3
|
-
// Convert `dimensions` (OpenAI) to `outputDimensionality` (Google)
|
|
4
|
-
export const geminiDimensionsMiddleware = {
|
|
5
|
-
specificationVersion: "v3",
|
|
6
|
-
// eslint-disable-next-line require-await
|
|
7
|
-
transformParams: async ({ params }) => {
|
|
8
|
-
const unknown = params.providerOptions?.["unknown"];
|
|
9
|
-
if (!unknown)
|
|
10
|
-
return params;
|
|
11
|
-
const dimensions = unknown["dimensions"];
|
|
12
|
-
if (!dimensions)
|
|
13
|
-
return params;
|
|
14
|
-
(params.providerOptions["google"] ??= {})["outputDimensionality"] = dimensions;
|
|
15
|
-
delete unknown["dimensions"];
|
|
16
|
-
return params;
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
// https://ai.google.dev/gemini-api/docs/thinking#thinking-levels
|
|
20
|
-
export function mapGeminiReasoningEffort(effort, modelId) {
|
|
21
|
-
if (modelId.includes("gemini-3.1-pro")) {
|
|
22
|
-
switch (effort) {
|
|
23
|
-
case "none":
|
|
24
|
-
case "minimal":
|
|
25
|
-
case "low":
|
|
26
|
-
return "low";
|
|
27
|
-
case "medium":
|
|
28
|
-
return "medium";
|
|
29
|
-
case "high":
|
|
30
|
-
case "xhigh":
|
|
31
|
-
case "max":
|
|
32
|
-
return "high";
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (modelId.includes("gemini-3-pro")) {
|
|
36
|
-
switch (effort) {
|
|
37
|
-
case "none":
|
|
38
|
-
case "minimal":
|
|
39
|
-
case "low":
|
|
40
|
-
return "low";
|
|
41
|
-
case "medium":
|
|
42
|
-
case "high":
|
|
43
|
-
case "xhigh":
|
|
44
|
-
case "max":
|
|
45
|
-
return "high";
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (modelId.includes("gemini-3-flash")) {
|
|
49
|
-
switch (effort) {
|
|
50
|
-
case "none":
|
|
51
|
-
case "minimal":
|
|
52
|
-
return "minimal";
|
|
53
|
-
case "low":
|
|
54
|
-
return "low";
|
|
55
|
-
case "medium":
|
|
56
|
-
return "medium";
|
|
57
|
-
case "high":
|
|
58
|
-
case "xhigh":
|
|
59
|
-
case "max":
|
|
60
|
-
return "high";
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return effort;
|
|
64
|
-
}
|
|
65
|
-
export const GEMINI_DEFAULT_MAX_OUTPUT_TOKENS = 65536;
|
|
66
|
-
export const GEMINI_2_5_PRO_MIN_THINKING_BUDGET = 128;
|
|
67
|
-
export const geminiReasoningMiddleware = {
|
|
68
|
-
specificationVersion: "v3",
|
|
69
|
-
// eslint-disable-next-line require-await
|
|
70
|
-
transformParams: async ({ params, model }) => {
|
|
71
|
-
const unknown = params.providerOptions?.["unknown"];
|
|
72
|
-
if (!unknown)
|
|
73
|
-
return params;
|
|
74
|
-
const reasoning = unknown["reasoning"];
|
|
75
|
-
if (!reasoning)
|
|
76
|
-
return params;
|
|
77
|
-
const target = (params.providerOptions["google"] ??= {});
|
|
78
|
-
const modelId = model.modelId;
|
|
79
|
-
if (modelId.includes("gemini-2")) {
|
|
80
|
-
const is25Pro = modelId.includes("gemini-2.5-pro");
|
|
81
|
-
target["thinkingConfig"] = {
|
|
82
|
-
thinkingBudget: reasoning.max_tokens ??
|
|
83
|
-
calculateReasoningBudgetFromEffort(reasoning.effort ?? "none", params.maxOutputTokens ?? GEMINI_DEFAULT_MAX_OUTPUT_TOKENS, is25Pro ? GEMINI_2_5_PRO_MIN_THINKING_BUDGET : 0),
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
else if (modelId.includes("gemini-3") && reasoning.effort) {
|
|
87
|
-
target["thinkingConfig"] = {
|
|
88
|
-
thinkingLevel: mapGeminiReasoningEffort(reasoning.effort, modelId),
|
|
89
|
-
};
|
|
90
|
-
// FUTURE: warn if model is gemini-3 and max_tokens (unsupported) was ignored
|
|
91
|
-
}
|
|
92
|
-
(target["thinkingConfig"] ??= {})["includeThoughts"] =
|
|
93
|
-
reasoning.enabled ? !reasoning.exclude : false;
|
|
94
|
-
delete unknown["reasoning"];
|
|
95
|
-
return params;
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
modelMiddlewareMatcher.useForModel("google/gemini-*embedding-*", {
|
|
99
|
-
embedding: [geminiDimensionsMiddleware],
|
|
100
|
-
});
|
|
101
|
-
modelMiddlewareMatcher.useForModel(["google/gemini-2*", "google/gemini-3*"], {
|
|
102
|
-
language: [geminiReasoningMiddleware],
|
|
103
|
-
});
|