@positronic/client-vercel 0.0.61 → 0.0.63
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/src/index.js +582 -398
- package/dist/types/index.d.ts +4 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/src/index.js
CHANGED
|
@@ -70,6 +70,13 @@ function _define_property(obj, key, value) {
|
|
|
70
70
|
}
|
|
71
71
|
return obj;
|
|
72
72
|
}
|
|
73
|
+
function _instanceof(left, right) {
|
|
74
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
75
|
+
return !!right[Symbol.hasInstance](left);
|
|
76
|
+
} else {
|
|
77
|
+
return left instanceof right;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
73
80
|
function _iterable_to_array(iter) {
|
|
74
81
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
75
82
|
}
|
|
@@ -103,12 +110,31 @@ function _non_iterable_rest() {
|
|
|
103
110
|
function _non_iterable_spread() {
|
|
104
111
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
105
112
|
}
|
|
113
|
+
function _object_spread(target) {
|
|
114
|
+
for(var i = 1; i < arguments.length; i++){
|
|
115
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
116
|
+
var ownKeys = Object.keys(source);
|
|
117
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
118
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
119
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
ownKeys.forEach(function(key) {
|
|
123
|
+
_define_property(target, key, source[key]);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return target;
|
|
127
|
+
}
|
|
106
128
|
function _sliced_to_array(arr, i) {
|
|
107
129
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
108
130
|
}
|
|
109
131
|
function _to_consumable_array(arr) {
|
|
110
132
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
111
133
|
}
|
|
134
|
+
function _type_of(obj) {
|
|
135
|
+
"@swc/helpers - typeof";
|
|
136
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
137
|
+
}
|
|
112
138
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
113
139
|
if (!o) return;
|
|
114
140
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -208,7 +234,127 @@ function _ts_generator(thisArg, body) {
|
|
|
208
234
|
};
|
|
209
235
|
}
|
|
210
236
|
}
|
|
211
|
-
|
|
237
|
+
function _ts_values(o) {
|
|
238
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
239
|
+
if (m) return m.call(o);
|
|
240
|
+
if (o && typeof o.length === "number") return {
|
|
241
|
+
next: function() {
|
|
242
|
+
if (o && i >= o.length) o = void 0;
|
|
243
|
+
return {
|
|
244
|
+
value: o && o[i++],
|
|
245
|
+
done: !o
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
250
|
+
}
|
|
251
|
+
import { generateText, streamText as vercelStreamText, stepCountIs, Output } from 'ai';
|
|
252
|
+
var MAX_RATE_LIMIT_RETRIES = 4;
|
|
253
|
+
var INITIAL_RETRY_DELAY_MS = 5000;
|
|
254
|
+
var RETRY_BACKOFF_FACTOR = 2;
|
|
255
|
+
function isErrorWithStatusCode(error, codes) {
|
|
256
|
+
return (typeof error === "undefined" ? "undefined" : _type_of(error)) === 'object' && error !== null && 'statusCode' in error && typeof error.statusCode === 'number' && codes.includes(error.statusCode);
|
|
257
|
+
}
|
|
258
|
+
function isRateLimitError(error) {
|
|
259
|
+
var rateLimitCodes = [
|
|
260
|
+
429,
|
|
261
|
+
529
|
|
262
|
+
];
|
|
263
|
+
if (isErrorWithStatusCode(error, rateLimitCodes)) {
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
// RetryError wrapping rate limit errors (SDK exhausted its retries)
|
|
267
|
+
if (_instanceof(error, Error) && 'errors' in error && Array.isArray(error.errors)) {
|
|
268
|
+
return error.errors.some(function(e) {
|
|
269
|
+
return isErrorWithStatusCode(e, rateLimitCodes);
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
function retryWithBackoff(fn) {
|
|
275
|
+
return _async_to_generator(function() {
|
|
276
|
+
var _loop, attempt, _ret;
|
|
277
|
+
return _ts_generator(this, function(_state) {
|
|
278
|
+
switch(_state.label){
|
|
279
|
+
case 0:
|
|
280
|
+
_loop = function(attempt) {
|
|
281
|
+
var _tmp, error, baseDelay, jitter, delay;
|
|
282
|
+
return _ts_generator(this, function(_state) {
|
|
283
|
+
switch(_state.label){
|
|
284
|
+
case 0:
|
|
285
|
+
_state.trys.push([
|
|
286
|
+
0,
|
|
287
|
+
2,
|
|
288
|
+
,
|
|
289
|
+
4
|
|
290
|
+
]);
|
|
291
|
+
_tmp = {};
|
|
292
|
+
return [
|
|
293
|
+
4,
|
|
294
|
+
fn()
|
|
295
|
+
];
|
|
296
|
+
case 1:
|
|
297
|
+
return [
|
|
298
|
+
2,
|
|
299
|
+
(_tmp.v = _state.sent(), _tmp)
|
|
300
|
+
];
|
|
301
|
+
case 2:
|
|
302
|
+
error = _state.sent();
|
|
303
|
+
if (attempt === MAX_RATE_LIMIT_RETRIES || !isRateLimitError(error)) {
|
|
304
|
+
throw error;
|
|
305
|
+
}
|
|
306
|
+
baseDelay = INITIAL_RETRY_DELAY_MS * Math.pow(RETRY_BACKOFF_FACTOR, attempt);
|
|
307
|
+
jitter = 0.5 + Math.random();
|
|
308
|
+
delay = baseDelay * jitter;
|
|
309
|
+
return [
|
|
310
|
+
4,
|
|
311
|
+
new Promise(function(resolve) {
|
|
312
|
+
return setTimeout(resolve, delay);
|
|
313
|
+
})
|
|
314
|
+
];
|
|
315
|
+
case 3:
|
|
316
|
+
_state.sent();
|
|
317
|
+
return [
|
|
318
|
+
3,
|
|
319
|
+
4
|
|
320
|
+
];
|
|
321
|
+
case 4:
|
|
322
|
+
return [
|
|
323
|
+
2
|
|
324
|
+
];
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
};
|
|
328
|
+
attempt = 0;
|
|
329
|
+
_state.label = 1;
|
|
330
|
+
case 1:
|
|
331
|
+
if (!(attempt <= MAX_RATE_LIMIT_RETRIES)) return [
|
|
332
|
+
3,
|
|
333
|
+
4
|
|
334
|
+
];
|
|
335
|
+
return [
|
|
336
|
+
5,
|
|
337
|
+
_ts_values(_loop(attempt))
|
|
338
|
+
];
|
|
339
|
+
case 2:
|
|
340
|
+
_ret = _state.sent();
|
|
341
|
+
if (_type_of(_ret) === "object") return [
|
|
342
|
+
2,
|
|
343
|
+
_ret.v
|
|
344
|
+
];
|
|
345
|
+
_state.label = 3;
|
|
346
|
+
case 3:
|
|
347
|
+
attempt++;
|
|
348
|
+
return [
|
|
349
|
+
3,
|
|
350
|
+
1
|
|
351
|
+
];
|
|
352
|
+
case 4:
|
|
353
|
+
throw new Error('unreachable');
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
})();
|
|
357
|
+
}
|
|
212
358
|
/**
|
|
213
359
|
* Creates a tool result message in SDK-native format.
|
|
214
360
|
* Use this to append tool results to responseMessages before the next generateText call.
|
|
@@ -250,78 +396,97 @@ export var VercelClient = /*#__PURE__*/ function() {
|
|
|
250
396
|
},
|
|
251
397
|
{
|
|
252
398
|
key: "generateObject",
|
|
253
|
-
value: function
|
|
399
|
+
value: function generateObject(params) {
|
|
254
400
|
return _async_to_generator(function() {
|
|
255
|
-
var schema, schemaName, schemaDescription, prompt, messages, system,
|
|
401
|
+
var _this, schema, schemaName, schemaDescription, prompt, messages, system, maxRetries, coreMessages;
|
|
256
402
|
return _ts_generator(this, function(_state) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
if (prompt) {
|
|
276
|
-
coreMessages.push({
|
|
277
|
-
role: 'user',
|
|
278
|
-
content: prompt
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
if (!(coreMessages.length > 0)) return [
|
|
282
|
-
3,
|
|
283
|
-
2
|
|
284
|
-
];
|
|
285
|
-
return [
|
|
286
|
-
4,
|
|
287
|
-
generateObject({
|
|
288
|
-
model: this.model,
|
|
289
|
-
schema: schema,
|
|
290
|
-
schemaName: schemaName,
|
|
291
|
-
schemaDescription: schemaDescription,
|
|
292
|
-
messages: coreMessages,
|
|
293
|
-
mode: 'auto'
|
|
294
|
-
})
|
|
295
|
-
];
|
|
296
|
-
case 1:
|
|
297
|
-
object = _state.sent().object;
|
|
298
|
-
return [
|
|
299
|
-
2,
|
|
300
|
-
object
|
|
301
|
-
];
|
|
302
|
-
case 2:
|
|
303
|
-
return [
|
|
304
|
-
4,
|
|
305
|
-
generateObject({
|
|
306
|
-
model: this.model,
|
|
307
|
-
schema: schema,
|
|
308
|
-
schemaName: schemaName,
|
|
309
|
-
schemaDescription: schemaDescription,
|
|
310
|
-
prompt: prompt || '',
|
|
311
|
-
mode: 'auto'
|
|
312
|
-
})
|
|
313
|
-
];
|
|
314
|
-
case 3:
|
|
315
|
-
object1 = _state.sent().object;
|
|
316
|
-
return [
|
|
317
|
-
2,
|
|
318
|
-
object1
|
|
319
|
-
];
|
|
320
|
-
case 4:
|
|
321
|
-
return [
|
|
322
|
-
2
|
|
323
|
-
];
|
|
403
|
+
_this = this;
|
|
404
|
+
schema = params.schema, schemaName = params.schemaName, schemaDescription = params.schemaDescription, prompt = params.prompt, messages = params.messages, system = params.system, maxRetries = params.maxRetries;
|
|
405
|
+
coreMessages = [];
|
|
406
|
+
if (system) {
|
|
407
|
+
coreMessages.push({
|
|
408
|
+
role: 'system',
|
|
409
|
+
content: system
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
if (messages) {
|
|
413
|
+
messages.forEach(function(msg) {
|
|
414
|
+
coreMessages.push({
|
|
415
|
+
role: msg.role,
|
|
416
|
+
content: msg.content
|
|
417
|
+
});
|
|
418
|
+
});
|
|
324
419
|
}
|
|
420
|
+
if (prompt) {
|
|
421
|
+
coreMessages.push({
|
|
422
|
+
role: 'user',
|
|
423
|
+
content: prompt
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
// AI SDK v5 requires either messages or prompt, but not both as undefined
|
|
427
|
+
// If we have messages built up, use them; otherwise use the prompt directly
|
|
428
|
+
return [
|
|
429
|
+
2,
|
|
430
|
+
retryWithBackoff(function() {
|
|
431
|
+
return _async_to_generator(function() {
|
|
432
|
+
var output, output1;
|
|
433
|
+
return _ts_generator(this, function(_state) {
|
|
434
|
+
switch(_state.label){
|
|
435
|
+
case 0:
|
|
436
|
+
if (!(coreMessages.length > 0)) return [
|
|
437
|
+
3,
|
|
438
|
+
2
|
|
439
|
+
];
|
|
440
|
+
return [
|
|
441
|
+
4,
|
|
442
|
+
generateText(_object_spread({
|
|
443
|
+
model: this.model,
|
|
444
|
+
output: Output.object({
|
|
445
|
+
schema: schema,
|
|
446
|
+
name: schemaName,
|
|
447
|
+
description: schemaDescription
|
|
448
|
+
}),
|
|
449
|
+
messages: coreMessages
|
|
450
|
+
}, maxRetries !== undefined && {
|
|
451
|
+
maxRetries: maxRetries
|
|
452
|
+
}))
|
|
453
|
+
];
|
|
454
|
+
case 1:
|
|
455
|
+
output = _state.sent().output;
|
|
456
|
+
return [
|
|
457
|
+
2,
|
|
458
|
+
output
|
|
459
|
+
];
|
|
460
|
+
case 2:
|
|
461
|
+
return [
|
|
462
|
+
4,
|
|
463
|
+
generateText(_object_spread({
|
|
464
|
+
model: this.model,
|
|
465
|
+
output: Output.object({
|
|
466
|
+
schema: schema,
|
|
467
|
+
name: schemaName,
|
|
468
|
+
description: schemaDescription
|
|
469
|
+
}),
|
|
470
|
+
prompt: prompt || ''
|
|
471
|
+
}, maxRetries !== undefined && {
|
|
472
|
+
maxRetries: maxRetries
|
|
473
|
+
}))
|
|
474
|
+
];
|
|
475
|
+
case 3:
|
|
476
|
+
output1 = _state.sent().output;
|
|
477
|
+
return [
|
|
478
|
+
2,
|
|
479
|
+
output1
|
|
480
|
+
];
|
|
481
|
+
case 4:
|
|
482
|
+
return [
|
|
483
|
+
2
|
|
484
|
+
];
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
}).call(_this);
|
|
488
|
+
})
|
|
489
|
+
];
|
|
325
490
|
});
|
|
326
491
|
}).call(this);
|
|
327
492
|
}
|
|
@@ -330,156 +495,166 @@ export var VercelClient = /*#__PURE__*/ function() {
|
|
|
330
495
|
key: "generateText",
|
|
331
496
|
value: function generateText1(params) {
|
|
332
497
|
return _async_to_generator(function() {
|
|
333
|
-
var
|
|
498
|
+
var _this, system, messages, responseMessages, tools, _params_toolChoice, toolChoice, modelMessages, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, msg, contentParts, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, tc, aiTools, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _step_value, name, tool;
|
|
334
499
|
return _ts_generator(this, function(_state) {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
500
|
+
_this = this;
|
|
501
|
+
system = params.system, messages = params.messages, responseMessages = params.responseMessages, tools = params.tools, _params_toolChoice = params.toolChoice, toolChoice = _params_toolChoice === void 0 ? 'required' : _params_toolChoice;
|
|
502
|
+
if (responseMessages && responseMessages.length > 0) {
|
|
503
|
+
// Use the SDK-native messages directly (preserves providerOptions/thoughtSignature)
|
|
504
|
+
modelMessages = responseMessages;
|
|
505
|
+
} else {
|
|
506
|
+
// First call - convert our ToolMessage format to SDK format
|
|
507
|
+
modelMessages = [];
|
|
508
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
509
|
+
try {
|
|
510
|
+
for(_iterator = messages[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
511
|
+
msg = _step.value;
|
|
512
|
+
if (msg.role === 'user') {
|
|
513
|
+
modelMessages.push({
|
|
514
|
+
role: 'user',
|
|
515
|
+
content: msg.content
|
|
516
|
+
});
|
|
517
|
+
} else if (msg.role === 'assistant') {
|
|
518
|
+
contentParts = [];
|
|
519
|
+
if (msg.content) {
|
|
520
|
+
contentParts.push({
|
|
521
|
+
type: 'text',
|
|
522
|
+
text: msg.content
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
if (msg.toolCalls && msg.toolCalls.length > 0) {
|
|
526
|
+
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
527
|
+
try {
|
|
528
|
+
for(_iterator1 = msg.toolCalls[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
529
|
+
tc = _step1.value;
|
|
356
530
|
contentParts.push({
|
|
357
|
-
type: '
|
|
358
|
-
|
|
531
|
+
type: 'tool-call',
|
|
532
|
+
toolCallId: tc.toolCallId,
|
|
533
|
+
toolName: tc.toolName,
|
|
534
|
+
input: tc.args
|
|
359
535
|
});
|
|
360
536
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
}
|
|
373
|
-
} catch (err) {
|
|
374
|
-
_didIteratorError1 = true;
|
|
375
|
-
_iteratorError1 = err;
|
|
376
|
-
} finally{
|
|
377
|
-
try {
|
|
378
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
379
|
-
_iterator1.return();
|
|
380
|
-
}
|
|
381
|
-
} finally{
|
|
382
|
-
if (_didIteratorError1) {
|
|
383
|
-
throw _iteratorError1;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
537
|
+
} catch (err) {
|
|
538
|
+
_didIteratorError1 = true;
|
|
539
|
+
_iteratorError1 = err;
|
|
540
|
+
} finally{
|
|
541
|
+
try {
|
|
542
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
543
|
+
_iterator1.return();
|
|
544
|
+
}
|
|
545
|
+
} finally{
|
|
546
|
+
if (_didIteratorError1) {
|
|
547
|
+
throw _iteratorError1;
|
|
386
548
|
}
|
|
387
549
|
}
|
|
388
|
-
if (contentParts.length > 0) {
|
|
389
|
-
modelMessages.push({
|
|
390
|
-
role: 'assistant',
|
|
391
|
-
content: contentParts
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
} else if (msg.role === 'tool') {
|
|
395
|
-
modelMessages.push({
|
|
396
|
-
role: 'tool',
|
|
397
|
-
content: [
|
|
398
|
-
{
|
|
399
|
-
type: 'tool-result',
|
|
400
|
-
toolCallId: msg.toolCallId,
|
|
401
|
-
toolName: msg.toolName,
|
|
402
|
-
output: {
|
|
403
|
-
type: 'text',
|
|
404
|
-
value: msg.content
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
]
|
|
408
|
-
});
|
|
409
550
|
}
|
|
410
551
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
417
|
-
_iterator.return();
|
|
418
|
-
}
|
|
419
|
-
} finally{
|
|
420
|
-
if (_didIteratorError) {
|
|
421
|
-
throw _iteratorError;
|
|
422
|
-
}
|
|
552
|
+
if (contentParts.length > 0) {
|
|
553
|
+
modelMessages.push({
|
|
554
|
+
role: 'assistant',
|
|
555
|
+
content: contentParts
|
|
556
|
+
});
|
|
423
557
|
}
|
|
558
|
+
} else if (msg.role === 'tool') {
|
|
559
|
+
modelMessages.push({
|
|
560
|
+
role: 'tool',
|
|
561
|
+
content: [
|
|
562
|
+
{
|
|
563
|
+
type: 'tool-result',
|
|
564
|
+
toolCallId: msg.toolCallId,
|
|
565
|
+
toolName: msg.toolName,
|
|
566
|
+
output: {
|
|
567
|
+
type: 'text',
|
|
568
|
+
value: msg.content
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
]
|
|
572
|
+
});
|
|
424
573
|
}
|
|
425
574
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
575
|
+
} catch (err) {
|
|
576
|
+
_didIteratorError = true;
|
|
577
|
+
_iteratorError = err;
|
|
578
|
+
} finally{
|
|
429
579
|
try {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
aiTools[name] = {
|
|
433
|
-
description: tool.description,
|
|
434
|
-
inputSchema: tool.inputSchema
|
|
435
|
-
};
|
|
580
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
581
|
+
_iterator.return();
|
|
436
582
|
}
|
|
437
|
-
} catch (err) {
|
|
438
|
-
_didIteratorError2 = true;
|
|
439
|
-
_iteratorError2 = err;
|
|
440
583
|
} finally{
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
_iterator2.return();
|
|
444
|
-
}
|
|
445
|
-
} finally{
|
|
446
|
-
if (_didIteratorError2) {
|
|
447
|
-
throw _iteratorError2;
|
|
448
|
-
}
|
|
584
|
+
if (_didIteratorError) {
|
|
585
|
+
throw _iteratorError;
|
|
449
586
|
}
|
|
450
587
|
}
|
|
451
|
-
|
|
452
|
-
4,
|
|
453
|
-
generateText({
|
|
454
|
-
model: this.model,
|
|
455
|
-
system: system,
|
|
456
|
-
messages: modelMessages,
|
|
457
|
-
tools: aiTools
|
|
458
|
-
})
|
|
459
|
-
];
|
|
460
|
-
case 1:
|
|
461
|
-
result = _state.sent();
|
|
462
|
-
// Return the updated conversation (input messages + new response messages)
|
|
463
|
-
// The response.messages contain proper providerOptions for Gemini thoughtSignature etc.
|
|
464
|
-
updatedMessages = _to_consumable_array(modelMessages).concat(_to_consumable_array(result.response.messages));
|
|
465
|
-
return [
|
|
466
|
-
2,
|
|
467
|
-
{
|
|
468
|
-
text: result.text || undefined,
|
|
469
|
-
toolCalls: (_result_toolCalls = result.toolCalls) === null || _result_toolCalls === void 0 ? void 0 : _result_toolCalls.map(function(tc) {
|
|
470
|
-
return {
|
|
471
|
-
toolCallId: tc.toolCallId,
|
|
472
|
-
toolName: tc.toolName,
|
|
473
|
-
args: tc.input
|
|
474
|
-
};
|
|
475
|
-
}),
|
|
476
|
-
usage: {
|
|
477
|
-
totalTokens: (_result_usage_totalTokens = (_result_usage = result.usage) === null || _result_usage === void 0 ? void 0 : _result_usage.totalTokens) !== null && _result_usage_totalTokens !== void 0 ? _result_usage_totalTokens : 0
|
|
478
|
-
},
|
|
479
|
-
responseMessages: updatedMessages
|
|
480
|
-
}
|
|
481
|
-
];
|
|
588
|
+
}
|
|
482
589
|
}
|
|
590
|
+
// Convert our tool format to Vercel AI SDK format
|
|
591
|
+
aiTools = {};
|
|
592
|
+
_iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
|
|
593
|
+
try {
|
|
594
|
+
for(_iterator2 = Object.entries(tools)[Symbol.iterator](); !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
|
|
595
|
+
_step_value = _sliced_to_array(_step2.value, 2), name = _step_value[0], tool = _step_value[1];
|
|
596
|
+
aiTools[name] = {
|
|
597
|
+
description: tool.description,
|
|
598
|
+
inputSchema: tool.inputSchema
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
} catch (err) {
|
|
602
|
+
_didIteratorError2 = true;
|
|
603
|
+
_iteratorError2 = err;
|
|
604
|
+
} finally{
|
|
605
|
+
try {
|
|
606
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
607
|
+
_iterator2.return();
|
|
608
|
+
}
|
|
609
|
+
} finally{
|
|
610
|
+
if (_didIteratorError2) {
|
|
611
|
+
throw _iteratorError2;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return [
|
|
616
|
+
2,
|
|
617
|
+
retryWithBackoff(function() {
|
|
618
|
+
return _async_to_generator(function() {
|
|
619
|
+
var _result_toolCalls, _result_usage, result, updatedMessages, _result_usage_totalTokens;
|
|
620
|
+
return _ts_generator(this, function(_state) {
|
|
621
|
+
switch(_state.label){
|
|
622
|
+
case 0:
|
|
623
|
+
return [
|
|
624
|
+
4,
|
|
625
|
+
generateText({
|
|
626
|
+
model: this.model,
|
|
627
|
+
system: system,
|
|
628
|
+
toolChoice: toolChoice,
|
|
629
|
+
messages: modelMessages,
|
|
630
|
+
tools: aiTools
|
|
631
|
+
})
|
|
632
|
+
];
|
|
633
|
+
case 1:
|
|
634
|
+
result = _state.sent();
|
|
635
|
+
updatedMessages = _to_consumable_array(modelMessages).concat(_to_consumable_array(result.response.messages));
|
|
636
|
+
return [
|
|
637
|
+
2,
|
|
638
|
+
{
|
|
639
|
+
text: result.text || undefined,
|
|
640
|
+
toolCalls: (_result_toolCalls = result.toolCalls) === null || _result_toolCalls === void 0 ? void 0 : _result_toolCalls.map(function(tc) {
|
|
641
|
+
return {
|
|
642
|
+
toolCallId: tc.toolCallId,
|
|
643
|
+
toolName: tc.toolName,
|
|
644
|
+
args: tc.input
|
|
645
|
+
};
|
|
646
|
+
}),
|
|
647
|
+
usage: {
|
|
648
|
+
totalTokens: (_result_usage_totalTokens = (_result_usage = result.usage) === null || _result_usage === void 0 ? void 0 : _result_usage.totalTokens) !== null && _result_usage_totalTokens !== void 0 ? _result_usage_totalTokens : 0
|
|
649
|
+
},
|
|
650
|
+
responseMessages: updatedMessages
|
|
651
|
+
}
|
|
652
|
+
];
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
}).call(_this);
|
|
656
|
+
})
|
|
657
|
+
];
|
|
483
658
|
});
|
|
484
659
|
}).call(this);
|
|
485
660
|
}
|
|
@@ -488,220 +663,229 @@ export var VercelClient = /*#__PURE__*/ function() {
|
|
|
488
663
|
key: "streamText",
|
|
489
664
|
value: function streamText(params) {
|
|
490
665
|
return _async_to_generator(function() {
|
|
491
|
-
var system, prompt, messages, tools, _params_maxSteps, maxSteps, modelMessages, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, msg, contentParts, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, tc, aiTools, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _step_value, name, tool
|
|
666
|
+
var _this, system, prompt, messages, tools, _params_maxSteps, maxSteps, _params_toolChoice, toolChoice, modelMessages, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, msg, contentParts, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, tc, aiTools, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _step_value, name, tool;
|
|
492
667
|
return _ts_generator(this, function(_state) {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
668
|
+
_this = this;
|
|
669
|
+
system = params.system, prompt = params.prompt, messages = params.messages, tools = params.tools, _params_maxSteps = params.maxSteps, maxSteps = _params_maxSteps === void 0 ? 10 : _params_maxSteps, _params_toolChoice = params.toolChoice, toolChoice = _params_toolChoice === void 0 ? 'required' : _params_toolChoice;
|
|
670
|
+
// Build messages array
|
|
671
|
+
modelMessages = [];
|
|
672
|
+
if (system) {
|
|
673
|
+
modelMessages.push({
|
|
674
|
+
role: 'system',
|
|
675
|
+
content: system
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
// Add any context messages
|
|
679
|
+
if (messages) {
|
|
680
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
681
|
+
try {
|
|
682
|
+
for(_iterator = messages[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
683
|
+
msg = _step.value;
|
|
684
|
+
if (msg.role === 'user') {
|
|
685
|
+
modelMessages.push({
|
|
686
|
+
role: 'user',
|
|
687
|
+
content: msg.content
|
|
688
|
+
});
|
|
689
|
+
} else if (msg.role === 'assistant') {
|
|
690
|
+
// Build content array for assistant message
|
|
691
|
+
contentParts = [];
|
|
692
|
+
// Add text if present
|
|
693
|
+
if (msg.content) {
|
|
694
|
+
contentParts.push({
|
|
695
|
+
type: 'text',
|
|
696
|
+
text: msg.content
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
// Add tool calls if present (using 'input' as Vercel SDK expects)
|
|
700
|
+
if (msg.toolCalls && msg.toolCalls.length > 0) {
|
|
701
|
+
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
702
|
+
try {
|
|
703
|
+
for(_iterator1 = msg.toolCalls[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
704
|
+
tc = _step1.value;
|
|
520
705
|
contentParts.push({
|
|
521
|
-
type: '
|
|
522
|
-
|
|
706
|
+
type: 'tool-call',
|
|
707
|
+
toolCallId: tc.toolCallId,
|
|
708
|
+
toolName: tc.toolName,
|
|
709
|
+
input: tc.args
|
|
523
710
|
});
|
|
524
711
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
} catch (err) {
|
|
539
|
-
_didIteratorError1 = true;
|
|
540
|
-
_iteratorError1 = err;
|
|
541
|
-
} finally{
|
|
542
|
-
try {
|
|
543
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
544
|
-
_iterator1.return();
|
|
545
|
-
}
|
|
546
|
-
} finally{
|
|
547
|
-
if (_didIteratorError1) {
|
|
548
|
-
throw _iteratorError1;
|
|
549
|
-
}
|
|
550
|
-
}
|
|
712
|
+
} catch (err) {
|
|
713
|
+
_didIteratorError1 = true;
|
|
714
|
+
_iteratorError1 = err;
|
|
715
|
+
} finally{
|
|
716
|
+
try {
|
|
717
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
718
|
+
_iterator1.return();
|
|
719
|
+
}
|
|
720
|
+
} finally{
|
|
721
|
+
if (_didIteratorError1) {
|
|
722
|
+
throw _iteratorError1;
|
|
551
723
|
}
|
|
552
724
|
}
|
|
553
|
-
// Push message with content array or string
|
|
554
|
-
if (contentParts.length > 0) {
|
|
555
|
-
modelMessages.push({
|
|
556
|
-
role: 'assistant',
|
|
557
|
-
content: contentParts
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
} else if (msg.role === 'tool') {
|
|
561
|
-
modelMessages.push({
|
|
562
|
-
role: 'tool',
|
|
563
|
-
content: [
|
|
564
|
-
{
|
|
565
|
-
type: 'tool-result',
|
|
566
|
-
toolCallId: msg.toolCallId,
|
|
567
|
-
toolName: msg.toolName,
|
|
568
|
-
output: {
|
|
569
|
-
type: 'text',
|
|
570
|
-
value: msg.content
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
]
|
|
574
|
-
});
|
|
575
725
|
}
|
|
576
726
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
_iterator.return();
|
|
584
|
-
}
|
|
585
|
-
} finally{
|
|
586
|
-
if (_didIteratorError) {
|
|
587
|
-
throw _iteratorError;
|
|
588
|
-
}
|
|
727
|
+
// Push message with content array or string
|
|
728
|
+
if (contentParts.length > 0) {
|
|
729
|
+
modelMessages.push({
|
|
730
|
+
role: 'assistant',
|
|
731
|
+
content: contentParts
|
|
732
|
+
});
|
|
589
733
|
}
|
|
734
|
+
} else if (msg.role === 'tool') {
|
|
735
|
+
modelMessages.push({
|
|
736
|
+
role: 'tool',
|
|
737
|
+
content: [
|
|
738
|
+
{
|
|
739
|
+
type: 'tool-result',
|
|
740
|
+
toolCallId: msg.toolCallId,
|
|
741
|
+
toolName: msg.toolName,
|
|
742
|
+
output: {
|
|
743
|
+
type: 'text',
|
|
744
|
+
value: msg.content
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
]
|
|
748
|
+
});
|
|
590
749
|
}
|
|
591
750
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
});
|
|
597
|
-
// Convert tools to Vercel AI SDK format (with execute functions)
|
|
598
|
-
aiTools = {};
|
|
599
|
-
_iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
|
|
751
|
+
} catch (err) {
|
|
752
|
+
_didIteratorError = true;
|
|
753
|
+
_iteratorError = err;
|
|
754
|
+
} finally{
|
|
600
755
|
try {
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
aiTools[name] = {
|
|
604
|
-
description: tool.description,
|
|
605
|
-
inputSchema: tool.inputSchema,
|
|
606
|
-
execute: tool.execute
|
|
607
|
-
};
|
|
756
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
757
|
+
_iterator.return();
|
|
608
758
|
}
|
|
609
|
-
} catch (err) {
|
|
610
|
-
_didIteratorError2 = true;
|
|
611
|
-
_iteratorError2 = err;
|
|
612
759
|
} finally{
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
_iterator2.return();
|
|
616
|
-
}
|
|
617
|
-
} finally{
|
|
618
|
-
if (_didIteratorError2) {
|
|
619
|
-
throw _iteratorError2;
|
|
620
|
-
}
|
|
760
|
+
if (_didIteratorError) {
|
|
761
|
+
throw _iteratorError;
|
|
621
762
|
}
|
|
622
763
|
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
// Add the initial prompt
|
|
767
|
+
modelMessages.push({
|
|
768
|
+
role: 'user',
|
|
769
|
+
content: prompt
|
|
770
|
+
});
|
|
771
|
+
// Convert tools to Vercel AI SDK format (with execute functions)
|
|
772
|
+
aiTools = {};
|
|
773
|
+
_iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
|
|
774
|
+
try {
|
|
775
|
+
for(_iterator2 = Object.entries(tools)[Symbol.iterator](); !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
|
|
776
|
+
_step_value = _sliced_to_array(_step2.value, 2), name = _step_value[0], tool = _step_value[1];
|
|
777
|
+
aiTools[name] = {
|
|
778
|
+
description: tool.description,
|
|
779
|
+
inputSchema: tool.inputSchema,
|
|
780
|
+
execute: tool.execute
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
} catch (err) {
|
|
784
|
+
_didIteratorError2 = true;
|
|
785
|
+
_iteratorError2 = err;
|
|
786
|
+
} finally{
|
|
787
|
+
try {
|
|
788
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
789
|
+
_iterator2.return();
|
|
790
|
+
}
|
|
791
|
+
} finally{
|
|
792
|
+
if (_didIteratorError2) {
|
|
793
|
+
throw _iteratorError2;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
return [
|
|
798
|
+
2,
|
|
799
|
+
retryWithBackoff(function() {
|
|
800
|
+
return _async_to_generator(function() {
|
|
801
|
+
var stream, _ref, steps, text, usage, allToolCalls, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, step, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _loop, _iterator1, _step1, _usage_totalTokens;
|
|
802
|
+
return _ts_generator(this, function(_state) {
|
|
803
|
+
switch(_state.label){
|
|
804
|
+
case 0:
|
|
805
|
+
stream = vercelStreamText({
|
|
806
|
+
model: this.model,
|
|
807
|
+
messages: modelMessages,
|
|
808
|
+
tools: aiTools,
|
|
809
|
+
toolChoice: toolChoice,
|
|
810
|
+
stopWhen: stepCountIs(maxSteps)
|
|
661
811
|
});
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
812
|
+
return [
|
|
813
|
+
4,
|
|
814
|
+
Promise.all([
|
|
815
|
+
stream.steps,
|
|
816
|
+
stream.text,
|
|
817
|
+
stream.totalUsage
|
|
818
|
+
])
|
|
819
|
+
];
|
|
820
|
+
case 1:
|
|
821
|
+
_ref = _sliced_to_array.apply(void 0, [
|
|
822
|
+
_state.sent(),
|
|
823
|
+
3
|
|
824
|
+
]), steps = _ref[0], text = _ref[1], usage = _ref[2];
|
|
825
|
+
allToolCalls = [];
|
|
826
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
827
|
+
try {
|
|
828
|
+
for(_iterator = steps[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
829
|
+
step = _step.value;
|
|
830
|
+
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
831
|
+
try {
|
|
832
|
+
_loop = function() {
|
|
833
|
+
var toolCall = _step1.value;
|
|
834
|
+
var toolResult = step.toolResults.find(function(tr) {
|
|
835
|
+
return tr.toolCallId === toolCall.toolCallId;
|
|
836
|
+
});
|
|
837
|
+
allToolCalls.push({
|
|
838
|
+
toolCallId: toolCall.toolCallId,
|
|
839
|
+
toolName: toolCall.toolName,
|
|
840
|
+
args: toolCall.input,
|
|
841
|
+
result: toolResult === null || toolResult === void 0 ? void 0 : toolResult.output
|
|
842
|
+
});
|
|
843
|
+
};
|
|
844
|
+
for(_iterator1 = step.toolCalls[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true)_loop();
|
|
845
|
+
} catch (err) {
|
|
846
|
+
_didIteratorError1 = true;
|
|
847
|
+
_iteratorError1 = err;
|
|
848
|
+
} finally{
|
|
849
|
+
try {
|
|
850
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
851
|
+
_iterator1.return();
|
|
852
|
+
}
|
|
853
|
+
} finally{
|
|
854
|
+
if (_didIteratorError1) {
|
|
855
|
+
throw _iteratorError1;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
} catch (err) {
|
|
861
|
+
_didIteratorError = true;
|
|
862
|
+
_iteratorError = err;
|
|
863
|
+
} finally{
|
|
864
|
+
try {
|
|
865
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
866
|
+
_iterator.return();
|
|
867
|
+
}
|
|
868
|
+
} finally{
|
|
869
|
+
if (_didIteratorError) {
|
|
870
|
+
throw _iteratorError;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
676
873
|
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
}
|
|
688
|
-
} finally{
|
|
689
|
-
if (_didIteratorError3) {
|
|
690
|
-
throw _iteratorError3;
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
return [
|
|
695
|
-
2,
|
|
696
|
-
{
|
|
697
|
-
toolCalls: allToolCalls,
|
|
698
|
-
text: text || undefined,
|
|
699
|
-
usage: {
|
|
700
|
-
totalTokens: (_usage_totalTokens = usage === null || usage === void 0 ? void 0 : usage.totalTokens) !== null && _usage_totalTokens !== void 0 ? _usage_totalTokens : 0
|
|
874
|
+
return [
|
|
875
|
+
2,
|
|
876
|
+
{
|
|
877
|
+
toolCalls: allToolCalls,
|
|
878
|
+
text: text || undefined,
|
|
879
|
+
usage: {
|
|
880
|
+
totalTokens: (_usage_totalTokens = usage === null || usage === void 0 ? void 0 : usage.totalTokens) !== null && _usage_totalTokens !== void 0 ? _usage_totalTokens : 0
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
];
|
|
701
884
|
}
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
|
|
885
|
+
});
|
|
886
|
+
}).call(_this);
|
|
887
|
+
})
|
|
888
|
+
];
|
|
705
889
|
});
|
|
706
890
|
}).call(this);
|
|
707
891
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ObjectGenerator, Message, ToolMessage, ResponseMessage } from '@positronic/core';
|
|
1
|
+
import type { ObjectGenerator, Message, ToolMessage, ResponseMessage, ToolChoice } from '@positronic/core';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import type { LanguageModel } from 'ai';
|
|
4
4
|
/**
|
|
@@ -20,6 +20,7 @@ export declare class VercelClient implements ObjectGenerator {
|
|
|
20
20
|
prompt?: string;
|
|
21
21
|
messages?: Message[];
|
|
22
22
|
system?: string;
|
|
23
|
+
maxRetries?: number;
|
|
23
24
|
}): Promise<z.infer<T>>;
|
|
24
25
|
generateText(params: {
|
|
25
26
|
system?: string;
|
|
@@ -29,6 +30,7 @@ export declare class VercelClient implements ObjectGenerator {
|
|
|
29
30
|
description: string;
|
|
30
31
|
inputSchema: z.ZodSchema;
|
|
31
32
|
}>;
|
|
33
|
+
toolChoice?: ToolChoice;
|
|
32
34
|
}): Promise<{
|
|
33
35
|
text?: string;
|
|
34
36
|
toolCalls?: Array<{
|
|
@@ -51,6 +53,7 @@ export declare class VercelClient implements ObjectGenerator {
|
|
|
51
53
|
execute?: (args: unknown) => Promise<unknown> | unknown;
|
|
52
54
|
}>;
|
|
53
55
|
maxSteps?: number;
|
|
56
|
+
toolChoice?: ToolChoice;
|
|
54
57
|
}): Promise<{
|
|
55
58
|
toolCalls: Array<{
|
|
56
59
|
toolCallId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAO3G,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,IAAI,CAAC;AAmDtD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,GACd,eAAe,CAgBjB;AAED,qBAAa,YAAa,YAAW,eAAe;IAClD,OAAO,CAAC,KAAK,CAAgB;gBAEjB,KAAK,EAAE,aAAa;IAIhC,uBAAuB,CACrB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,GACd,eAAe;IAIZ,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,YAAY,EAAE,MAAM,EAAE;QACrD,MAAM,EAAE,CAAC,CAAC;QACV,UAAU,EAAE,MAAM,CAAC;QACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;QACrB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAoDjB,YAAY,CAAC,MAAM,EAAE;QACzB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,WAAW,EAAE,CAAC;QACxB,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;QACrC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,WAAW,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,CAAC,CAAC,SAAS,CAAA;SAAE,CAAC,CAAC;QACzE,UAAU,CAAC,EAAE,UAAU,CAAC;KACzB,GAAG,OAAO,CAAC;QACV,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,KAAK,CAAC;YAAE,UAAU,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,OAAO,CAAA;SAAE,CAAC,CAAC;QAC3E,KAAK,EAAE;YAAE,WAAW,EAAE,MAAM,CAAA;SAAE,CAAC;QAC/B,gBAAgB,EAAE,eAAe,EAAE,CAAC;KACrC,CAAC;IA6FI,UAAU,CAAC,MAAM,EAAE;QACvB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;QACzB,KAAK,EAAE,MAAM,CACX,MAAM,EACN;YACE,WAAW,EAAE,MAAM,CAAC;YACpB,WAAW,EAAE,CAAC,CAAC,SAAS,CAAC;YACzB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;SACzD,CACF,CAAC;QACF,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,UAAU,CAAC;KACzB,GAAG,OAAO,CAAC;QACV,SAAS,EAAE,KAAK,CAAC;YACf,UAAU,EAAE,MAAM,CAAC;YACnB,QAAQ,EAAE,MAAM,CAAC;YACjB,IAAI,EAAE,OAAO,CAAC;YACd,MAAM,EAAE,OAAO,CAAC;SACjB,CAAC,CAAC;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,EAAE;YAAE,WAAW,EAAE,MAAM,CAAA;SAAE,CAAC;KAChC,CAAC;CA4HH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@positronic/client-vercel",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.63",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"ai": "^6.0.0"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@positronic/core": "^0.0.
|
|
26
|
+
"@positronic/core": "^0.0.63",
|
|
27
27
|
"zod": "^3.24.1"
|
|
28
28
|
}
|
|
29
29
|
}
|