@zhivex-ai/gateway 0.1.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/dist/compat.d.ts +7 -0
- package/dist/compat.d.ts.map +1 -0
- package/dist/compat.js +46 -0
- package/dist/compat.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +194 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +72 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +32 -0
package/dist/compat.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ModelMessage } from "@zhivex-ai/core";
|
|
2
|
+
import type { GatewayMessage, GatewayModelTarget, GatewayProviderId, GatewayResponse } from "./types.js";
|
|
3
|
+
export declare const supportsVisionInput: (provider: GatewayProviderId, modelId: string) => boolean;
|
|
4
|
+
export declare const stripImagesForUnsupportedModel: (messages: GatewayMessage[], provider: GatewayProviderId, modelId: string) => GatewayMessage[];
|
|
5
|
+
export declare const gatewayMessagesToModelMessages: (messages: GatewayMessage[], systemPrompt?: string) => ModelMessage[];
|
|
6
|
+
export declare const createRouteDecision: (mode: GatewayResponse["routeDecision"]["mode"], intent: GatewayResponse["routeDecision"]["intent"], orderedTargets: GatewayModelTarget[]) => GatewayResponse["routeDecision"];
|
|
7
|
+
//# sourceMappingURL=compat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["../src/compat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EAChB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,mBAAmB,GAAI,UAAU,iBAAiB,EAAE,SAAS,MAAM,KAAG,OAYlF,CAAC;AAEF,eAAO,MAAM,8BAA8B,GACzC,UAAU,cAAc,EAAE,EAC1B,UAAU,iBAAiB,EAC3B,SAAS,MAAM,KACd,cAAc,EAMhB,CAAC;AAEF,eAAO,MAAM,8BAA8B,GACzC,UAAU,cAAc,EAAE,EAC1B,eAAe,MAAM,KACpB,YAAY,EAyBd,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,MAAM,eAAe,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,EAC9C,QAAQ,eAAe,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,EAClD,gBAAgB,kBAAkB,EAAE,KACnC,eAAe,CAAC,eAAe,CAKhC,CAAC"}
|
package/dist/compat.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const supportsVisionInput = (provider, modelId) => {
|
|
2
|
+
const model = modelId.toLowerCase();
|
|
3
|
+
if (provider === "gemini") {
|
|
4
|
+
return !model.includes("embedding");
|
|
5
|
+
}
|
|
6
|
+
if (provider === "bedrock") {
|
|
7
|
+
return model.includes("nova") || model.includes("claude-3") || model.includes("claude-4");
|
|
8
|
+
}
|
|
9
|
+
return true;
|
|
10
|
+
};
|
|
11
|
+
export const stripImagesForUnsupportedModel = (messages, provider, modelId) => {
|
|
12
|
+
if (supportsVisionInput(provider, modelId)) {
|
|
13
|
+
return messages;
|
|
14
|
+
}
|
|
15
|
+
return messages.map((message) => (message.images?.length ? { ...message, images: [] } : message));
|
|
16
|
+
};
|
|
17
|
+
export const gatewayMessagesToModelMessages = (messages, systemPrompt) => {
|
|
18
|
+
const mappedMessages = [];
|
|
19
|
+
if (systemPrompt) {
|
|
20
|
+
mappedMessages.push({
|
|
21
|
+
role: "system",
|
|
22
|
+
parts: [{ type: "text", text: systemPrompt }]
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
for (const message of messages) {
|
|
26
|
+
mappedMessages.push({
|
|
27
|
+
role: message.role,
|
|
28
|
+
parts: [
|
|
29
|
+
{ type: "text", text: message.content },
|
|
30
|
+
...((message.images ?? []).map((image) => ({
|
|
31
|
+
type: "image",
|
|
32
|
+
image: image.dataUrl,
|
|
33
|
+
mediaType: image.mimeType
|
|
34
|
+
})) ?? [])
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return mappedMessages;
|
|
39
|
+
};
|
|
40
|
+
export const createRouteDecision = (mode, intent, orderedTargets) => ({
|
|
41
|
+
mode,
|
|
42
|
+
intent,
|
|
43
|
+
orderedTargets,
|
|
44
|
+
reason: `Ordered by ${mode} mode with ${intent} intent.`
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=compat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compat.js","sourceRoot":"","sources":["../src/compat.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,QAA2B,EAAE,OAAe,EAAW,EAAE;IAC3F,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAEpC,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC5F,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAC5C,QAA0B,EAC1B,QAA2B,EAC3B,OAAe,EACG,EAAE;IACpB,IAAI,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC;QAC3C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO,QAAQ,CAAC,GAAG,CAAC,C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CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type GatewayConfig, type GatewayRequest, type GatewayResponse } from "./types.js";
|
|
2
|
+
export declare const createGateway: (config: GatewayConfig) => {
|
|
3
|
+
generate(request: GatewayRequest): Promise<GatewayResponse>;
|
|
4
|
+
};
|
|
5
|
+
export * from "./compat.js";
|
|
6
|
+
export * from "./types.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,aAAa,EAGlB,KAAK,cAAc,EACnB,KAAK,eAAe,EAGrB,MAAM,YAAY,CAAC;AA8HpB,eAAO,MAAM,aAAa,GAAI,QAAQ,aAAa;sBAUvB,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;CA+GpE,CAAC;AAEF,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { generateText } from "@zhivex-ai/core";
|
|
2
|
+
import { createRouteDecision, gatewayMessagesToModelMessages, stripImagesForUnsupportedModel } from "./compat.js";
|
|
3
|
+
import { GatewayError } from "./types.js";
|
|
4
|
+
const scoreTarget = (mode, intent, target, config) => {
|
|
5
|
+
const model = target.modelId.toLowerCase();
|
|
6
|
+
const localBoost = target.provider === "ollama" ? -2 : 0;
|
|
7
|
+
const qualityBoost = model.includes("pro") || model.includes("claude") ? 2 : 0;
|
|
8
|
+
const speedBoost = model.includes("flash") || model.includes("lite") ? 2 : 0;
|
|
9
|
+
const reasoningBoost = model.includes("pro") || model.includes("claude") ? 2 : 0;
|
|
10
|
+
const catalogCost = config.modelCatalog?.find(target.provider, target.modelId)?.costPer1kTokens;
|
|
11
|
+
const costPenalty = config.providerCostsPer1kTokens?.[target.provider] ?? catalogCost ?? 0;
|
|
12
|
+
const latencyPenalty = (config.latencyBiasMs?.[target.provider] ?? 0) / 100;
|
|
13
|
+
if (mode === "speed") {
|
|
14
|
+
return speedBoost + localBoost - latencyPenalty;
|
|
15
|
+
}
|
|
16
|
+
if (mode === "quality") {
|
|
17
|
+
return qualityBoost + (intent === "reasoning" ? reasoningBoost : 0) - costPenalty;
|
|
18
|
+
}
|
|
19
|
+
return speedBoost + qualityBoost + localBoost + (intent === "reasoning" ? 1 : 0) - costPenalty - latencyPenalty;
|
|
20
|
+
};
|
|
21
|
+
const orderTargets = (mode, intent, primary, fallbacks, config) => [primary, ...fallbacks]
|
|
22
|
+
.filter((target, index, list) => list.findIndex((candidate) => candidate.provider === target.provider && candidate.modelId === target.modelId) === index)
|
|
23
|
+
.sort((left, right) => scoreTarget(mode, intent, right, config) - scoreTarget(mode, intent, left, config));
|
|
24
|
+
const supportsRequiredCapabilities = (adapter, target, requiredCapabilities) => {
|
|
25
|
+
if (!requiredCapabilities) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
const capabilities = adapter.languageModel(target.modelId).capabilities;
|
|
29
|
+
return Object.entries(requiredCapabilities).every(([key, required]) => required !== true || capabilities[key] === true);
|
|
30
|
+
};
|
|
31
|
+
const withinCostBudget = (config, request, target) => {
|
|
32
|
+
if (request.maxCostPer1kTokens == null) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
const configuredCost = config.providerCostsPer1kTokens?.[target.provider];
|
|
36
|
+
const catalogCost = config.modelCatalog?.find(target.provider, target.modelId)?.costPer1kTokens;
|
|
37
|
+
const effectiveCost = configuredCost ?? catalogCost;
|
|
38
|
+
if (effectiveCost == null) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return effectiveCost <= request.maxCostPer1kTokens;
|
|
42
|
+
};
|
|
43
|
+
const estimateTokens = (text) => Math.max(1, Math.ceil(text.trim().length / 4));
|
|
44
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
45
|
+
const withTimeout = async (promise, timeoutMs) => new Promise((resolve, reject) => {
|
|
46
|
+
const timer = setTimeout(() => reject(new GatewayError(`Provider timed out after ${timeoutMs}ms.`, true)), timeoutMs);
|
|
47
|
+
promise
|
|
48
|
+
.then((value) => {
|
|
49
|
+
clearTimeout(timer);
|
|
50
|
+
resolve(value);
|
|
51
|
+
})
|
|
52
|
+
.catch((error) => {
|
|
53
|
+
clearTimeout(timer);
|
|
54
|
+
reject(error);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
const normalizeError = (error) => {
|
|
58
|
+
if (error instanceof GatewayError) {
|
|
59
|
+
return error;
|
|
60
|
+
}
|
|
61
|
+
if (error instanceof Error) {
|
|
62
|
+
const message = error.message.toLowerCase();
|
|
63
|
+
if (message.includes("timed out") || message.includes("429") || message.includes("rate")) {
|
|
64
|
+
return new GatewayError(error.message, true);
|
|
65
|
+
}
|
|
66
|
+
if (message.includes("connect") || message.includes("econnrefused") || message.includes("503")) {
|
|
67
|
+
return new GatewayError(error.message, true);
|
|
68
|
+
}
|
|
69
|
+
return new GatewayError(error.message, false);
|
|
70
|
+
}
|
|
71
|
+
return new GatewayError("Unknown gateway error.", false);
|
|
72
|
+
};
|
|
73
|
+
const getAttemptTimeoutMs = (config, provider) => config.attemptTimeoutsMs?.[provider] ?? config.attemptTimeoutMs ?? 20_000;
|
|
74
|
+
const retryBackoffMs = (config, retry) => (config.retryBackoffMs ?? 200) * (retry + 1);
|
|
75
|
+
const normalizeUsage = (usage, inputText, outputText) => {
|
|
76
|
+
const inputTokens = usage?.inputTokens ?? estimateTokens(inputText);
|
|
77
|
+
const outputTokens = usage?.outputTokens ?? estimateTokens(outputText);
|
|
78
|
+
const totalTokens = usage?.totalTokens ?? inputTokens + outputTokens;
|
|
79
|
+
return {
|
|
80
|
+
inputTokens,
|
|
81
|
+
outputTokens,
|
|
82
|
+
totalTokens,
|
|
83
|
+
estimated: usage?.inputTokens == null || usage?.outputTokens == null || usage?.totalTokens == null
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
export const createGateway = (config) => {
|
|
87
|
+
const getAdapter = (provider) => {
|
|
88
|
+
const adapter = config.adapters[provider];
|
|
89
|
+
if (!adapter) {
|
|
90
|
+
throw new GatewayError(`No adapter registered for provider "${provider}".`, false);
|
|
91
|
+
}
|
|
92
|
+
return adapter;
|
|
93
|
+
};
|
|
94
|
+
return {
|
|
95
|
+
async generate(request) {
|
|
96
|
+
const attempts = [];
|
|
97
|
+
const startedAt = Date.now();
|
|
98
|
+
const mode = request.routingMode ?? "balanced";
|
|
99
|
+
const intent = request.taskIntent ?? "chat";
|
|
100
|
+
const orderedTargets = orderTargets(mode, intent, request.primary, request.fallbacks ?? [], config);
|
|
101
|
+
const routeDecision = createRouteDecision(mode, intent, orderedTargets);
|
|
102
|
+
const maxRetries = Math.max(0, config.maxRetries ?? 2);
|
|
103
|
+
for (const [targetIndex, target] of orderedTargets.entries()) {
|
|
104
|
+
const adapter = getAdapter(target.provider);
|
|
105
|
+
if (!supportsRequiredCapabilities(adapter, target, request.requiredCapabilities)) {
|
|
106
|
+
attempts.push({
|
|
107
|
+
provider: target.provider,
|
|
108
|
+
modelId: target.modelId,
|
|
109
|
+
ok: false,
|
|
110
|
+
latencyMs: 0,
|
|
111
|
+
errorMessage: "Skipped because model capabilities do not satisfy the request."
|
|
112
|
+
});
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (!withinCostBudget(config, request, target)) {
|
|
116
|
+
attempts.push({
|
|
117
|
+
provider: target.provider,
|
|
118
|
+
modelId: target.modelId,
|
|
119
|
+
ok: false,
|
|
120
|
+
latencyMs: 0,
|
|
121
|
+
errorMessage: "Skipped because provider cost exceeds the configured budget."
|
|
122
|
+
});
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
for (let retry = 0; retry <= maxRetries; retry += 1) {
|
|
126
|
+
const attemptStartedAt = Date.now();
|
|
127
|
+
try {
|
|
128
|
+
const providerMessages = stripImagesForUnsupportedModel(request.messages, target.provider, target.modelId);
|
|
129
|
+
await config.onAttempt?.({
|
|
130
|
+
provider: target.provider,
|
|
131
|
+
modelId: target.modelId,
|
|
132
|
+
ok: true,
|
|
133
|
+
latencyMs: 0,
|
|
134
|
+
retry,
|
|
135
|
+
targetRank: targetIndex
|
|
136
|
+
});
|
|
137
|
+
const result = await withTimeout(generateText({
|
|
138
|
+
model: adapter.languageModel(target.modelId),
|
|
139
|
+
messages: gatewayMessagesToModelMessages(providerMessages, request.systemPrompt),
|
|
140
|
+
temperature: request.temperature,
|
|
141
|
+
maxTokens: request.maxTokens,
|
|
142
|
+
abortSignal: request.abortSignal
|
|
143
|
+
}), getAttemptTimeoutMs(config, target.provider));
|
|
144
|
+
attempts.push({
|
|
145
|
+
provider: target.provider,
|
|
146
|
+
modelId: target.modelId,
|
|
147
|
+
ok: true,
|
|
148
|
+
latencyMs: Date.now() - attemptStartedAt
|
|
149
|
+
});
|
|
150
|
+
const inputText = `${request.systemPrompt ?? ""}\n${providerMessages.map((message) => message.content).join("\n")}`.trim();
|
|
151
|
+
return {
|
|
152
|
+
text: result.text,
|
|
153
|
+
providerUsed: target.provider,
|
|
154
|
+
modelUsed: target.modelId,
|
|
155
|
+
latencyMs: Date.now() - startedAt,
|
|
156
|
+
attempts,
|
|
157
|
+
usage: normalizeUsage(result.usage, inputText, result.text),
|
|
158
|
+
routeDecision
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
const normalized = normalizeError(error);
|
|
163
|
+
attempts.push({
|
|
164
|
+
provider: target.provider,
|
|
165
|
+
modelId: target.modelId,
|
|
166
|
+
ok: false,
|
|
167
|
+
latencyMs: Date.now() - attemptStartedAt,
|
|
168
|
+
errorMessage: normalized.message
|
|
169
|
+
});
|
|
170
|
+
await config.onAttempt?.({
|
|
171
|
+
provider: target.provider,
|
|
172
|
+
modelId: target.modelId,
|
|
173
|
+
ok: false,
|
|
174
|
+
latencyMs: Date.now() - attemptStartedAt,
|
|
175
|
+
errorMessage: normalized.message,
|
|
176
|
+
retry,
|
|
177
|
+
targetRank: targetIndex
|
|
178
|
+
});
|
|
179
|
+
if (retry < maxRetries && normalized.retryable) {
|
|
180
|
+
await sleep(retryBackoffMs(config, retry));
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const finalError = attempts.at(-1)?.errorMessage ?? "All gateway attempts failed.";
|
|
188
|
+
throw new GatewayError(finalError, false);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
export * from "./compat.js";
|
|
193
|
+
export * from "./types.js";
|
|
194
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAE,mBAAmB,EAAE,8BAA8B,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAClH,OAAO,EACL,YAAY,EASb,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,GAAG,CAClB,IAAwB,EACxB,MAAyB,EACzB,MAA0B,EAC1B,MAAqB,EACrB,EAAE;IACF,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IAC3C,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,MAAM,YAAY,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/E,MAAM,UAAU,GAAG,KAAK,CAAC,QAAQ,CA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1
|
+
import type { ModelCatalog, ProviderAdapter, TokenUsage } from "@zhivex-ai/core";
|
|
2
|
+
export type GatewayProviderId = "openai" | "anthropic" | "gemini" | "bedrock" | "ollama" | "azure-openai" | "openrouter";
|
|
3
|
+
export type GatewayRoutingMode = "speed" | "balanced" | "quality";
|
|
4
|
+
export type GatewayTaskIntent = "chat" | "reasoning" | "tool-heavy";
|
|
5
|
+
export interface GatewayImageAttachment {
|
|
6
|
+
dataUrl: string;
|
|
7
|
+
mimeType: string;
|
|
8
|
+
}
|
|
9
|
+
export interface GatewayMessage {
|
|
10
|
+
role: "user" | "assistant";
|
|
11
|
+
content: string;
|
|
12
|
+
images?: GatewayImageAttachment[];
|
|
13
|
+
}
|
|
14
|
+
export interface GatewayModelTarget {
|
|
15
|
+
provider: GatewayProviderId;
|
|
16
|
+
modelId: string;
|
|
17
|
+
}
|
|
18
|
+
export interface GatewayRequest {
|
|
19
|
+
messages: GatewayMessage[];
|
|
20
|
+
systemPrompt?: string;
|
|
21
|
+
temperature?: number;
|
|
22
|
+
maxTokens?: number;
|
|
23
|
+
requiredCapabilities?: Partial<Record<"streaming" | "tools" | "structuredOutput" | "jsonMode" | "vision" | "reasoning", boolean>>;
|
|
24
|
+
maxCostPer1kTokens?: number;
|
|
25
|
+
routingMode?: GatewayRoutingMode;
|
|
26
|
+
taskIntent?: GatewayTaskIntent;
|
|
27
|
+
abortSignal?: AbortSignal;
|
|
28
|
+
primary: GatewayModelTarget;
|
|
29
|
+
fallbacks?: GatewayModelTarget[];
|
|
30
|
+
}
|
|
31
|
+
export interface GatewayAttempt {
|
|
32
|
+
provider: GatewayProviderId;
|
|
33
|
+
modelId: string;
|
|
34
|
+
ok: boolean;
|
|
35
|
+
latencyMs: number;
|
|
36
|
+
errorMessage?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface GatewayResponse {
|
|
39
|
+
text: string;
|
|
40
|
+
providerUsed: GatewayProviderId;
|
|
41
|
+
modelUsed: string;
|
|
42
|
+
latencyMs: number;
|
|
43
|
+
attempts: GatewayAttempt[];
|
|
44
|
+
usage: TokenUsage & {
|
|
45
|
+
estimated: boolean;
|
|
46
|
+
};
|
|
47
|
+
routeDecision: {
|
|
48
|
+
mode: GatewayRoutingMode;
|
|
49
|
+
intent: GatewayTaskIntent;
|
|
50
|
+
orderedTargets: GatewayModelTarget[];
|
|
51
|
+
reason: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export interface GatewayConfig {
|
|
55
|
+
adapters: Partial<Record<GatewayProviderId, ProviderAdapter>>;
|
|
56
|
+
modelCatalog?: ModelCatalog;
|
|
57
|
+
providerCostsPer1kTokens?: Partial<Record<GatewayProviderId, number>>;
|
|
58
|
+
latencyBiasMs?: Partial<Record<GatewayProviderId, number>>;
|
|
59
|
+
maxRetries?: number;
|
|
60
|
+
attemptTimeoutMs?: number;
|
|
61
|
+
attemptTimeoutsMs?: Partial<Record<GatewayProviderId, number>>;
|
|
62
|
+
retryBackoffMs?: number;
|
|
63
|
+
onAttempt?: (attempt: GatewayAttempt & {
|
|
64
|
+
retry: number;
|
|
65
|
+
targetRank: number;
|
|
66
|
+
}) => void | Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
export declare class GatewayError extends Error {
|
|
69
|
+
readonly retryable: boolean;
|
|
70
|
+
constructor(message: string, retryable: boolean);
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEjF,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,cAAc,GAAG,YAAY,CAAC;AACzH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS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
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAuEA,MAAM,OAAO,YAAa,SAAQ,KAAK;IAG1B;IAFX,YACE,OAAe,EACN,SAAkB;QAE3B,KAAK,CAAC,OAAO,CAAC,CAAC;QAFN,cAAS,GAAT,SAAS,CAAS;QAG3B,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zhivex-ai/gateway",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": ["dist"],
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/Zhivex/zhivex-ai-sdk.git",
|
|
19
|
+
"directory": "packages/gateway"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/Zhivex/zhivex-ai-sdk#readme",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/Zhivex/zhivex-ai-sdk/issues"
|
|
24
|
+
},
|
|
25
|
+
"keywords": ["ai", "sdk", "gateway", "routing", "typescript"],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@zhivex-ai/core": "^0.1.0"
|
|
31
|
+
}
|
|
32
|
+
}
|