@abhishek944/pi-embeddings 0.2.0 → 0.4.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 +44 -4
- package/dist/execute.js +20 -2
- package/dist/extension.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/providers.d.ts +5 -1
- package/dist/providers.js +112 -2
- package/dist/response.d.ts +15 -0
- package/dist/response.js +72 -0
- package/dist/schemas.d.ts +317 -22
- package/dist/schemas.js +91 -0
- package/dist/settings-write.js +2 -2
- package/dist/settings.js +6 -1
- package/dist/tool-contracts.d.ts +141 -9
- package/dist/vertex-provider.d.ts +18 -0
- package/dist/vertex-provider.js +139 -0
- package/package.json +9 -2
- package/src/execute.ts +19 -2
- package/src/extension.ts +2 -2
- package/src/index.ts +10 -0
- package/src/providers.ts +138 -1
- package/src/response.ts +84 -0
- package/src/schemas.ts +112 -0
- package/src/settings-write.ts +2 -2
- package/src/settings.ts +6 -0
- package/src/vertex-provider.ts +152 -0
package/dist/schemas.js
CHANGED
|
@@ -19,6 +19,8 @@ export const EMBEDDING_ROUTE_IDS = [
|
|
|
19
19
|
'gateway',
|
|
20
20
|
'openrouter',
|
|
21
21
|
'cloudflare',
|
|
22
|
+
'gemini',
|
|
23
|
+
'vertex',
|
|
22
24
|
];
|
|
23
25
|
export const GATEWAY_EMBEDDING_MODELS = [
|
|
24
26
|
'text-embedding-3-small',
|
|
@@ -26,12 +28,59 @@ export const GATEWAY_EMBEDDING_MODELS = [
|
|
|
26
28
|
];
|
|
27
29
|
export const OPENROUTER_EMBEDDING_MODELS = ['openai/text-embedding-3-small'];
|
|
28
30
|
export const CLOUDFLARE_EMBEDDING_MODELS = ['@cf/baai/bge-base-en-v1.5'];
|
|
31
|
+
export const GEMINI_EMBEDDING_MODELS = ['gemini-embedding-2'];
|
|
32
|
+
export const GEMINI_EMBEDDING_MIN_DIMENSIONS = 128;
|
|
33
|
+
export const GEMINI_EMBEDDING_MAX_DIMENSIONS = 3072;
|
|
34
|
+
export const DEFAULT_GEMINI_DIMENSIONS = 3072;
|
|
35
|
+
export const GEMINI_EMBEDDING_TASK_FORMATS = [
|
|
36
|
+
'retrieval-document',
|
|
37
|
+
'search-query',
|
|
38
|
+
'question-answering',
|
|
39
|
+
'fact-checking',
|
|
40
|
+
'code-retrieval',
|
|
41
|
+
'classification',
|
|
42
|
+
'clustering',
|
|
43
|
+
'sentence-similarity',
|
|
44
|
+
];
|
|
45
|
+
export const DEFAULT_GEMINI_TASK_FORMAT = 'retrieval-document';
|
|
46
|
+
/** Official Gemini Embedding 2 text task prefixes. `task_type` is not used for this model. */
|
|
47
|
+
export const GEMINI_TASK_PREFIXES = {
|
|
48
|
+
'retrieval-document': 'title: none | text: ',
|
|
49
|
+
'search-query': 'task: search result | query: ',
|
|
50
|
+
'question-answering': 'task: question answering | query: ',
|
|
51
|
+
'fact-checking': 'task: fact checking | query: ',
|
|
52
|
+
'code-retrieval': 'task: code retrieval | query: ',
|
|
53
|
+
classification: 'task: classification | query: ',
|
|
54
|
+
clustering: 'task: clustering | query: ',
|
|
55
|
+
'sentence-similarity': 'task: sentence similarity | query: ',
|
|
56
|
+
};
|
|
29
57
|
const gatewayModelSchema = Type.Union([
|
|
30
58
|
Type.Literal('text-embedding-3-small'),
|
|
31
59
|
Type.Literal('openai/text-embedding-3-small'),
|
|
32
60
|
]);
|
|
33
61
|
const openRouterModelSchema = Type.Literal('openai/text-embedding-3-small');
|
|
34
62
|
const cloudflareModelSchema = Type.Literal('@cf/baai/bge-base-en-v1.5');
|
|
63
|
+
const geminiModelSchema = Type.Literal(GEMINI_EMBEDDING_MODELS[0]);
|
|
64
|
+
export const VERTEX_EMBEDDING_LOCATIONS = ['us', 'eu', 'global'];
|
|
65
|
+
const vertexLocationSchema = Type.Union([
|
|
66
|
+
Type.Literal('us'),
|
|
67
|
+
Type.Literal('eu'),
|
|
68
|
+
Type.Literal('global'),
|
|
69
|
+
]);
|
|
70
|
+
const geminiDimensionsSchema = Type.Integer({
|
|
71
|
+
minimum: GEMINI_EMBEDDING_MIN_DIMENSIONS,
|
|
72
|
+
maximum: GEMINI_EMBEDDING_MAX_DIMENSIONS,
|
|
73
|
+
});
|
|
74
|
+
const geminiTaskFormatSchema = Type.Union([
|
|
75
|
+
Type.Literal('retrieval-document'),
|
|
76
|
+
Type.Literal('search-query'),
|
|
77
|
+
Type.Literal('question-answering'),
|
|
78
|
+
Type.Literal('fact-checking'),
|
|
79
|
+
Type.Literal('code-retrieval'),
|
|
80
|
+
Type.Literal('classification'),
|
|
81
|
+
Type.Literal('clustering'),
|
|
82
|
+
Type.Literal('sentence-similarity'),
|
|
83
|
+
]);
|
|
35
84
|
const embeddingErrorCodeSchema = Type.Union([
|
|
36
85
|
Type.Literal('configuration-invalid'),
|
|
37
86
|
Type.Literal('route-unconfigured'),
|
|
@@ -93,6 +142,8 @@ const embeddingProviderSchema = Type.Union([
|
|
|
93
142
|
Type.Literal('gateway'),
|
|
94
143
|
Type.Literal('openrouter'),
|
|
95
144
|
Type.Literal('cloudflare'),
|
|
145
|
+
Type.Literal('gemini'),
|
|
146
|
+
Type.Literal('vertex'),
|
|
96
147
|
]);
|
|
97
148
|
export const embeddingRouteSchema = Type.Object({
|
|
98
149
|
provider: embeddingProviderSchema,
|
|
@@ -103,6 +154,25 @@ const spaceCommon = {
|
|
|
103
154
|
prefix: Type.Literal(EMBEDDING_DOCUMENT_PREFIX),
|
|
104
155
|
normalization: Type.Literal(EMBEDDING_NORMALIZATION_VERSION),
|
|
105
156
|
};
|
|
157
|
+
const geminiSpaceCommon = {
|
|
158
|
+
format: Type.Literal(EMBEDDING_FORMAT_VERSION),
|
|
159
|
+
prefix: Type.Union([
|
|
160
|
+
Type.Literal('title: none | text: '),
|
|
161
|
+
Type.Literal('task: search result | query: '),
|
|
162
|
+
Type.Literal('task: question answering | query: '),
|
|
163
|
+
Type.Literal('task: fact checking | query: '),
|
|
164
|
+
Type.Literal('task: code retrieval | query: '),
|
|
165
|
+
Type.Literal('task: classification | query: '),
|
|
166
|
+
Type.Literal('task: clustering | query: '),
|
|
167
|
+
Type.Literal('task: sentence similarity | query: '),
|
|
168
|
+
]),
|
|
169
|
+
normalization: Type.Literal(EMBEDDING_NORMALIZATION_VERSION),
|
|
170
|
+
model: geminiModelSchema,
|
|
171
|
+
revision: Type.Null(),
|
|
172
|
+
quantization: Type.Null(),
|
|
173
|
+
dimensions: geminiDimensionsSchema,
|
|
174
|
+
taskFormat: geminiTaskFormatSchema,
|
|
175
|
+
};
|
|
106
176
|
/**
|
|
107
177
|
* Complete generating-space identity. `provider` is canonical: the gateway route deliberately
|
|
108
178
|
* reports the OpenAI recipe it declares, not its transport alias.
|
|
@@ -135,6 +205,16 @@ export const embeddingSpaceSchema = Type.Union([
|
|
|
135
205
|
runtime: Type.Literal('sarvam-v2'),
|
|
136
206
|
dimensions: Type.Literal(768),
|
|
137
207
|
}, { additionalProperties: false }),
|
|
208
|
+
Type.Object({
|
|
209
|
+
...geminiSpaceCommon,
|
|
210
|
+
provider: Type.Literal('gemini'),
|
|
211
|
+
runtime: Type.Literal('gemini-api-v1beta'),
|
|
212
|
+
}, { additionalProperties: false }),
|
|
213
|
+
Type.Object({
|
|
214
|
+
...geminiSpaceCommon,
|
|
215
|
+
provider: Type.Literal('vertex'),
|
|
216
|
+
runtime: Type.Literal('vertex-ai-v1'),
|
|
217
|
+
}, { additionalProperties: false }),
|
|
138
218
|
Type.Object({
|
|
139
219
|
...spaceCommon,
|
|
140
220
|
provider: Type.Literal('cloudflare'),
|
|
@@ -173,6 +253,17 @@ export const embeddingSettingsSchema = Type.Object({
|
|
|
173
253
|
model: Type.Optional(cloudflareModelSchema),
|
|
174
254
|
pooling: Type.Optional(Type.Union([Type.Literal('mean'), Type.Literal('cls')])),
|
|
175
255
|
}, { additionalProperties: false })),
|
|
256
|
+
vertex: Type.Optional(Type.Object({
|
|
257
|
+
project: Type.String({ minLength: 1, pattern: '^[a-zA-Z0-9_-]+$' }),
|
|
258
|
+
location: vertexLocationSchema,
|
|
259
|
+
dimensions: geminiDimensionsSchema,
|
|
260
|
+
taskFormat: geminiTaskFormatSchema,
|
|
261
|
+
}, { additionalProperties: false })),
|
|
262
|
+
gemini: Type.Optional(Type.Object({
|
|
263
|
+
apiKey: Type.Optional(Type.String({ minLength: 1 })),
|
|
264
|
+
dimensions: Type.Optional(geminiDimensionsSchema),
|
|
265
|
+
taskFormat: Type.Optional(geminiTaskFormatSchema),
|
|
266
|
+
}, { additionalProperties: false })),
|
|
176
267
|
}, { additionalProperties: false })),
|
|
177
268
|
}, { additionalProperties: false });
|
|
178
269
|
export const embeddingRequestSchema = Type.Object({
|
package/dist/settings-write.js
CHANGED
|
@@ -2,13 +2,13 @@ import { randomUUID } from 'node:crypto';
|
|
|
2
2
|
import { lstat, mkdir, open, readFile, rename, unlink } from 'node:fs/promises';
|
|
3
3
|
import { withFileMutationQueue } from '@earendil-works/pi-coding-agent';
|
|
4
4
|
import { join, resolve } from 'node:path';
|
|
5
|
-
import {
|
|
5
|
+
import { configuredDefault } from './settings.js';
|
|
6
6
|
import { EMBEDDINGS_SETTINGS_KEY } from './schemas.js';
|
|
7
7
|
export class EmbeddingsSettingsWriteError extends Error {
|
|
8
8
|
}
|
|
9
9
|
/** Update only the trusted project's `pi-embeddings.default`, preserving every unrelated key. */
|
|
10
10
|
export function updateProjectEmbeddingSettings({ cwd, projectTrusted, route, }) {
|
|
11
|
-
|
|
11
|
+
configuredDefault({ default: route });
|
|
12
12
|
const settingsPath = resolve(cwd, '.pi', 'settings.json');
|
|
13
13
|
return withFileMutationQueue(settingsPath, () => updateProjectEmbeddingSettingsNow({ cwd, projectTrusted, route }));
|
|
14
14
|
}
|
package/dist/settings.js
CHANGED
|
@@ -4,7 +4,7 @@ import { join, resolve } from 'node:path';
|
|
|
4
4
|
import { loadPiSettings, resolveConfigDir } from '@amaster.ai/pi-shared/settings';
|
|
5
5
|
import { Value } from 'typebox/value';
|
|
6
6
|
import { EmbeddingsError } from './errors.js';
|
|
7
|
-
import { CLOUDFLARE_EMBEDDING_MODELS, EMBEDDINGS_SETTINGS_KEY, GATEWAY_EMBEDDING_MODELS, OPENROUTER_EMBEDDING_MODELS, embeddingSettingsSchema, } from './schemas.js';
|
|
7
|
+
import { CLOUDFLARE_EMBEDDING_MODELS, EMBEDDINGS_SETTINGS_KEY, GATEWAY_EMBEDDING_MODELS, GEMINI_EMBEDDING_MODELS, OPENROUTER_EMBEDDING_MODELS, embeddingSettingsSchema, } from './schemas.js';
|
|
8
8
|
const MODELS_BY_PROVIDER = {
|
|
9
9
|
local: ['embeddinggemma-2'],
|
|
10
10
|
openai: ['text-embedding-3-small'],
|
|
@@ -12,6 +12,8 @@ const MODELS_BY_PROVIDER = {
|
|
|
12
12
|
gateway: GATEWAY_EMBEDDING_MODELS,
|
|
13
13
|
openrouter: OPENROUTER_EMBEDDING_MODELS,
|
|
14
14
|
cloudflare: CLOUDFLARE_EMBEDDING_MODELS,
|
|
15
|
+
gemini: GEMINI_EMBEDDING_MODELS,
|
|
16
|
+
vertex: GEMINI_EMBEDDING_MODELS,
|
|
15
17
|
};
|
|
16
18
|
export const isEmbeddingSettings = (value) => Value.Check(embeddingSettingsSchema, value);
|
|
17
19
|
function configuration(message) {
|
|
@@ -41,6 +43,9 @@ export function validateEmbeddingSettings(value) {
|
|
|
41
43
|
assertRoute(route, `fallback[${index}]`);
|
|
42
44
|
for (const [index, route] of (value.compare ?? []).entries())
|
|
43
45
|
assertRoute(route, `compare[${index}]`);
|
|
46
|
+
const routes = [value.default, ...(value.fallback ?? []), ...(value.compare ?? [])];
|
|
47
|
+
if (routes.some((route) => route.provider === 'vertex') && value.providers?.vertex === undefined)
|
|
48
|
+
return configuration('configuration-invalid');
|
|
44
49
|
if (value.version !== undefined && value.version !== 1)
|
|
45
50
|
return configuration('configuration-invalid');
|
|
46
51
|
return value;
|
package/dist/tool-contracts.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const embedCompareParameters: import("typebox").TObject<{
|
|
|
10
10
|
}>;
|
|
11
11
|
export declare const embedOutput: import("typebox").TObject<{
|
|
12
12
|
schemaVersion: import("typebox").TLiteral<2>;
|
|
13
|
-
provider: import("typebox").TUnion<[import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">]>, import("typebox").TNull]>;
|
|
13
|
+
provider: import("typebox").TUnion<[import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">]>, import("typebox").TNull]>;
|
|
14
14
|
model: import("typebox").TUnion<[import("typebox").TString, import("typebox").TNull]>;
|
|
15
15
|
space: import("typebox").TUnion<[import("typebox").TUnion<[import("typebox").TObject<{
|
|
16
16
|
provider: import("typebox").TLiteral<"local">;
|
|
@@ -42,6 +42,28 @@ export declare const embedOutput: import("typebox").TObject<{
|
|
|
42
42
|
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
43
43
|
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
44
44
|
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
45
|
+
}>, import("typebox").TObject<{
|
|
46
|
+
provider: import("typebox").TLiteral<"gemini">;
|
|
47
|
+
runtime: import("typebox").TLiteral<"gemini-api-v1beta">;
|
|
48
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
49
|
+
prefix: import("typebox").TUnion<[import("typebox").TLiteral<"title: none | text: ">, import("typebox").TLiteral<"task: search result | query: ">, import("typebox").TLiteral<"task: question answering | query: ">, import("typebox").TLiteral<"task: fact checking | query: ">, import("typebox").TLiteral<"task: code retrieval | query: ">, import("typebox").TLiteral<"task: classification | query: ">, import("typebox").TLiteral<"task: clustering | query: ">, import("typebox").TLiteral<"task: sentence similarity | query: ">]>;
|
|
50
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
51
|
+
model: import("typebox").TLiteral<"gemini-embedding-2">;
|
|
52
|
+
revision: import("typebox").TNull;
|
|
53
|
+
quantization: import("typebox").TNull;
|
|
54
|
+
dimensions: import("typebox").TInteger;
|
|
55
|
+
taskFormat: import("typebox").TUnion<[import("typebox").TLiteral<"retrieval-document">, import("typebox").TLiteral<"search-query">, import("typebox").TLiteral<"question-answering">, import("typebox").TLiteral<"fact-checking">, import("typebox").TLiteral<"code-retrieval">, import("typebox").TLiteral<"classification">, import("typebox").TLiteral<"clustering">, import("typebox").TLiteral<"sentence-similarity">]>;
|
|
56
|
+
}>, import("typebox").TObject<{
|
|
57
|
+
provider: import("typebox").TLiteral<"vertex">;
|
|
58
|
+
runtime: import("typebox").TLiteral<"vertex-ai-v1">;
|
|
59
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
60
|
+
prefix: import("typebox").TUnion<[import("typebox").TLiteral<"title: none | text: ">, import("typebox").TLiteral<"task: search result | query: ">, import("typebox").TLiteral<"task: question answering | query: ">, import("typebox").TLiteral<"task: fact checking | query: ">, import("typebox").TLiteral<"task: code retrieval | query: ">, import("typebox").TLiteral<"task: classification | query: ">, import("typebox").TLiteral<"task: clustering | query: ">, import("typebox").TLiteral<"task: sentence similarity | query: ">]>;
|
|
61
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
62
|
+
model: import("typebox").TLiteral<"gemini-embedding-2">;
|
|
63
|
+
revision: import("typebox").TNull;
|
|
64
|
+
quantization: import("typebox").TNull;
|
|
65
|
+
dimensions: import("typebox").TInteger;
|
|
66
|
+
taskFormat: import("typebox").TUnion<[import("typebox").TLiteral<"retrieval-document">, import("typebox").TLiteral<"search-query">, import("typebox").TLiteral<"question-answering">, import("typebox").TLiteral<"fact-checking">, import("typebox").TLiteral<"code-retrieval">, import("typebox").TLiteral<"classification">, import("typebox").TLiteral<"clustering">, import("typebox").TLiteral<"sentence-similarity">]>;
|
|
45
67
|
}>, import("typebox").TObject<{
|
|
46
68
|
provider: import("typebox").TLiteral<"cloudflare">;
|
|
47
69
|
model: import("typebox").TLiteral<"@cf/baai/bge-base-en-v1.5">;
|
|
@@ -55,7 +77,7 @@ export declare const embedOutput: import("typebox").TObject<{
|
|
|
55
77
|
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
56
78
|
}>]>, import("typebox").TNull]>;
|
|
57
79
|
generations: import("typebox").TArray<import("typebox").TObject<{
|
|
58
|
-
provider: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">]>;
|
|
80
|
+
provider: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">]>;
|
|
59
81
|
model: import("typebox").TString;
|
|
60
82
|
space: import("typebox").TUnion<[import("typebox").TObject<{
|
|
61
83
|
provider: import("typebox").TLiteral<"local">;
|
|
@@ -87,6 +109,28 @@ export declare const embedOutput: import("typebox").TObject<{
|
|
|
87
109
|
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
88
110
|
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
89
111
|
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
112
|
+
}>, import("typebox").TObject<{
|
|
113
|
+
provider: import("typebox").TLiteral<"gemini">;
|
|
114
|
+
runtime: import("typebox").TLiteral<"gemini-api-v1beta">;
|
|
115
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
116
|
+
prefix: import("typebox").TUnion<[import("typebox").TLiteral<"title: none | text: ">, import("typebox").TLiteral<"task: search result | query: ">, import("typebox").TLiteral<"task: question answering | query: ">, import("typebox").TLiteral<"task: fact checking | query: ">, import("typebox").TLiteral<"task: code retrieval | query: ">, import("typebox").TLiteral<"task: classification | query: ">, import("typebox").TLiteral<"task: clustering | query: ">, import("typebox").TLiteral<"task: sentence similarity | query: ">]>;
|
|
117
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
118
|
+
model: import("typebox").TLiteral<"gemini-embedding-2">;
|
|
119
|
+
revision: import("typebox").TNull;
|
|
120
|
+
quantization: import("typebox").TNull;
|
|
121
|
+
dimensions: import("typebox").TInteger;
|
|
122
|
+
taskFormat: import("typebox").TUnion<[import("typebox").TLiteral<"retrieval-document">, import("typebox").TLiteral<"search-query">, import("typebox").TLiteral<"question-answering">, import("typebox").TLiteral<"fact-checking">, import("typebox").TLiteral<"code-retrieval">, import("typebox").TLiteral<"classification">, import("typebox").TLiteral<"clustering">, import("typebox").TLiteral<"sentence-similarity">]>;
|
|
123
|
+
}>, import("typebox").TObject<{
|
|
124
|
+
provider: import("typebox").TLiteral<"vertex">;
|
|
125
|
+
runtime: import("typebox").TLiteral<"vertex-ai-v1">;
|
|
126
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
127
|
+
prefix: import("typebox").TUnion<[import("typebox").TLiteral<"title: none | text: ">, import("typebox").TLiteral<"task: search result | query: ">, import("typebox").TLiteral<"task: question answering | query: ">, import("typebox").TLiteral<"task: fact checking | query: ">, import("typebox").TLiteral<"task: code retrieval | query: ">, import("typebox").TLiteral<"task: classification | query: ">, import("typebox").TLiteral<"task: clustering | query: ">, import("typebox").TLiteral<"task: sentence similarity | query: ">]>;
|
|
128
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
129
|
+
model: import("typebox").TLiteral<"gemini-embedding-2">;
|
|
130
|
+
revision: import("typebox").TNull;
|
|
131
|
+
quantization: import("typebox").TNull;
|
|
132
|
+
dimensions: import("typebox").TInteger;
|
|
133
|
+
taskFormat: import("typebox").TUnion<[import("typebox").TLiteral<"retrieval-document">, import("typebox").TLiteral<"search-query">, import("typebox").TLiteral<"question-answering">, import("typebox").TLiteral<"fact-checking">, import("typebox").TLiteral<"code-retrieval">, import("typebox").TLiteral<"classification">, import("typebox").TLiteral<"clustering">, import("typebox").TLiteral<"sentence-similarity">]>;
|
|
90
134
|
}>, import("typebox").TObject<{
|
|
91
135
|
provider: import("typebox").TLiteral<"cloudflare">;
|
|
92
136
|
model: import("typebox").TLiteral<"@cf/baai/bge-base-en-v1.5">;
|
|
@@ -104,7 +148,7 @@ export declare const embedOutput: import("typebox").TObject<{
|
|
|
104
148
|
status: import("typebox").TLiteral<"success">;
|
|
105
149
|
index: import("typebox").TInteger;
|
|
106
150
|
vector: import("typebox").TArray<import("typebox").TNumber>;
|
|
107
|
-
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">]>;
|
|
151
|
+
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">]>;
|
|
108
152
|
model: import("typebox").TString;
|
|
109
153
|
space: import("typebox").TUnion<[import("typebox").TObject<{
|
|
110
154
|
provider: import("typebox").TLiteral<"local">;
|
|
@@ -136,6 +180,28 @@ export declare const embedOutput: import("typebox").TObject<{
|
|
|
136
180
|
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
137
181
|
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
138
182
|
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
183
|
+
}>, import("typebox").TObject<{
|
|
184
|
+
provider: import("typebox").TLiteral<"gemini">;
|
|
185
|
+
runtime: import("typebox").TLiteral<"gemini-api-v1beta">;
|
|
186
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
187
|
+
prefix: import("typebox").TUnion<[import("typebox").TLiteral<"title: none | text: ">, import("typebox").TLiteral<"task: search result | query: ">, import("typebox").TLiteral<"task: question answering | query: ">, import("typebox").TLiteral<"task: fact checking | query: ">, import("typebox").TLiteral<"task: code retrieval | query: ">, import("typebox").TLiteral<"task: classification | query: ">, import("typebox").TLiteral<"task: clustering | query: ">, import("typebox").TLiteral<"task: sentence similarity | query: ">]>;
|
|
188
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
189
|
+
model: import("typebox").TLiteral<"gemini-embedding-2">;
|
|
190
|
+
revision: import("typebox").TNull;
|
|
191
|
+
quantization: import("typebox").TNull;
|
|
192
|
+
dimensions: import("typebox").TInteger;
|
|
193
|
+
taskFormat: import("typebox").TUnion<[import("typebox").TLiteral<"retrieval-document">, import("typebox").TLiteral<"search-query">, import("typebox").TLiteral<"question-answering">, import("typebox").TLiteral<"fact-checking">, import("typebox").TLiteral<"code-retrieval">, import("typebox").TLiteral<"classification">, import("typebox").TLiteral<"clustering">, import("typebox").TLiteral<"sentence-similarity">]>;
|
|
194
|
+
}>, import("typebox").TObject<{
|
|
195
|
+
provider: import("typebox").TLiteral<"vertex">;
|
|
196
|
+
runtime: import("typebox").TLiteral<"vertex-ai-v1">;
|
|
197
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
198
|
+
prefix: import("typebox").TUnion<[import("typebox").TLiteral<"title: none | text: ">, import("typebox").TLiteral<"task: search result | query: ">, import("typebox").TLiteral<"task: question answering | query: ">, import("typebox").TLiteral<"task: fact checking | query: ">, import("typebox").TLiteral<"task: code retrieval | query: ">, import("typebox").TLiteral<"task: classification | query: ">, import("typebox").TLiteral<"task: clustering | query: ">, import("typebox").TLiteral<"task: sentence similarity | query: ">]>;
|
|
199
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
200
|
+
model: import("typebox").TLiteral<"gemini-embedding-2">;
|
|
201
|
+
revision: import("typebox").TNull;
|
|
202
|
+
quantization: import("typebox").TNull;
|
|
203
|
+
dimensions: import("typebox").TInteger;
|
|
204
|
+
taskFormat: import("typebox").TUnion<[import("typebox").TLiteral<"retrieval-document">, import("typebox").TLiteral<"search-query">, import("typebox").TLiteral<"question-answering">, import("typebox").TLiteral<"fact-checking">, import("typebox").TLiteral<"code-retrieval">, import("typebox").TLiteral<"classification">, import("typebox").TLiteral<"clustering">, import("typebox").TLiteral<"sentence-similarity">]>;
|
|
139
205
|
}>, import("typebox").TObject<{
|
|
140
206
|
provider: import("typebox").TLiteral<"cloudflare">;
|
|
141
207
|
model: import("typebox").TLiteral<"@cf/baai/bge-base-en-v1.5">;
|
|
@@ -158,7 +224,7 @@ export declare const embedOutput: import("typebox").TObject<{
|
|
|
158
224
|
}>]>>;
|
|
159
225
|
attempts: import("typebox").TArray<import("typebox").TObject<{
|
|
160
226
|
id: import("typebox").TString;
|
|
161
|
-
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">]>;
|
|
227
|
+
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">]>;
|
|
162
228
|
model: import("typebox").TString;
|
|
163
229
|
routeIndex: import("typebox").TInteger;
|
|
164
230
|
status: import("typebox").TUnion<[import("typebox").TLiteral<"success">, import("typebox").TLiteral<"error">, import("typebox").TLiteral<"cancelled">]>;
|
|
@@ -173,12 +239,12 @@ export declare const embedOutput: import("typebox").TObject<{
|
|
|
173
239
|
export declare const embedCompareOutput: import("typebox").TObject<{
|
|
174
240
|
schemaVersion: import("typebox").TLiteral<2>;
|
|
175
241
|
entries: import("typebox").TArray<import("typebox").TObject<{
|
|
176
|
-
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">]>;
|
|
242
|
+
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">]>;
|
|
177
243
|
model: import("typebox").TString;
|
|
178
244
|
status: import("typebox").TUnion<[import("typebox").TLiteral<"success">, import("typebox").TLiteral<"error">, import("typebox").TLiteral<"cancelled">]>;
|
|
179
245
|
result: import("typebox").TObject<{
|
|
180
246
|
schemaVersion: import("typebox").TLiteral<2>;
|
|
181
|
-
provider: import("typebox").TUnion<[import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">]>, import("typebox").TNull]>;
|
|
247
|
+
provider: import("typebox").TUnion<[import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">]>, import("typebox").TNull]>;
|
|
182
248
|
model: import("typebox").TUnion<[import("typebox").TString, import("typebox").TNull]>;
|
|
183
249
|
space: import("typebox").TUnion<[import("typebox").TUnion<[import("typebox").TObject<{
|
|
184
250
|
provider: import("typebox").TLiteral<"local">;
|
|
@@ -210,6 +276,28 @@ export declare const embedCompareOutput: import("typebox").TObject<{
|
|
|
210
276
|
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
211
277
|
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
212
278
|
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
279
|
+
}>, import("typebox").TObject<{
|
|
280
|
+
provider: import("typebox").TLiteral<"gemini">;
|
|
281
|
+
runtime: import("typebox").TLiteral<"gemini-api-v1beta">;
|
|
282
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
283
|
+
prefix: import("typebox").TUnion<[import("typebox").TLiteral<"title: none | text: ">, import("typebox").TLiteral<"task: search result | query: ">, import("typebox").TLiteral<"task: question answering | query: ">, import("typebox").TLiteral<"task: fact checking | query: ">, import("typebox").TLiteral<"task: code retrieval | query: ">, import("typebox").TLiteral<"task: classification | query: ">, import("typebox").TLiteral<"task: clustering | query: ">, import("typebox").TLiteral<"task: sentence similarity | query: ">]>;
|
|
284
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
285
|
+
model: import("typebox").TLiteral<"gemini-embedding-2">;
|
|
286
|
+
revision: import("typebox").TNull;
|
|
287
|
+
quantization: import("typebox").TNull;
|
|
288
|
+
dimensions: import("typebox").TInteger;
|
|
289
|
+
taskFormat: import("typebox").TUnion<[import("typebox").TLiteral<"retrieval-document">, import("typebox").TLiteral<"search-query">, import("typebox").TLiteral<"question-answering">, import("typebox").TLiteral<"fact-checking">, import("typebox").TLiteral<"code-retrieval">, import("typebox").TLiteral<"classification">, import("typebox").TLiteral<"clustering">, import("typebox").TLiteral<"sentence-similarity">]>;
|
|
290
|
+
}>, import("typebox").TObject<{
|
|
291
|
+
provider: import("typebox").TLiteral<"vertex">;
|
|
292
|
+
runtime: import("typebox").TLiteral<"vertex-ai-v1">;
|
|
293
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
294
|
+
prefix: import("typebox").TUnion<[import("typebox").TLiteral<"title: none | text: ">, import("typebox").TLiteral<"task: search result | query: ">, import("typebox").TLiteral<"task: question answering | query: ">, import("typebox").TLiteral<"task: fact checking | query: ">, import("typebox").TLiteral<"task: code retrieval | query: ">, import("typebox").TLiteral<"task: classification | query: ">, import("typebox").TLiteral<"task: clustering | query: ">, import("typebox").TLiteral<"task: sentence similarity | query: ">]>;
|
|
295
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
296
|
+
model: import("typebox").TLiteral<"gemini-embedding-2">;
|
|
297
|
+
revision: import("typebox").TNull;
|
|
298
|
+
quantization: import("typebox").TNull;
|
|
299
|
+
dimensions: import("typebox").TInteger;
|
|
300
|
+
taskFormat: import("typebox").TUnion<[import("typebox").TLiteral<"retrieval-document">, import("typebox").TLiteral<"search-query">, import("typebox").TLiteral<"question-answering">, import("typebox").TLiteral<"fact-checking">, import("typebox").TLiteral<"code-retrieval">, import("typebox").TLiteral<"classification">, import("typebox").TLiteral<"clustering">, import("typebox").TLiteral<"sentence-similarity">]>;
|
|
213
301
|
}>, import("typebox").TObject<{
|
|
214
302
|
provider: import("typebox").TLiteral<"cloudflare">;
|
|
215
303
|
model: import("typebox").TLiteral<"@cf/baai/bge-base-en-v1.5">;
|
|
@@ -223,7 +311,7 @@ export declare const embedCompareOutput: import("typebox").TObject<{
|
|
|
223
311
|
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
224
312
|
}>]>, import("typebox").TNull]>;
|
|
225
313
|
generations: import("typebox").TArray<import("typebox").TObject<{
|
|
226
|
-
provider: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">]>;
|
|
314
|
+
provider: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">]>;
|
|
227
315
|
model: import("typebox").TString;
|
|
228
316
|
space: import("typebox").TUnion<[import("typebox").TObject<{
|
|
229
317
|
provider: import("typebox").TLiteral<"local">;
|
|
@@ -255,6 +343,28 @@ export declare const embedCompareOutput: import("typebox").TObject<{
|
|
|
255
343
|
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
256
344
|
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
257
345
|
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
346
|
+
}>, import("typebox").TObject<{
|
|
347
|
+
provider: import("typebox").TLiteral<"gemini">;
|
|
348
|
+
runtime: import("typebox").TLiteral<"gemini-api-v1beta">;
|
|
349
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
350
|
+
prefix: import("typebox").TUnion<[import("typebox").TLiteral<"title: none | text: ">, import("typebox").TLiteral<"task: search result | query: ">, import("typebox").TLiteral<"task: question answering | query: ">, import("typebox").TLiteral<"task: fact checking | query: ">, import("typebox").TLiteral<"task: code retrieval | query: ">, import("typebox").TLiteral<"task: classification | query: ">, import("typebox").TLiteral<"task: clustering | query: ">, import("typebox").TLiteral<"task: sentence similarity | query: ">]>;
|
|
351
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
352
|
+
model: import("typebox").TLiteral<"gemini-embedding-2">;
|
|
353
|
+
revision: import("typebox").TNull;
|
|
354
|
+
quantization: import("typebox").TNull;
|
|
355
|
+
dimensions: import("typebox").TInteger;
|
|
356
|
+
taskFormat: import("typebox").TUnion<[import("typebox").TLiteral<"retrieval-document">, import("typebox").TLiteral<"search-query">, import("typebox").TLiteral<"question-answering">, import("typebox").TLiteral<"fact-checking">, import("typebox").TLiteral<"code-retrieval">, import("typebox").TLiteral<"classification">, import("typebox").TLiteral<"clustering">, import("typebox").TLiteral<"sentence-similarity">]>;
|
|
357
|
+
}>, import("typebox").TObject<{
|
|
358
|
+
provider: import("typebox").TLiteral<"vertex">;
|
|
359
|
+
runtime: import("typebox").TLiteral<"vertex-ai-v1">;
|
|
360
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
361
|
+
prefix: import("typebox").TUnion<[import("typebox").TLiteral<"title: none | text: ">, import("typebox").TLiteral<"task: search result | query: ">, import("typebox").TLiteral<"task: question answering | query: ">, import("typebox").TLiteral<"task: fact checking | query: ">, import("typebox").TLiteral<"task: code retrieval | query: ">, import("typebox").TLiteral<"task: classification | query: ">, import("typebox").TLiteral<"task: clustering | query: ">, import("typebox").TLiteral<"task: sentence similarity | query: ">]>;
|
|
362
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
363
|
+
model: import("typebox").TLiteral<"gemini-embedding-2">;
|
|
364
|
+
revision: import("typebox").TNull;
|
|
365
|
+
quantization: import("typebox").TNull;
|
|
366
|
+
dimensions: import("typebox").TInteger;
|
|
367
|
+
taskFormat: import("typebox").TUnion<[import("typebox").TLiteral<"retrieval-document">, import("typebox").TLiteral<"search-query">, import("typebox").TLiteral<"question-answering">, import("typebox").TLiteral<"fact-checking">, import("typebox").TLiteral<"code-retrieval">, import("typebox").TLiteral<"classification">, import("typebox").TLiteral<"clustering">, import("typebox").TLiteral<"sentence-similarity">]>;
|
|
258
368
|
}>, import("typebox").TObject<{
|
|
259
369
|
provider: import("typebox").TLiteral<"cloudflare">;
|
|
260
370
|
model: import("typebox").TLiteral<"@cf/baai/bge-base-en-v1.5">;
|
|
@@ -272,7 +382,7 @@ export declare const embedCompareOutput: import("typebox").TObject<{
|
|
|
272
382
|
status: import("typebox").TLiteral<"success">;
|
|
273
383
|
index: import("typebox").TInteger;
|
|
274
384
|
vector: import("typebox").TArray<import("typebox").TNumber>;
|
|
275
|
-
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">]>;
|
|
385
|
+
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">]>;
|
|
276
386
|
model: import("typebox").TString;
|
|
277
387
|
space: import("typebox").TUnion<[import("typebox").TObject<{
|
|
278
388
|
provider: import("typebox").TLiteral<"local">;
|
|
@@ -304,6 +414,28 @@ export declare const embedCompareOutput: import("typebox").TObject<{
|
|
|
304
414
|
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
305
415
|
prefix: import("typebox").TLiteral<"title: none | text: ">;
|
|
306
416
|
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
417
|
+
}>, import("typebox").TObject<{
|
|
418
|
+
provider: import("typebox").TLiteral<"gemini">;
|
|
419
|
+
runtime: import("typebox").TLiteral<"gemini-api-v1beta">;
|
|
420
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
421
|
+
prefix: import("typebox").TUnion<[import("typebox").TLiteral<"title: none | text: ">, import("typebox").TLiteral<"task: search result | query: ">, import("typebox").TLiteral<"task: question answering | query: ">, import("typebox").TLiteral<"task: fact checking | query: ">, import("typebox").TLiteral<"task: code retrieval | query: ">, import("typebox").TLiteral<"task: classification | query: ">, import("typebox").TLiteral<"task: clustering | query: ">, import("typebox").TLiteral<"task: sentence similarity | query: ">]>;
|
|
422
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
423
|
+
model: import("typebox").TLiteral<"gemini-embedding-2">;
|
|
424
|
+
revision: import("typebox").TNull;
|
|
425
|
+
quantization: import("typebox").TNull;
|
|
426
|
+
dimensions: import("typebox").TInteger;
|
|
427
|
+
taskFormat: import("typebox").TUnion<[import("typebox").TLiteral<"retrieval-document">, import("typebox").TLiteral<"search-query">, import("typebox").TLiteral<"question-answering">, import("typebox").TLiteral<"fact-checking">, import("typebox").TLiteral<"code-retrieval">, import("typebox").TLiteral<"classification">, import("typebox").TLiteral<"clustering">, import("typebox").TLiteral<"sentence-similarity">]>;
|
|
428
|
+
}>, import("typebox").TObject<{
|
|
429
|
+
provider: import("typebox").TLiteral<"vertex">;
|
|
430
|
+
runtime: import("typebox").TLiteral<"vertex-ai-v1">;
|
|
431
|
+
format: import("typebox").TLiteral<"host-display-attributes-v1">;
|
|
432
|
+
prefix: import("typebox").TUnion<[import("typebox").TLiteral<"title: none | text: ">, import("typebox").TLiteral<"task: search result | query: ">, import("typebox").TLiteral<"task: question answering | query: ">, import("typebox").TLiteral<"task: fact checking | query: ">, import("typebox").TLiteral<"task: code retrieval | query: ">, import("typebox").TLiteral<"task: classification | query: ">, import("typebox").TLiteral<"task: clustering | query: ">, import("typebox").TLiteral<"task: sentence similarity | query: ">]>;
|
|
433
|
+
normalization: import("typebox").TLiteral<"finite-nonzero-l2-v1">;
|
|
434
|
+
model: import("typebox").TLiteral<"gemini-embedding-2">;
|
|
435
|
+
revision: import("typebox").TNull;
|
|
436
|
+
quantization: import("typebox").TNull;
|
|
437
|
+
dimensions: import("typebox").TInteger;
|
|
438
|
+
taskFormat: import("typebox").TUnion<[import("typebox").TLiteral<"retrieval-document">, import("typebox").TLiteral<"search-query">, import("typebox").TLiteral<"question-answering">, import("typebox").TLiteral<"fact-checking">, import("typebox").TLiteral<"code-retrieval">, import("typebox").TLiteral<"classification">, import("typebox").TLiteral<"clustering">, import("typebox").TLiteral<"sentence-similarity">]>;
|
|
307
439
|
}>, import("typebox").TObject<{
|
|
308
440
|
provider: import("typebox").TLiteral<"cloudflare">;
|
|
309
441
|
model: import("typebox").TLiteral<"@cf/baai/bge-base-en-v1.5">;
|
|
@@ -326,7 +458,7 @@ export declare const embedCompareOutput: import("typebox").TObject<{
|
|
|
326
458
|
}>]>>;
|
|
327
459
|
attempts: import("typebox").TArray<import("typebox").TObject<{
|
|
328
460
|
id: import("typebox").TString;
|
|
329
|
-
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">]>;
|
|
461
|
+
route: import("typebox").TUnion<[import("typebox").TLiteral<"local">, import("typebox").TLiteral<"openai">, import("typebox").TLiteral<"sarvam">, import("typebox").TLiteral<"gateway">, import("typebox").TLiteral<"openrouter">, import("typebox").TLiteral<"cloudflare">, import("typebox").TLiteral<"gemini">, import("typebox").TLiteral<"vertex">]>;
|
|
330
462
|
model: import("typebox").TString;
|
|
331
463
|
routeIndex: import("typebox").TInteger;
|
|
332
464
|
status: import("typebox").TUnion<[import("typebox").TLiteral<"success">, import("typebox").TLiteral<"error">, import("typebox").TLiteral<"cancelled">]>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { EmbeddingsProvider, PreparedInput, ProviderBatchResult } from './provider-types.js';
|
|
2
|
+
import { type EmbeddingSettings, type EmbeddingSpace } from './schemas.js';
|
|
3
|
+
type VertexSettings = NonNullable<NonNullable<EmbeddingSettings['providers']>['vertex']>;
|
|
4
|
+
export declare const vertexEmbeddingSpace: (config: VertexSettings) => EmbeddingSpace;
|
|
5
|
+
/** Native Vertex transport: fixed Google hosts, explicit resource, keyless ADC, no gcloud or API keys. */
|
|
6
|
+
export declare class VertexProvider implements EmbeddingsProvider {
|
|
7
|
+
#private;
|
|
8
|
+
readonly route: "vertex";
|
|
9
|
+
readonly model: "gemini-embedding-2";
|
|
10
|
+
readonly space: EmbeddingSpace;
|
|
11
|
+
readonly maxRequestInputs = 1;
|
|
12
|
+
readonly maxRequestTokens: number;
|
|
13
|
+
constructor(config: VertexSettings);
|
|
14
|
+
prepare(text: string, signal: AbortSignal): Promise<PreparedInput>;
|
|
15
|
+
embed(inputs: readonly PreparedInput[], signal: AbortSignal): Promise<ProviderBatchResult>;
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { GdchClient, GoogleAuth, JWT } from 'google-auth-library';
|
|
2
|
+
import { EmbeddingsError } from './errors.js';
|
|
3
|
+
import { headerValueIsSafe, requestJson } from './provider-http.js';
|
|
4
|
+
import { parseGeminiCountTokensResponse, parseVertexEmbeddingResponse } from './response.js';
|
|
5
|
+
import { EMBEDDING_FORMAT_VERSION, EMBEDDING_NORMALIZATION_VERSION, GEMINI_EMBEDDING_MODELS, GEMINI_TASK_PREFIXES, } from './schemas.js';
|
|
6
|
+
// Gemini Embedding 2 shares an 8192-token window across modalities; excess input is silently truncated.
|
|
7
|
+
// https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/embeddings/get-multimodal-embeddings
|
|
8
|
+
const MAX_INPUT_TOKENS = 8192;
|
|
9
|
+
export const vertexEmbeddingSpace = (config) => Object.freeze({
|
|
10
|
+
provider: 'vertex',
|
|
11
|
+
model: GEMINI_EMBEDDING_MODELS[0],
|
|
12
|
+
revision: null,
|
|
13
|
+
quantization: null,
|
|
14
|
+
runtime: 'vertex-ai-v1',
|
|
15
|
+
dimensions: config.dimensions,
|
|
16
|
+
taskFormat: config.taskFormat,
|
|
17
|
+
format: EMBEDDING_FORMAT_VERSION,
|
|
18
|
+
prefix: GEMINI_TASK_PREFIXES[config.taskFormat],
|
|
19
|
+
normalization: EMBEDDING_NORMALIZATION_VERSION,
|
|
20
|
+
});
|
|
21
|
+
/** Inspect only ADC type metadata, including an impersonation source; never expose credentials. */
|
|
22
|
+
const isKeylessCredentialMetadata = (metadata) => {
|
|
23
|
+
if (typeof metadata !== 'object' || metadata === null || !('type' in metadata))
|
|
24
|
+
return false;
|
|
25
|
+
switch (metadata.type) {
|
|
26
|
+
case 'authorized_user':
|
|
27
|
+
case 'external_account':
|
|
28
|
+
case 'external_account_authorized_user':
|
|
29
|
+
return true;
|
|
30
|
+
case 'impersonated_service_account':
|
|
31
|
+
return 'source_credentials' in metadata && isKeylessCredentialMetadata(metadata.source_credentials);
|
|
32
|
+
default:
|
|
33
|
+
// The SDK treats missing/unknown types as JWT credentials too; a denylist misses nested keys.
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
/** Native Vertex transport: fixed Google hosts, explicit resource, keyless ADC, no gcloud or API keys. */
|
|
38
|
+
export class VertexProvider {
|
|
39
|
+
route = 'vertex';
|
|
40
|
+
model = GEMINI_EMBEDDING_MODELS[0];
|
|
41
|
+
space;
|
|
42
|
+
maxRequestInputs = 1; // embedContent contains exactly one Content.
|
|
43
|
+
maxRequestTokens = Number.POSITIVE_INFINITY;
|
|
44
|
+
#config;
|
|
45
|
+
#auth;
|
|
46
|
+
#url;
|
|
47
|
+
#countUrl;
|
|
48
|
+
constructor(config) {
|
|
49
|
+
this.#config = config;
|
|
50
|
+
this.space = vertexEmbeddingSpace(config);
|
|
51
|
+
const origin = config.location === 'global'
|
|
52
|
+
? 'https://aiplatform.googleapis.com'
|
|
53
|
+
: `https://aiplatform.${config.location}.rep.googleapis.com`;
|
|
54
|
+
const resource = `/v1/projects/${encodeURIComponent(config.project)}/locations/${config.location}/publishers/google/models/${this.model}`;
|
|
55
|
+
this.#url = new URL(`${resource}:embedContent`, origin);
|
|
56
|
+
this.#countUrl = new URL(`${resource}:countTokens`, origin);
|
|
57
|
+
// An explicit project also prevents ADC discovery from invoking gcloud to infer one.
|
|
58
|
+
this.#auth = new GoogleAuth({
|
|
59
|
+
projectId: config.project,
|
|
60
|
+
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
async #headers(url, signal) {
|
|
64
|
+
signal.throwIfAborted();
|
|
65
|
+
let listener;
|
|
66
|
+
const cancelled = new Promise((_resolve, reject) => {
|
|
67
|
+
listener = () => reject(new EmbeddingsError('cancelled'));
|
|
68
|
+
signal.addEventListener('abort', listener, { once: true });
|
|
69
|
+
});
|
|
70
|
+
try {
|
|
71
|
+
// The SDK does not expose an AbortSignal for ADC discovery/refresh. Stop waiting on cancellation;
|
|
72
|
+
// any in-flight SDK refresh may finish, but cannot proceed to a model request after cancellation.
|
|
73
|
+
const headers = await Promise.race([(async () => {
|
|
74
|
+
const client = await this.#auth.getClient();
|
|
75
|
+
if (client instanceof JWT || client instanceof GdchClient ||
|
|
76
|
+
(this.#auth.jsonContent !== null && !isKeylessCredentialMetadata(this.#auth.jsonContent)))
|
|
77
|
+
throw new EmbeddingsError('configuration-invalid');
|
|
78
|
+
signal.throwIfAborted();
|
|
79
|
+
return client.getRequestHeaders(url);
|
|
80
|
+
})(), cancelled]);
|
|
81
|
+
signal.throwIfAborted();
|
|
82
|
+
const authorization = headers.get('authorization');
|
|
83
|
+
if (authorization === null || !authorization.startsWith('Bearer ') || !headerValueIsSafe(authorization))
|
|
84
|
+
throw new EmbeddingsError('configuration-invalid');
|
|
85
|
+
const result = { authorization };
|
|
86
|
+
const quotaProject = headers.get('x-goog-user-project');
|
|
87
|
+
if (quotaProject !== null) {
|
|
88
|
+
if (!headerValueIsSafe(quotaProject))
|
|
89
|
+
throw new EmbeddingsError('configuration-invalid');
|
|
90
|
+
result['x-goog-user-project'] = quotaProject;
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
// SDK errors may contain sensitive request metadata. Never propagate them or infer a retry/fallback.
|
|
96
|
+
throw new EmbeddingsError(signal.aborted ? 'cancelled' : 'configuration-invalid');
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
if (listener !== undefined)
|
|
100
|
+
signal.removeEventListener('abort', listener);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async prepare(text, signal) {
|
|
104
|
+
const prepared = GEMINI_TASK_PREFIXES[this.#config.taskFormat] + text;
|
|
105
|
+
const response = await requestJson({
|
|
106
|
+
url: this.#countUrl,
|
|
107
|
+
signal,
|
|
108
|
+
headers: await this.#headers(this.#countUrl, signal),
|
|
109
|
+
body: { contents: [{ role: 'user', parts: [{ text: prepared }] }] },
|
|
110
|
+
});
|
|
111
|
+
const tokenCount = parseGeminiCountTokensResponse(response);
|
|
112
|
+
if (tokenCount > MAX_INPUT_TOKENS)
|
|
113
|
+
throw new EmbeddingsError('input-too-long', { knownUsage: { preparedInputTokens: tokenCount } });
|
|
114
|
+
return { kind: 'text', text: prepared, tokenCount };
|
|
115
|
+
}
|
|
116
|
+
async embed(inputs, signal) {
|
|
117
|
+
const input = inputs[0];
|
|
118
|
+
if (inputs.length !== 1 || input?.kind !== 'text' || input.tokenCount === null)
|
|
119
|
+
throw new EmbeddingsError('provider-response-invalid');
|
|
120
|
+
const response = await requestJson({
|
|
121
|
+
url: this.#url,
|
|
122
|
+
signal,
|
|
123
|
+
headers: await this.#headers(this.#url, signal),
|
|
124
|
+
body: {
|
|
125
|
+
content: { role: 'user', parts: [{ text: input.text }] },
|
|
126
|
+
embedContentConfig: { outputDimensionality: this.space.dimensions },
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
return parseVertexEmbeddingResponse({
|
|
130
|
+
response,
|
|
131
|
+
space: this.space,
|
|
132
|
+
maxInputTokens: MAX_INPUT_TOKENS,
|
|
133
|
+
preparedInputTokens: input.tokenCount,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
async close() {
|
|
137
|
+
// ADC and native fetch own no adapter-created child, timer or listener.
|
|
138
|
+
}
|
|
139
|
+
}
|