@zhivex-ai/vertex 0.2.1
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 +13 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +286 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type CallableProviderAdapter, type ProviderAdapter } from "@zhivex-ai/core";
|
|
2
|
+
export interface VertexProviderOptions {
|
|
3
|
+
accessToken?: string;
|
|
4
|
+
projectId?: string;
|
|
5
|
+
location?: string;
|
|
6
|
+
apiVersion?: string;
|
|
7
|
+
baseURL?: string;
|
|
8
|
+
fetch?: typeof globalThis.fetch;
|
|
9
|
+
}
|
|
10
|
+
export interface VertexLanguageModelOptions {
|
|
11
|
+
topP?: number;
|
|
12
|
+
topK?: number;
|
|
13
|
+
stopSequences?: string[];
|
|
14
|
+
candidateCount?: number;
|
|
15
|
+
responseMimeType?: string;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
export declare const createVertex: (options?: VertexProviderOptions) => CallableProviderAdapter & ProviderAdapter & {
|
|
19
|
+
rawFetch: typeof globalThis.fetch;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAQL,KAAK,uBAAuB,EAS5B,KAAK,eAAe,EAErB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AA0SD,eAAO,MAAM,YAAY,GACvB,UAAS,qBAA0B,KAClC,uBAAuB,GAAG,eAAe,GAAG;IAAE,QAAQ,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;CAwBjF,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { toJSONSchema } from "zod";
|
|
2
|
+
import { ConfigurationError, ProviderHTTPError, createProviderAdapter, normalizeFinishReason, streamSSE, withRetry, withTimeoutSignal } from "@zhivex-ai/core";
|
|
3
|
+
const capabilities = {
|
|
4
|
+
streaming: true,
|
|
5
|
+
tools: true,
|
|
6
|
+
structuredOutput: true,
|
|
7
|
+
jsonMode: true,
|
|
8
|
+
toolChoice: false,
|
|
9
|
+
parallelToolCalls: false,
|
|
10
|
+
vision: true,
|
|
11
|
+
files: false,
|
|
12
|
+
audioInput: false,
|
|
13
|
+
audioOutput: false,
|
|
14
|
+
embeddings: true,
|
|
15
|
+
reasoning: true,
|
|
16
|
+
webSearch: false
|
|
17
|
+
};
|
|
18
|
+
const parseJson = async (response) => {
|
|
19
|
+
if (!response.ok) {
|
|
20
|
+
const body = await response.text();
|
|
21
|
+
throw new ProviderHTTPError(`Vertex request failed with status ${response.status}.`, response.status, {
|
|
22
|
+
responseBody: body
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return response.json();
|
|
26
|
+
};
|
|
27
|
+
const systemInstruction = (messages) => {
|
|
28
|
+
const text = messages
|
|
29
|
+
.filter((message) => message.role === "system")
|
|
30
|
+
.flatMap((message) => message.parts)
|
|
31
|
+
.filter((part) => part.type === "text")
|
|
32
|
+
.map((part) => part.text)
|
|
33
|
+
.join("\n");
|
|
34
|
+
return text ? { parts: [{ text }] } : undefined;
|
|
35
|
+
};
|
|
36
|
+
const mapPart = (part) => {
|
|
37
|
+
switch (part.type) {
|
|
38
|
+
case "text":
|
|
39
|
+
return { text: part.text };
|
|
40
|
+
case "image":
|
|
41
|
+
return {
|
|
42
|
+
inlineData: {
|
|
43
|
+
mimeType: part.mediaType ?? "image/jpeg",
|
|
44
|
+
data: part.image
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
case "tool-call":
|
|
48
|
+
return {
|
|
49
|
+
functionCall: {
|
|
50
|
+
name: part.toolCall.name,
|
|
51
|
+
args: part.toolCall.input
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
case "tool-result":
|
|
55
|
+
return {
|
|
56
|
+
functionResponse: {
|
|
57
|
+
name: part.toolResult.toolName,
|
|
58
|
+
response: {
|
|
59
|
+
name: part.toolResult.toolName,
|
|
60
|
+
content: part.toolResult.isError ? part.toolResult.error : part.toolResult.output
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
default:
|
|
65
|
+
return { text: JSON.stringify(part) };
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const mapMessages = (messages) => messages
|
|
69
|
+
.filter((message) => message.role !== "system")
|
|
70
|
+
.map((message) => ({
|
|
71
|
+
role: message.role === "assistant" ? "model" : "user",
|
|
72
|
+
parts: message.parts.map(mapPart)
|
|
73
|
+
}));
|
|
74
|
+
const mapTools = (tools) => tools
|
|
75
|
+
? [
|
|
76
|
+
{
|
|
77
|
+
functionDeclarations: Object.values(tools).map((tool) => ({
|
|
78
|
+
name: tool.name,
|
|
79
|
+
description: tool.description,
|
|
80
|
+
parameters: toJSONSchema(tool.schema)
|
|
81
|
+
}))
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
: undefined;
|
|
85
|
+
const generationConfig = (input) => ({
|
|
86
|
+
temperature: input.temperature,
|
|
87
|
+
maxOutputTokens: input.maxTokens,
|
|
88
|
+
...(input.structuredOutput?.mode === "native"
|
|
89
|
+
? {
|
|
90
|
+
responseMimeType: "application/json",
|
|
91
|
+
responseSchema: toJSONSchema(input.structuredOutput.schema)
|
|
92
|
+
}
|
|
93
|
+
: {})
|
|
94
|
+
});
|
|
95
|
+
const parseAssistantMessage = (candidate) => ({
|
|
96
|
+
role: "assistant",
|
|
97
|
+
parts: candidate?.content?.parts?.map((part) => {
|
|
98
|
+
if (part.text) {
|
|
99
|
+
return { type: "text", text: part.text };
|
|
100
|
+
}
|
|
101
|
+
if (part.functionCall) {
|
|
102
|
+
return {
|
|
103
|
+
type: "tool-call",
|
|
104
|
+
toolCall: {
|
|
105
|
+
id: `${part.functionCall.name}-0`,
|
|
106
|
+
name: part.functionCall.name,
|
|
107
|
+
input: part.functionCall.args ?? {}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return { type: "text", text: JSON.stringify(part) };
|
|
112
|
+
}) ?? []
|
|
113
|
+
});
|
|
114
|
+
class VertexLanguageModel {
|
|
115
|
+
modelId;
|
|
116
|
+
baseURL;
|
|
117
|
+
accessToken;
|
|
118
|
+
fetcher;
|
|
119
|
+
provider = "vertex";
|
|
120
|
+
capabilities = capabilities;
|
|
121
|
+
constructor(modelId, baseURL, accessToken, fetcher) {
|
|
122
|
+
this.modelId = modelId;
|
|
123
|
+
this.baseURL = baseURL;
|
|
124
|
+
this.accessToken = accessToken;
|
|
125
|
+
this.fetcher = fetcher;
|
|
126
|
+
}
|
|
127
|
+
url(action) {
|
|
128
|
+
return `${this.baseURL}/publishers/google/models/${this.modelId}:${action}`;
|
|
129
|
+
}
|
|
130
|
+
headers() {
|
|
131
|
+
return {
|
|
132
|
+
"content-type": "application/json",
|
|
133
|
+
authorization: `Bearer ${this.accessToken}`
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
async generate(input) {
|
|
137
|
+
const { signal, cleanup } = withTimeoutSignal(input);
|
|
138
|
+
try {
|
|
139
|
+
const response = await withRetry(() => this.fetcher(this.url("generateContent"), {
|
|
140
|
+
method: "POST",
|
|
141
|
+
headers: this.headers(),
|
|
142
|
+
signal,
|
|
143
|
+
body: JSON.stringify({
|
|
144
|
+
contents: mapMessages(input.messages),
|
|
145
|
+
systemInstruction: systemInstruction(input.messages),
|
|
146
|
+
generationConfig: generationConfig(input),
|
|
147
|
+
tools: mapTools(input.tools),
|
|
148
|
+
...input.providerOptions
|
|
149
|
+
})
|
|
150
|
+
}), input);
|
|
151
|
+
const json = await parseJson(response);
|
|
152
|
+
const candidate = json.candidates?.[0];
|
|
153
|
+
const assistantMessage = parseAssistantMessage(candidate);
|
|
154
|
+
return {
|
|
155
|
+
messages: [assistantMessage],
|
|
156
|
+
text: assistantMessage.parts
|
|
157
|
+
.filter((part) => part.type === "text")
|
|
158
|
+
.map((part) => part.text)
|
|
159
|
+
.join(""),
|
|
160
|
+
finishReason: normalizeFinishReason(candidate?.finishReason),
|
|
161
|
+
providerFinishReason: candidate?.finishReason,
|
|
162
|
+
rawResponse: json
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
finally {
|
|
166
|
+
cleanup();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
async stream(input) {
|
|
170
|
+
const { signal, cleanup } = withTimeoutSignal(input);
|
|
171
|
+
const response = await withRetry(() => this.fetcher(this.url("streamGenerateContent?alt=sse"), {
|
|
172
|
+
method: "POST",
|
|
173
|
+
headers: this.headers(),
|
|
174
|
+
signal,
|
|
175
|
+
body: JSON.stringify({
|
|
176
|
+
contents: mapMessages(input.messages),
|
|
177
|
+
systemInstruction: systemInstruction(input.messages),
|
|
178
|
+
generationConfig: generationConfig(input),
|
|
179
|
+
tools: mapTools(input.tools),
|
|
180
|
+
...input.providerOptions
|
|
181
|
+
})
|
|
182
|
+
}), input);
|
|
183
|
+
return (async function* () {
|
|
184
|
+
try {
|
|
185
|
+
for await (const event of streamSSE(response)) {
|
|
186
|
+
const json = JSON.parse(event.data);
|
|
187
|
+
const candidate = json.candidates?.[0];
|
|
188
|
+
const parts = candidate?.content?.parts ?? [];
|
|
189
|
+
for (const part of parts) {
|
|
190
|
+
if (part.text) {
|
|
191
|
+
yield { type: "text-delta", textDelta: part.text };
|
|
192
|
+
}
|
|
193
|
+
if (part.functionCall) {
|
|
194
|
+
yield {
|
|
195
|
+
type: "tool-call",
|
|
196
|
+
toolCall: {
|
|
197
|
+
id: `${part.functionCall.name}-0`,
|
|
198
|
+
name: part.functionCall.name,
|
|
199
|
+
input: part.functionCall.args ?? {}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (candidate?.finishReason) {
|
|
205
|
+
yield {
|
|
206
|
+
type: "finish",
|
|
207
|
+
finishReason: normalizeFinishReason(candidate.finishReason),
|
|
208
|
+
providerFinishReason: candidate.finishReason
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
finally {
|
|
214
|
+
cleanup();
|
|
215
|
+
}
|
|
216
|
+
})();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
class VertexEmbeddingModel {
|
|
220
|
+
modelId;
|
|
221
|
+
baseURL;
|
|
222
|
+
accessToken;
|
|
223
|
+
fetcher;
|
|
224
|
+
provider = "vertex";
|
|
225
|
+
capabilities = capabilities;
|
|
226
|
+
constructor(modelId, baseURL, accessToken, fetcher) {
|
|
227
|
+
this.modelId = modelId;
|
|
228
|
+
this.baseURL = baseURL;
|
|
229
|
+
this.accessToken = accessToken;
|
|
230
|
+
this.fetcher = fetcher;
|
|
231
|
+
}
|
|
232
|
+
url() {
|
|
233
|
+
return `${this.baseURL}/publishers/google/models/${this.modelId}:predict`;
|
|
234
|
+
}
|
|
235
|
+
headers() {
|
|
236
|
+
return {
|
|
237
|
+
"content-type": "application/json",
|
|
238
|
+
authorization: `Bearer ${this.accessToken}`
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
async embed(input) {
|
|
242
|
+
const { signal, cleanup } = withTimeoutSignal(input);
|
|
243
|
+
try {
|
|
244
|
+
const response = await withRetry(() => this.fetcher(this.url(), {
|
|
245
|
+
method: "POST",
|
|
246
|
+
headers: this.headers(),
|
|
247
|
+
signal,
|
|
248
|
+
body: JSON.stringify({
|
|
249
|
+
instances: input.values.map((value) => ({
|
|
250
|
+
content: value
|
|
251
|
+
}))
|
|
252
|
+
})
|
|
253
|
+
}), input);
|
|
254
|
+
const json = await parseJson(response);
|
|
255
|
+
return {
|
|
256
|
+
embeddings: (json.predictions ?? []).map((prediction) => prediction.embeddings?.values ?? []),
|
|
257
|
+
rawResponse: json
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
finally {
|
|
261
|
+
cleanup();
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
export const createVertex = (options = {}) => {
|
|
266
|
+
const accessToken = options.accessToken ?? process.env.VERTEX_ACCESS_TOKEN ?? process.env.GOOGLE_ACCESS_TOKEN;
|
|
267
|
+
if (!accessToken) {
|
|
268
|
+
throw new ConfigurationError("Missing Vertex access token.");
|
|
269
|
+
}
|
|
270
|
+
const projectId = options.projectId ?? process.env.GOOGLE_CLOUD_PROJECT ?? process.env.GCLOUD_PROJECT;
|
|
271
|
+
if (!projectId && !options.baseURL) {
|
|
272
|
+
throw new ConfigurationError("Missing Vertex project ID.");
|
|
273
|
+
}
|
|
274
|
+
const location = options.location ?? process.env.VERTEX_LOCATION ?? "us-central1";
|
|
275
|
+
const apiVersion = options.apiVersion ?? "v1beta1";
|
|
276
|
+
const baseURL = options.baseURL ??
|
|
277
|
+
`https://${location}-aiplatform.googleapis.com/${apiVersion}/projects/${projectId}/locations/${location}`;
|
|
278
|
+
const fetcher = options.fetch ?? globalThis.fetch;
|
|
279
|
+
return createProviderAdapter({
|
|
280
|
+
name: "vertex",
|
|
281
|
+
languageModel: (modelId) => new VertexLanguageModel(modelId, baseURL, accessToken, fetcher),
|
|
282
|
+
embeddingModel: (modelId) => new VertexEmbeddingModel(modelId, baseURL, accessToken, fetcher),
|
|
283
|
+
rawFetch: fetcher
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAEnC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,SAAS,EACT,SAAS,EACT,iBAAiB,EAYlB,MAAM,iBAAiB,CAAC;AAoBzB,MAAM,YAAY,GAAsB;IACtC,SAAS,EAAE,IAAI;IACf,KAAK,EAAE,IAAI;IACX,gBAAgB,EAAE,IAAI;IACtB,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,KAAK;IACjB,iBAAiB,EAAE,KAAK;IACxB,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,KAAK;IACZ,UAAU,EAAE,KAAK;IACjB,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,KAAK;CACjB,CAAC;AAEF,MAAM,SAAS,GAAG,KAAK,EAAE,QAAkB,EAAE,EAAE;IAC7C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,MAAM,IAAI,iBAAiB,CAAC,qCAAqC,QAAQ,CAAC,MAAM,GAAG,EAAE,QAAQ,CAAC,MAAM,EAAE;YACpG,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;IACL,CAAC;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C;QAC7F,QAAQ,EAAE,OAAO;KAClB,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zhivex-ai/vertex",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Vertex AI adapter for Zhivex AI SDK.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=18.18.0",
|
|
11
|
+
"bun": ">=1.3.7"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/Zhivex/zhivex-ai-sdk.git",
|
|
27
|
+
"directory": "packages/vertex"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/Zhivex/zhivex-ai-sdk#readme",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/Zhivex/zhivex-ai-sdk/issues"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"ai",
|
|
35
|
+
"sdk",
|
|
36
|
+
"vertex",
|
|
37
|
+
"gemini",
|
|
38
|
+
"typescript"
|
|
39
|
+
],
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@zhivex-ai/core": "^0.2.0",
|
|
45
|
+
"zod": "^4.3.6"
|
|
46
|
+
}
|
|
47
|
+
}
|