ai 3.0.21 → 3.0.23

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.
Files changed (57) hide show
  1. package/dist/index.d.mts +42 -1
  2. package/dist/index.d.ts +42 -1
  3. package/dist/index.js +104 -177
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +65 -138
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +4 -33
  8. package/react/dist/index.d.mts +6 -2
  9. package/react/dist/index.d.ts +6 -2
  10. package/react/dist/index.js +107 -24
  11. package/react/dist/index.js.map +1 -1
  12. package/react/dist/index.mjs +107 -24
  13. package/react/dist/index.mjs.map +1 -1
  14. package/rsc/dist/rsc-server.mjs +3 -3
  15. package/rsc/dist/rsc-server.mjs.map +1 -1
  16. package/solid/dist/index.d.mts +6 -2
  17. package/solid/dist/index.d.ts +6 -2
  18. package/solid/dist/index.js +105 -23
  19. package/solid/dist/index.js.map +1 -1
  20. package/solid/dist/index.mjs +105 -23
  21. package/solid/dist/index.mjs.map +1 -1
  22. package/svelte/dist/index.d.mts +6 -2
  23. package/svelte/dist/index.d.ts +6 -2
  24. package/svelte/dist/index.js +107 -24
  25. package/svelte/dist/index.js.map +1 -1
  26. package/svelte/dist/index.mjs +107 -24
  27. package/svelte/dist/index.mjs.map +1 -1
  28. package/vue/dist/index.d.mts +6 -2
  29. package/vue/dist/index.d.ts +6 -2
  30. package/vue/dist/index.js +105 -23
  31. package/vue/dist/index.js.map +1 -1
  32. package/vue/dist/index.mjs +105 -23
  33. package/vue/dist/index.mjs.map +1 -1
  34. package/anthropic/dist/index.d.mts +0 -51
  35. package/anthropic/dist/index.d.ts +0 -51
  36. package/anthropic/dist/index.js +0 -792
  37. package/anthropic/dist/index.js.map +0 -1
  38. package/anthropic/dist/index.mjs +0 -760
  39. package/anthropic/dist/index.mjs.map +0 -1
  40. package/google/dist/index.d.mts +0 -47
  41. package/google/dist/index.d.ts +0 -47
  42. package/google/dist/index.js +0 -796
  43. package/google/dist/index.js.map +0 -1
  44. package/google/dist/index.mjs +0 -764
  45. package/google/dist/index.mjs.map +0 -1
  46. package/mistral/dist/index.d.mts +0 -52
  47. package/mistral/dist/index.d.ts +0 -52
  48. package/mistral/dist/index.js +0 -763
  49. package/mistral/dist/index.js.map +0 -1
  50. package/mistral/dist/index.mjs +0 -731
  51. package/mistral/dist/index.mjs.map +0 -1
  52. package/openai/dist/index.d.mts +0 -116
  53. package/openai/dist/index.d.ts +0 -116
  54. package/openai/dist/index.js +0 -1143
  55. package/openai/dist/index.js.map +0 -1
  56. package/openai/dist/index.mjs +0 -1115
  57. package/openai/dist/index.mjs.map +0 -1
@@ -1,764 +0,0 @@
1
- // spec/util/generate-id.ts
2
- import { customAlphabet } from "nanoid/non-secure";
3
- var generateId = customAlphabet(
4
- "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
5
- 7
6
- );
7
-
8
- // spec/util/load-api-key.ts
9
- import { LoadAPIKeyError } from "@ai-sdk/provider";
10
- function loadApiKey({
11
- apiKey,
12
- environmentVariableName,
13
- apiKeyParameterName = "apiKey",
14
- description
15
- }) {
16
- if (typeof apiKey === "string") {
17
- return apiKey;
18
- }
19
- if (apiKey != null) {
20
- throw new LoadAPIKeyError({
21
- message: `${description} API key must be a string.`
22
- });
23
- }
24
- if (typeof process === "undefined") {
25
- throw new LoadAPIKeyError({
26
- message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter. Environment variables is not supported in this environment.`
27
- });
28
- }
29
- apiKey = process.env[environmentVariableName];
30
- if (apiKey == null) {
31
- throw new LoadAPIKeyError({
32
- message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter or the ${environmentVariableName} environment variable.`
33
- });
34
- }
35
- if (typeof apiKey !== "string") {
36
- throw new LoadAPIKeyError({
37
- message: `${description} API key must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
38
- });
39
- }
40
- return apiKey;
41
- }
42
-
43
- // spec/util/parse-json.ts
44
- import { JSONParseError, TypeValidationError as TypeValidationError2 } from "@ai-sdk/provider";
45
- import SecureJSON from "secure-json-parse";
46
-
47
- // spec/util/validate-types.ts
48
- import { TypeValidationError } from "@ai-sdk/provider";
49
- function validateTypes({
50
- value,
51
- schema
52
- }) {
53
- try {
54
- return schema.parse(value);
55
- } catch (error) {
56
- throw new TypeValidationError({ value, cause: error });
57
- }
58
- }
59
- function safeValidateTypes({
60
- value,
61
- schema
62
- }) {
63
- try {
64
- const validationResult = schema.safeParse(value);
65
- if (validationResult.success) {
66
- return {
67
- success: true,
68
- value: validationResult.data
69
- };
70
- }
71
- return {
72
- success: false,
73
- error: new TypeValidationError({
74
- value,
75
- cause: validationResult.error
76
- })
77
- };
78
- } catch (error) {
79
- return {
80
- success: false,
81
- error: TypeValidationError.isTypeValidationError(error) ? error : new TypeValidationError({ value, cause: error })
82
- };
83
- }
84
- }
85
-
86
- // spec/util/parse-json.ts
87
- function parseJSON({
88
- text,
89
- schema
90
- }) {
91
- try {
92
- const value = SecureJSON.parse(text);
93
- if (schema == null) {
94
- return value;
95
- }
96
- return validateTypes({ value, schema });
97
- } catch (error) {
98
- if (JSONParseError.isJSONParseError(error) || TypeValidationError2.isTypeValidationError(error)) {
99
- throw error;
100
- }
101
- throw new JSONParseError({ text, cause: error });
102
- }
103
- }
104
- function safeParseJSON({
105
- text,
106
- schema
107
- }) {
108
- try {
109
- const value = SecureJSON.parse(text);
110
- if (schema == null) {
111
- return {
112
- success: true,
113
- value
114
- };
115
- }
116
- return safeValidateTypes({ value, schema });
117
- } catch (error) {
118
- return {
119
- success: false,
120
- error: JSONParseError.isJSONParseError(error) ? error : new JSONParseError({ text, cause: error })
121
- };
122
- }
123
- }
124
-
125
- // spec/util/post-to-api.ts
126
- import { APICallError } from "@ai-sdk/provider";
127
- var postJsonToApi = async ({
128
- url,
129
- headers,
130
- body,
131
- failedResponseHandler,
132
- successfulResponseHandler,
133
- abortSignal
134
- }) => postToApi({
135
- url,
136
- headers: {
137
- ...headers,
138
- "Content-Type": "application/json"
139
- },
140
- body: {
141
- content: JSON.stringify(body),
142
- values: body
143
- },
144
- failedResponseHandler,
145
- successfulResponseHandler,
146
- abortSignal
147
- });
148
- var postToApi = async ({
149
- url,
150
- headers = {},
151
- body,
152
- successfulResponseHandler,
153
- failedResponseHandler,
154
- abortSignal
155
- }) => {
156
- try {
157
- const definedHeaders = Object.fromEntries(
158
- Object.entries(headers).filter(([_key, value]) => value != null)
159
- );
160
- const response = await fetch(url, {
161
- method: "POST",
162
- headers: definedHeaders,
163
- body: body.content,
164
- signal: abortSignal
165
- });
166
- if (!response.ok) {
167
- try {
168
- throw await failedResponseHandler({
169
- response,
170
- url,
171
- requestBodyValues: body.values
172
- });
173
- } catch (error) {
174
- if (error instanceof Error) {
175
- if (error.name === "AbortError" || APICallError.isAPICallError(error)) {
176
- throw error;
177
- }
178
- }
179
- throw new APICallError({
180
- message: "Failed to process error response",
181
- cause: error,
182
- statusCode: response.status,
183
- url,
184
- requestBodyValues: body.values
185
- });
186
- }
187
- }
188
- try {
189
- return await successfulResponseHandler({
190
- response,
191
- url,
192
- requestBodyValues: body.values
193
- });
194
- } catch (error) {
195
- if (error instanceof Error) {
196
- if (error.name === "AbortError" || APICallError.isAPICallError(error)) {
197
- throw error;
198
- }
199
- }
200
- throw new APICallError({
201
- message: "Failed to process successful response",
202
- cause: error,
203
- statusCode: response.status,
204
- url,
205
- requestBodyValues: body.values
206
- });
207
- }
208
- } catch (error) {
209
- if (error instanceof Error) {
210
- if (error.name === "AbortError") {
211
- throw error;
212
- }
213
- }
214
- if (error instanceof TypeError && error.message === "fetch failed") {
215
- const cause = error.cause;
216
- if (cause != null) {
217
- throw new APICallError({
218
- message: `Cannot connect to API: ${cause.message}`,
219
- cause,
220
- url,
221
- requestBodyValues: body.values,
222
- isRetryable: true
223
- // retry when network error
224
- });
225
- }
226
- }
227
- throw error;
228
- }
229
- };
230
-
231
- // spec/util/response-handler.ts
232
- import { APICallError as APICallError2, NoResponseBodyError } from "@ai-sdk/provider";
233
- import {
234
- EventSourceParserStream
235
- } from "eventsource-parser/stream";
236
- var createJsonErrorResponseHandler = ({
237
- errorSchema,
238
- errorToMessage,
239
- isRetryable
240
- }) => async ({ response, url, requestBodyValues }) => {
241
- const responseBody = await response.text();
242
- if (responseBody.trim() === "") {
243
- return new APICallError2({
244
- message: response.statusText,
245
- url,
246
- requestBodyValues,
247
- statusCode: response.status,
248
- responseBody,
249
- isRetryable: isRetryable == null ? void 0 : isRetryable(response)
250
- });
251
- }
252
- try {
253
- const parsedError = parseJSON({
254
- text: responseBody,
255
- schema: errorSchema
256
- });
257
- return new APICallError2({
258
- message: errorToMessage(parsedError),
259
- url,
260
- requestBodyValues,
261
- statusCode: response.status,
262
- responseBody,
263
- data: parsedError,
264
- isRetryable: isRetryable == null ? void 0 : isRetryable(response, parsedError)
265
- });
266
- } catch (parseError) {
267
- return new APICallError2({
268
- message: response.statusText,
269
- url,
270
- requestBodyValues,
271
- statusCode: response.status,
272
- responseBody,
273
- isRetryable: isRetryable == null ? void 0 : isRetryable(response)
274
- });
275
- }
276
- };
277
- var createEventSourceResponseHandler = (chunkSchema2) => async ({ response }) => {
278
- if (response.body == null) {
279
- throw new NoResponseBodyError();
280
- }
281
- return response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream()).pipeThrough(
282
- new TransformStream({
283
- transform({ data }, controller) {
284
- if (data === "[DONE]") {
285
- return;
286
- }
287
- controller.enqueue(
288
- safeParseJSON({
289
- text: data,
290
- schema: chunkSchema2
291
- })
292
- );
293
- }
294
- })
295
- );
296
- };
297
- var createJsonResponseHandler = (responseSchema2) => async ({ response, url, requestBodyValues }) => {
298
- const responseBody = await response.text();
299
- const parsedResult = safeParseJSON({
300
- text: responseBody,
301
- schema: responseSchema2
302
- });
303
- if (!parsedResult.success) {
304
- throw new APICallError2({
305
- message: "Invalid JSON response",
306
- cause: parsedResult.error,
307
- statusCode: response.status,
308
- responseBody,
309
- url,
310
- requestBodyValues
311
- });
312
- }
313
- return parsedResult.value;
314
- };
315
-
316
- // spec/util/uint8-utils.ts
317
- function convertUint8ArrayToBase64(array) {
318
- let latin1string = "";
319
- for (let i = 0; i < array.length; i++) {
320
- latin1string += String.fromCodePoint(array[i]);
321
- }
322
- return globalThis.btoa(latin1string);
323
- }
324
-
325
- // google/google-generative-ai-language-model.ts
326
- import {
327
- UnsupportedFunctionalityError as UnsupportedFunctionalityError2
328
- } from "@ai-sdk/provider";
329
- import { z as z2 } from "zod";
330
-
331
- // google/convert-to-google-generative-ai-messages.ts
332
- import {
333
- UnsupportedFunctionalityError
334
- } from "@ai-sdk/provider";
335
- function convertToGoogleGenerativeAIMessages(prompt) {
336
- const messages = [];
337
- for (const { role, content } of prompt) {
338
- switch (role) {
339
- case "system": {
340
- messages.push({ role: "user", parts: [{ text: content }] });
341
- messages.push({ role: "model", parts: [{ text: "" }] });
342
- break;
343
- }
344
- case "user": {
345
- messages.push({
346
- role: "user",
347
- parts: content.map((part) => {
348
- var _a;
349
- switch (part.type) {
350
- case "text": {
351
- return { text: part.text };
352
- }
353
- case "image": {
354
- if (part.image instanceof URL) {
355
- throw new UnsupportedFunctionalityError({
356
- functionality: "URL image parts"
357
- });
358
- } else {
359
- return {
360
- inlineData: {
361
- mimeType: (_a = part.mimeType) != null ? _a : "image/jpeg",
362
- data: convertUint8ArrayToBase64(part.image)
363
- }
364
- };
365
- }
366
- }
367
- }
368
- })
369
- });
370
- break;
371
- }
372
- case "assistant": {
373
- messages.push({
374
- role: "model",
375
- parts: content.map((part) => {
376
- switch (part.type) {
377
- case "text": {
378
- return part.text.length === 0 ? void 0 : { text: part.text };
379
- }
380
- case "tool-call": {
381
- return {
382
- functionCall: {
383
- name: part.toolName,
384
- args: part.args
385
- }
386
- };
387
- }
388
- }
389
- }).filter(
390
- (part) => part !== void 0
391
- )
392
- });
393
- break;
394
- }
395
- case "tool": {
396
- messages.push({
397
- role: "user",
398
- parts: content.map((part) => ({
399
- functionResponse: {
400
- name: part.toolName,
401
- response: part.result
402
- }
403
- }))
404
- });
405
- break;
406
- }
407
- default: {
408
- const _exhaustiveCheck = role;
409
- throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
410
- }
411
- }
412
- }
413
- return messages;
414
- }
415
-
416
- // google/google-error.ts
417
- import { z } from "zod";
418
- var googleErrorDataSchema = z.object({
419
- error: z.object({
420
- code: z.number().nullable(),
421
- message: z.string(),
422
- status: z.string()
423
- })
424
- });
425
- var googleFailedResponseHandler = createJsonErrorResponseHandler({
426
- errorSchema: googleErrorDataSchema,
427
- errorToMessage: (data) => data.error.message
428
- });
429
-
430
- // google/map-google-generative-ai-finish-reason.ts
431
- function mapGoogleGenerativeAIFinishReason({
432
- finishReason,
433
- hasToolCalls
434
- }) {
435
- switch (finishReason) {
436
- case "STOP":
437
- return hasToolCalls ? "tool-calls" : "stop";
438
- case "MAX_TOKENS":
439
- return "length";
440
- case "RECITATION":
441
- case "SAFETY":
442
- return "content-filter";
443
- case "FINISH_REASON_UNSPECIFIED":
444
- case "OTHER":
445
- default:
446
- return "other";
447
- }
448
- }
449
-
450
- // google/google-generative-ai-language-model.ts
451
- var GoogleGenerativeAILanguageModel = class {
452
- constructor(modelId, settings, config) {
453
- this.specificationVersion = "v1";
454
- this.defaultObjectGenerationMode = void 0;
455
- this.modelId = modelId;
456
- this.settings = settings;
457
- this.config = config;
458
- }
459
- get provider() {
460
- return this.config.provider;
461
- }
462
- getArgs({
463
- mode,
464
- prompt,
465
- maxTokens,
466
- temperature,
467
- topP,
468
- frequencyPenalty,
469
- presencePenalty,
470
- seed
471
- }) {
472
- var _a;
473
- const type = mode.type;
474
- const warnings = [];
475
- if (frequencyPenalty != null) {
476
- warnings.push({
477
- type: "unsupported-setting",
478
- setting: "frequencyPenalty"
479
- });
480
- }
481
- if (presencePenalty != null) {
482
- warnings.push({
483
- type: "unsupported-setting",
484
- setting: "presencePenalty"
485
- });
486
- }
487
- if (seed != null) {
488
- warnings.push({
489
- type: "unsupported-setting",
490
- setting: "seed"
491
- });
492
- }
493
- const baseArgs = {
494
- generationConfig: {
495
- // model specific settings:
496
- topK: this.settings.topK,
497
- // standardized settings:
498
- maxOutputTokens: maxTokens,
499
- temperature,
500
- topP
501
- },
502
- // prompt:
503
- contents: convertToGoogleGenerativeAIMessages(prompt)
504
- };
505
- switch (type) {
506
- case "regular": {
507
- const functionDeclarations = (_a = mode.tools) == null ? void 0 : _a.map((tool) => {
508
- var _a2;
509
- return {
510
- name: tool.name,
511
- description: (_a2 = tool.description) != null ? _a2 : "",
512
- parameters: prepareJsonSchema(tool.parameters)
513
- };
514
- });
515
- return {
516
- args: {
517
- ...baseArgs,
518
- tools: functionDeclarations == null ? void 0 : { functionDeclarations }
519
- },
520
- warnings
521
- };
522
- }
523
- case "object-json": {
524
- throw new UnsupportedFunctionalityError2({
525
- functionality: "object-json mode"
526
- });
527
- }
528
- case "object-tool": {
529
- throw new UnsupportedFunctionalityError2({
530
- functionality: "object-tool mode"
531
- });
532
- }
533
- case "object-grammar": {
534
- throw new UnsupportedFunctionalityError2({
535
- functionality: "object-grammar mode"
536
- });
537
- }
538
- default: {
539
- const _exhaustiveCheck = type;
540
- throw new Error(`Unsupported type: ${_exhaustiveCheck}`);
541
- }
542
- }
543
- }
544
- async doGenerate(options) {
545
- var _a;
546
- const { args, warnings } = this.getArgs(options);
547
- const response = await postJsonToApi({
548
- url: `${this.config.baseUrl}/${this.modelId}:generateContent`,
549
- headers: this.config.headers(),
550
- body: args,
551
- failedResponseHandler: googleFailedResponseHandler,
552
- successfulResponseHandler: createJsonResponseHandler(responseSchema),
553
- abortSignal: options.abortSignal
554
- });
555
- const { contents: rawPrompt, ...rawSettings } = args;
556
- const candidate = response.candidates[0];
557
- const toolCalls = getToolCallsFromParts({
558
- parts: candidate.content.parts,
559
- generateId: this.config.generateId
560
- });
561
- return {
562
- text: getTextFromParts(candidate.content.parts),
563
- toolCalls,
564
- finishReason: mapGoogleGenerativeAIFinishReason({
565
- finishReason: candidate.finishReason,
566
- hasToolCalls: toolCalls != null && toolCalls.length > 0
567
- }),
568
- usage: {
569
- promptTokens: NaN,
570
- completionTokens: (_a = candidate.tokenCount) != null ? _a : NaN
571
- },
572
- rawCall: { rawPrompt, rawSettings },
573
- warnings
574
- };
575
- }
576
- async doStream(options) {
577
- const { args, warnings } = this.getArgs(options);
578
- const response = await postJsonToApi({
579
- url: `${this.config.baseUrl}/${this.modelId}:streamGenerateContent?alt=sse`,
580
- headers: this.config.headers(),
581
- body: args,
582
- failedResponseHandler: googleFailedResponseHandler,
583
- successfulResponseHandler: createEventSourceResponseHandler(chunkSchema),
584
- abortSignal: options.abortSignal
585
- });
586
- const { contents: rawPrompt, ...rawSettings } = args;
587
- let finishReason = "other";
588
- let usage = {
589
- promptTokens: Number.NaN,
590
- completionTokens: Number.NaN
591
- };
592
- const generateId2 = this.config.generateId;
593
- let hasToolCalls = false;
594
- return {
595
- stream: response.pipeThrough(
596
- new TransformStream({
597
- transform(chunk, controller) {
598
- if (!chunk.success) {
599
- controller.enqueue({ type: "error", error: chunk.error });
600
- return;
601
- }
602
- const value = chunk.value;
603
- const candidate = value.candidates[0];
604
- if ((candidate == null ? void 0 : candidate.finishReason) != null) {
605
- finishReason = mapGoogleGenerativeAIFinishReason({
606
- finishReason: candidate.finishReason,
607
- hasToolCalls
608
- });
609
- }
610
- if (candidate.tokenCount != null) {
611
- usage = {
612
- promptTokens: NaN,
613
- completionTokens: candidate.tokenCount
614
- };
615
- }
616
- const content = candidate.content;
617
- if (content == null) {
618
- return;
619
- }
620
- const deltaText = getTextFromParts(content.parts);
621
- if (deltaText != null) {
622
- controller.enqueue({
623
- type: "text-delta",
624
- textDelta: deltaText
625
- });
626
- }
627
- const toolCallDeltas = getToolCallsFromParts({
628
- parts: content.parts,
629
- generateId: generateId2
630
- });
631
- if (toolCallDeltas != null) {
632
- for (const toolCall of toolCallDeltas) {
633
- controller.enqueue({
634
- type: "tool-call-delta",
635
- toolCallType: "function",
636
- toolCallId: toolCall.toolCallId,
637
- toolName: toolCall.toolName,
638
- argsTextDelta: toolCall.args
639
- });
640
- controller.enqueue({
641
- type: "tool-call",
642
- toolCallType: "function",
643
- toolCallId: toolCall.toolCallId,
644
- toolName: toolCall.toolName,
645
- args: toolCall.args
646
- });
647
- hasToolCalls = true;
648
- }
649
- }
650
- },
651
- flush(controller) {
652
- controller.enqueue({ type: "finish", finishReason, usage });
653
- }
654
- })
655
- ),
656
- rawCall: { rawPrompt, rawSettings },
657
- warnings
658
- };
659
- }
660
- };
661
- function prepareJsonSchema(jsonSchema) {
662
- if (typeof jsonSchema !== "object") {
663
- return jsonSchema;
664
- }
665
- if (Array.isArray(jsonSchema)) {
666
- return jsonSchema.map(prepareJsonSchema);
667
- }
668
- const result = {};
669
- for (const [key, value] of Object.entries(jsonSchema)) {
670
- if (key === "additionalProperties" || key === "$schema") {
671
- continue;
672
- }
673
- result[key] = prepareJsonSchema(value);
674
- }
675
- return result;
676
- }
677
- function getToolCallsFromParts({
678
- parts,
679
- generateId: generateId2
680
- }) {
681
- const functionCallParts = parts.filter(
682
- (part) => "functionCall" in part
683
- );
684
- return functionCallParts.length === 0 ? void 0 : functionCallParts.map((part) => ({
685
- toolCallType: "function",
686
- toolCallId: generateId2(),
687
- toolName: part.functionCall.name,
688
- args: JSON.stringify(part.functionCall.args)
689
- }));
690
- }
691
- function getTextFromParts(parts) {
692
- const textParts = parts.filter((part) => "text" in part);
693
- return textParts.length === 0 ? void 0 : textParts.map((part) => part.text).join("");
694
- }
695
- var contentSchema = z2.object({
696
- role: z2.string(),
697
- parts: z2.array(
698
- z2.union([
699
- z2.object({
700
- text: z2.string()
701
- }),
702
- z2.object({
703
- functionCall: z2.object({
704
- name: z2.string(),
705
- args: z2.unknown()
706
- })
707
- })
708
- ])
709
- )
710
- });
711
- var responseSchema = z2.object({
712
- candidates: z2.array(
713
- z2.object({
714
- content: contentSchema,
715
- finishReason: z2.string().optional(),
716
- tokenCount: z2.number().optional()
717
- })
718
- )
719
- });
720
- var chunkSchema = z2.object({
721
- candidates: z2.array(
722
- z2.object({
723
- content: contentSchema.optional(),
724
- finishReason: z2.string().optional(),
725
- tokenCount: z2.number().optional()
726
- })
727
- )
728
- });
729
-
730
- // google/google-facade.ts
731
- var Google = class {
732
- constructor(options = {}) {
733
- var _a;
734
- this.baseUrl = options.baseUrl;
735
- this.apiKey = options.apiKey;
736
- this.generateId = (_a = options.generateId) != null ? _a : generateId;
737
- }
738
- get baseConfig() {
739
- var _a;
740
- return {
741
- baseUrl: (_a = this.baseUrl) != null ? _a : "https://generativelanguage.googleapis.com/v1beta",
742
- headers: () => ({
743
- "x-goog-api-key": loadApiKey({
744
- apiKey: this.apiKey,
745
- environmentVariableName: "GOOGLE_GENERATIVE_AI_API_KEY",
746
- description: "Google Generative AI"
747
- })
748
- })
749
- };
750
- }
751
- generativeAI(modelId, settings = {}) {
752
- return new GoogleGenerativeAILanguageModel(modelId, settings, {
753
- provider: "google.generative-ai",
754
- ...this.baseConfig,
755
- generateId: this.generateId
756
- });
757
- }
758
- };
759
- var google = new Google();
760
- export {
761
- Google,
762
- google
763
- };
764
- //# sourceMappingURL=index.mjs.map