@mastra/core 0.1.27-alpha.28 → 0.1.27-alpha.29
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/agent/index.d.ts +12 -1
- package/dist/core.cjs.development.js +283 -97
- package/dist/core.cjs.development.js.map +1 -1
- package/dist/core.cjs.production.min.js +1 -1
- package/dist/core.cjs.production.min.js.map +1 -1
- package/dist/core.esm.js +283 -97
- package/dist/core.esm.js.map +1 -1
- package/dist/llm/index.d.ts +7 -9
- package/dist/llm/types.d.ts +3 -1
- package/package.json +1 -1
package/dist/agent/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { CoreAssistantMessage, CoreMessage, CoreToolMessage, CoreUserMessage, Us
|
|
|
2
2
|
import { ZodSchema } from 'zod';
|
|
3
3
|
import { Integration } from '../integration';
|
|
4
4
|
import { LLM } from '../llm';
|
|
5
|
-
import { ModelConfig, StructuredOutput } from '../llm/types';
|
|
5
|
+
import { GenerateReturn, ModelConfig, StructuredOutput } from '../llm/types';
|
|
6
6
|
import { Logger } from '../logger';
|
|
7
7
|
import { MastraMemory } from '../memory';
|
|
8
8
|
import { Run } from '../run/types';
|
|
@@ -89,6 +89,17 @@ export declare class Agent<TTools, TIntegrations extends Integration[] | undefin
|
|
|
89
89
|
threadId: string;
|
|
90
90
|
}) => Promise<void>;
|
|
91
91
|
};
|
|
92
|
+
generate<S extends boolean = false, Z extends ZodSchema | undefined = undefined>(messages: string | string[] | CoreMessage[], { schema, stream, context, threadId: threadIdInFn, resourceid, maxSteps, onFinish, onStepFinish, runId, }?: {
|
|
93
|
+
resourceid?: string;
|
|
94
|
+
context?: CoreMessage[];
|
|
95
|
+
threadId?: string;
|
|
96
|
+
runId?: string;
|
|
97
|
+
stream?: S;
|
|
98
|
+
schema?: Z;
|
|
99
|
+
onFinish?: (result: string) => Promise<void> | void;
|
|
100
|
+
onStepFinish?: (step: string) => void;
|
|
101
|
+
maxSteps?: number;
|
|
102
|
+
}): Promise<GenerateReturn<S, Z>>;
|
|
92
103
|
text({ messages, context, onStepFinish, maxSteps, threadId: threadIdInFn, resourceid, runId, }: {
|
|
93
104
|
resourceid?: string;
|
|
94
105
|
threadId?: string;
|
|
@@ -1538,7 +1538,15 @@ var LLM = (_model = /*#__PURE__*/_classPrivateFieldLooseKey("model"), _tools$1 =
|
|
|
1538
1538
|
case 0:
|
|
1539
1539
|
_ref8 = _temp === void 0 ? {} : _temp, schema = _ref8.schema, stream = _ref8.stream, _ref8$maxSteps = _ref8.maxSteps, maxSteps = _ref8$maxSteps === void 0 ? 5 : _ref8$maxSteps, onFinish = _ref8.onFinish, onStepFinish = _ref8.onStepFinish, enabledTools = _ref8.enabledTools, convertedTools = _ref8.convertedTools, runId = _ref8.runId;
|
|
1540
1540
|
if (Array.isArray(messages)) {
|
|
1541
|
-
msgs = messages
|
|
1541
|
+
msgs = messages == null ? void 0 : messages.map(function (m) {
|
|
1542
|
+
if (typeof m === 'string') {
|
|
1543
|
+
return {
|
|
1544
|
+
role: 'user',
|
|
1545
|
+
content: m
|
|
1546
|
+
};
|
|
1547
|
+
}
|
|
1548
|
+
return m;
|
|
1549
|
+
});
|
|
1542
1550
|
} else {
|
|
1543
1551
|
msgs = [{
|
|
1544
1552
|
role: 'user',
|
|
@@ -2886,28 +2894,206 @@ exports.Agent = (_tools = /*#__PURE__*/_classPrivateFieldLooseKey("tools"), _log
|
|
|
2886
2894
|
}()
|
|
2887
2895
|
};
|
|
2888
2896
|
};
|
|
2889
|
-
_proto.
|
|
2890
|
-
var
|
|
2891
|
-
var
|
|
2892
|
-
return _regeneratorRuntime().wrap(function
|
|
2893
|
-
while (1) switch (
|
|
2897
|
+
_proto.generate = /*#__PURE__*/function () {
|
|
2898
|
+
var _generate = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(messages, _temp) {
|
|
2899
|
+
var _ref8, schema, stream, context, threadIdInFn, resourceid, _ref8$maxSteps, maxSteps, _onFinish, onStepFinish, runId, messagesToUse, _this$__primitive, before, after, _yield$before, threadId, messageObjects, convertedTools, _result, result;
|
|
2900
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
2901
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
2894
2902
|
case 0:
|
|
2895
|
-
|
|
2903
|
+
_ref8 = _temp === void 0 ? {} : _temp, schema = _ref8.schema, stream = _ref8.stream, context = _ref8.context, threadIdInFn = _ref8.threadId, resourceid = _ref8.resourceid, _ref8$maxSteps = _ref8.maxSteps, maxSteps = _ref8$maxSteps === void 0 ? 5 : _ref8$maxSteps, _onFinish = _ref8.onFinish, onStepFinish = _ref8.onStepFinish, runId = _ref8.runId;
|
|
2904
|
+
messagesToUse = [];
|
|
2905
|
+
if (Array.isArray(messages)) {
|
|
2906
|
+
messagesToUse = messages.map(function (content) {
|
|
2907
|
+
if (typeof content === 'string') {
|
|
2908
|
+
return content;
|
|
2909
|
+
}
|
|
2910
|
+
return content.content;
|
|
2911
|
+
});
|
|
2912
|
+
} else {
|
|
2913
|
+
messagesToUse = [messages];
|
|
2914
|
+
}
|
|
2896
2915
|
_this$__primitive = this.__primitive({
|
|
2897
|
-
messages:
|
|
2916
|
+
messages: messagesToUse,
|
|
2898
2917
|
context: context,
|
|
2899
2918
|
threadId: threadIdInFn,
|
|
2900
2919
|
resourceid: resourceid,
|
|
2901
2920
|
runId: runId
|
|
2902
2921
|
}), before = _this$__primitive.before, after = _this$__primitive.after;
|
|
2903
|
-
|
|
2922
|
+
_context11.next = 6;
|
|
2904
2923
|
return before();
|
|
2905
|
-
case
|
|
2906
|
-
_yield$before =
|
|
2924
|
+
case 6:
|
|
2925
|
+
_yield$before = _context11.sent;
|
|
2907
2926
|
threadId = _yield$before.threadId;
|
|
2908
2927
|
messageObjects = _yield$before.messageObjects;
|
|
2909
2928
|
convertedTools = _yield$before.convertedTools;
|
|
2910
|
-
|
|
2929
|
+
if (!(stream && schema)) {
|
|
2930
|
+
_context11.next = 12;
|
|
2931
|
+
break;
|
|
2932
|
+
}
|
|
2933
|
+
return _context11.abrupt("return", this.llm.__streamObject({
|
|
2934
|
+
messages: messageObjects,
|
|
2935
|
+
structuredOutput: schema,
|
|
2936
|
+
enabledTools: this.enabledTools,
|
|
2937
|
+
convertedTools: convertedTools,
|
|
2938
|
+
onStepFinish: onStepFinish,
|
|
2939
|
+
onFinish: function () {
|
|
2940
|
+
var _onFinish2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(result) {
|
|
2941
|
+
var res;
|
|
2942
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
2943
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
2944
|
+
case 0:
|
|
2945
|
+
_context9.prev = 0;
|
|
2946
|
+
res = JSON.parse(result) || {};
|
|
2947
|
+
_context9.next = 4;
|
|
2948
|
+
return after({
|
|
2949
|
+
result: res,
|
|
2950
|
+
threadId: threadId
|
|
2951
|
+
});
|
|
2952
|
+
case 4:
|
|
2953
|
+
_context9.next = 9;
|
|
2954
|
+
break;
|
|
2955
|
+
case 6:
|
|
2956
|
+
_context9.prev = 6;
|
|
2957
|
+
_context9.t0 = _context9["catch"](0);
|
|
2958
|
+
console.error('Error saving memory on finish', _context9.t0);
|
|
2959
|
+
case 9:
|
|
2960
|
+
_onFinish == null || _onFinish(result);
|
|
2961
|
+
case 10:
|
|
2962
|
+
case "end":
|
|
2963
|
+
return _context9.stop();
|
|
2964
|
+
}
|
|
2965
|
+
}, _callee9, null, [[0, 6]]);
|
|
2966
|
+
}));
|
|
2967
|
+
function onFinish(_x10) {
|
|
2968
|
+
return _onFinish2.apply(this, arguments);
|
|
2969
|
+
}
|
|
2970
|
+
return onFinish;
|
|
2971
|
+
}(),
|
|
2972
|
+
maxSteps: maxSteps,
|
|
2973
|
+
runId: runId
|
|
2974
|
+
}));
|
|
2975
|
+
case 12:
|
|
2976
|
+
if (!stream) {
|
|
2977
|
+
_context11.next = 14;
|
|
2978
|
+
break;
|
|
2979
|
+
}
|
|
2980
|
+
return _context11.abrupt("return", this.llm.__stream({
|
|
2981
|
+
messages: messageObjects,
|
|
2982
|
+
enabledTools: this.enabledTools,
|
|
2983
|
+
convertedTools: convertedTools,
|
|
2984
|
+
onStepFinish: onStepFinish,
|
|
2985
|
+
onFinish: function () {
|
|
2986
|
+
var _onFinish3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(result) {
|
|
2987
|
+
var res;
|
|
2988
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
2989
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
2990
|
+
case 0:
|
|
2991
|
+
_context10.prev = 0;
|
|
2992
|
+
res = JSON.parse(result) || {};
|
|
2993
|
+
_context10.next = 4;
|
|
2994
|
+
return after({
|
|
2995
|
+
result: res,
|
|
2996
|
+
threadId: threadId
|
|
2997
|
+
});
|
|
2998
|
+
case 4:
|
|
2999
|
+
_context10.next = 9;
|
|
3000
|
+
break;
|
|
3001
|
+
case 6:
|
|
3002
|
+
_context10.prev = 6;
|
|
3003
|
+
_context10.t0 = _context10["catch"](0);
|
|
3004
|
+
console.error('Error saving memory on finish', _context10.t0);
|
|
3005
|
+
case 9:
|
|
3006
|
+
_onFinish == null || _onFinish(result);
|
|
3007
|
+
case 10:
|
|
3008
|
+
case "end":
|
|
3009
|
+
return _context10.stop();
|
|
3010
|
+
}
|
|
3011
|
+
}, _callee10, null, [[0, 6]]);
|
|
3012
|
+
}));
|
|
3013
|
+
function onFinish(_x11) {
|
|
3014
|
+
return _onFinish3.apply(this, arguments);
|
|
3015
|
+
}
|
|
3016
|
+
return onFinish;
|
|
3017
|
+
}(),
|
|
3018
|
+
maxSteps: maxSteps,
|
|
3019
|
+
runId: runId
|
|
3020
|
+
}));
|
|
3021
|
+
case 14:
|
|
3022
|
+
if (!schema) {
|
|
3023
|
+
_context11.next = 21;
|
|
3024
|
+
break;
|
|
3025
|
+
}
|
|
3026
|
+
_context11.next = 17;
|
|
3027
|
+
return this.llm.__textObject({
|
|
3028
|
+
messages: messageObjects,
|
|
3029
|
+
structuredOutput: schema,
|
|
3030
|
+
enabledTools: this.enabledTools,
|
|
3031
|
+
convertedTools: convertedTools,
|
|
3032
|
+
onStepFinish: onStepFinish,
|
|
3033
|
+
maxSteps: maxSteps,
|
|
3034
|
+
runId: runId
|
|
3035
|
+
});
|
|
3036
|
+
case 17:
|
|
3037
|
+
_result = _context11.sent;
|
|
3038
|
+
_context11.next = 20;
|
|
3039
|
+
return after({
|
|
3040
|
+
result: _result,
|
|
3041
|
+
threadId: threadId
|
|
3042
|
+
});
|
|
3043
|
+
case 20:
|
|
3044
|
+
return _context11.abrupt("return", _result);
|
|
3045
|
+
case 21:
|
|
3046
|
+
_context11.next = 23;
|
|
3047
|
+
return this.llm.__text({
|
|
3048
|
+
messages: messageObjects,
|
|
3049
|
+
enabledTools: this.enabledTools,
|
|
3050
|
+
convertedTools: convertedTools,
|
|
3051
|
+
onStepFinish: onStepFinish,
|
|
3052
|
+
maxSteps: maxSteps,
|
|
3053
|
+
runId: runId
|
|
3054
|
+
});
|
|
3055
|
+
case 23:
|
|
3056
|
+
result = _context11.sent;
|
|
3057
|
+
_context11.next = 26;
|
|
3058
|
+
return after({
|
|
3059
|
+
result: result,
|
|
3060
|
+
threadId: threadId
|
|
3061
|
+
});
|
|
3062
|
+
case 26:
|
|
3063
|
+
return _context11.abrupt("return", result);
|
|
3064
|
+
case 27:
|
|
3065
|
+
case "end":
|
|
3066
|
+
return _context11.stop();
|
|
3067
|
+
}
|
|
3068
|
+
}, _callee11, this);
|
|
3069
|
+
}));
|
|
3070
|
+
function generate(_x8, _x9) {
|
|
3071
|
+
return _generate.apply(this, arguments);
|
|
3072
|
+
}
|
|
3073
|
+
return generate;
|
|
3074
|
+
}();
|
|
3075
|
+
_proto.text = /*#__PURE__*/function () {
|
|
3076
|
+
var _text = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(_ref9) {
|
|
3077
|
+
var messages, context, onStepFinish, _ref9$maxSteps, maxSteps, threadIdInFn, resourceid, runId, _this$__primitive2, before, after, _yield$before2, threadId, messageObjects, convertedTools, result;
|
|
3078
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
3079
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
3080
|
+
case 0:
|
|
3081
|
+
messages = _ref9.messages, context = _ref9.context, onStepFinish = _ref9.onStepFinish, _ref9$maxSteps = _ref9.maxSteps, maxSteps = _ref9$maxSteps === void 0 ? 5 : _ref9$maxSteps, threadIdInFn = _ref9.threadId, resourceid = _ref9.resourceid, runId = _ref9.runId;
|
|
3082
|
+
_this$__primitive2 = this.__primitive({
|
|
3083
|
+
messages: messages,
|
|
3084
|
+
context: context,
|
|
3085
|
+
threadId: threadIdInFn,
|
|
3086
|
+
resourceid: resourceid,
|
|
3087
|
+
runId: runId
|
|
3088
|
+
}), before = _this$__primitive2.before, after = _this$__primitive2.after;
|
|
3089
|
+
_context12.next = 4;
|
|
3090
|
+
return before();
|
|
3091
|
+
case 4:
|
|
3092
|
+
_yield$before2 = _context12.sent;
|
|
3093
|
+
threadId = _yield$before2.threadId;
|
|
3094
|
+
messageObjects = _yield$before2.messageObjects;
|
|
3095
|
+
convertedTools = _yield$before2.convertedTools;
|
|
3096
|
+
_context12.next = 10;
|
|
2911
3097
|
return this.llm.__text({
|
|
2912
3098
|
messages: messageObjects,
|
|
2913
3099
|
enabledTools: this.enabledTools,
|
|
@@ -2917,47 +3103,47 @@ exports.Agent = (_tools = /*#__PURE__*/_classPrivateFieldLooseKey("tools"), _log
|
|
|
2917
3103
|
runId: runId
|
|
2918
3104
|
});
|
|
2919
3105
|
case 10:
|
|
2920
|
-
result =
|
|
2921
|
-
|
|
3106
|
+
result = _context12.sent;
|
|
3107
|
+
_context12.next = 13;
|
|
2922
3108
|
return after({
|
|
2923
3109
|
result: result,
|
|
2924
3110
|
threadId: threadId
|
|
2925
3111
|
});
|
|
2926
3112
|
case 13:
|
|
2927
|
-
return
|
|
3113
|
+
return _context12.abrupt("return", result);
|
|
2928
3114
|
case 14:
|
|
2929
3115
|
case "end":
|
|
2930
|
-
return
|
|
3116
|
+
return _context12.stop();
|
|
2931
3117
|
}
|
|
2932
|
-
},
|
|
3118
|
+
}, _callee12, this);
|
|
2933
3119
|
}));
|
|
2934
|
-
function text(
|
|
3120
|
+
function text(_x12) {
|
|
2935
3121
|
return _text.apply(this, arguments);
|
|
2936
3122
|
}
|
|
2937
3123
|
return text;
|
|
2938
3124
|
}();
|
|
2939
3125
|
_proto.textObject = /*#__PURE__*/function () {
|
|
2940
|
-
var _textObject = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2941
|
-
var messages, context, structuredOutput, onStepFinish,
|
|
2942
|
-
return _regeneratorRuntime().wrap(function
|
|
2943
|
-
while (1) switch (
|
|
3126
|
+
var _textObject = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(_ref10) {
|
|
3127
|
+
var messages, context, structuredOutput, onStepFinish, _ref10$maxSteps, maxSteps, threadIdInFn, resourceid, runId, _this$__primitive3, before, after, _yield$before3, threadId, messageObjects, convertedTools, result;
|
|
3128
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
3129
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
2944
3130
|
case 0:
|
|
2945
|
-
messages =
|
|
2946
|
-
_this$
|
|
3131
|
+
messages = _ref10.messages, context = _ref10.context, structuredOutput = _ref10.structuredOutput, onStepFinish = _ref10.onStepFinish, _ref10$maxSteps = _ref10.maxSteps, maxSteps = _ref10$maxSteps === void 0 ? 5 : _ref10$maxSteps, threadIdInFn = _ref10.threadId, resourceid = _ref10.resourceid, runId = _ref10.runId;
|
|
3132
|
+
_this$__primitive3 = this.__primitive({
|
|
2947
3133
|
messages: messages,
|
|
2948
3134
|
context: context,
|
|
2949
3135
|
threadId: threadIdInFn,
|
|
2950
3136
|
resourceid: resourceid,
|
|
2951
3137
|
runId: runId
|
|
2952
|
-
}), before = _this$
|
|
2953
|
-
|
|
3138
|
+
}), before = _this$__primitive3.before, after = _this$__primitive3.after;
|
|
3139
|
+
_context13.next = 4;
|
|
2954
3140
|
return before();
|
|
2955
3141
|
case 4:
|
|
2956
|
-
_yield$
|
|
2957
|
-
threadId = _yield$
|
|
2958
|
-
messageObjects = _yield$
|
|
2959
|
-
convertedTools = _yield$
|
|
2960
|
-
|
|
3142
|
+
_yield$before3 = _context13.sent;
|
|
3143
|
+
threadId = _yield$before3.threadId;
|
|
3144
|
+
messageObjects = _yield$before3.messageObjects;
|
|
3145
|
+
convertedTools = _yield$before3.convertedTools;
|
|
3146
|
+
_context13.next = 10;
|
|
2961
3147
|
return this.llm.__textObject({
|
|
2962
3148
|
messages: messageObjects,
|
|
2963
3149
|
structuredOutput: structuredOutput,
|
|
@@ -2968,81 +3154,81 @@ exports.Agent = (_tools = /*#__PURE__*/_classPrivateFieldLooseKey("tools"), _log
|
|
|
2968
3154
|
runId: runId
|
|
2969
3155
|
});
|
|
2970
3156
|
case 10:
|
|
2971
|
-
result =
|
|
2972
|
-
|
|
3157
|
+
result = _context13.sent;
|
|
3158
|
+
_context13.next = 13;
|
|
2973
3159
|
return after({
|
|
2974
3160
|
result: result,
|
|
2975
3161
|
threadId: threadId
|
|
2976
3162
|
});
|
|
2977
3163
|
case 13:
|
|
2978
|
-
return
|
|
3164
|
+
return _context13.abrupt("return", result);
|
|
2979
3165
|
case 14:
|
|
2980
3166
|
case "end":
|
|
2981
|
-
return
|
|
3167
|
+
return _context13.stop();
|
|
2982
3168
|
}
|
|
2983
|
-
},
|
|
3169
|
+
}, _callee13, this);
|
|
2984
3170
|
}));
|
|
2985
|
-
function textObject(
|
|
3171
|
+
function textObject(_x13) {
|
|
2986
3172
|
return _textObject.apply(this, arguments);
|
|
2987
3173
|
}
|
|
2988
3174
|
return textObject;
|
|
2989
3175
|
}();
|
|
2990
3176
|
_proto.stream = /*#__PURE__*/function () {
|
|
2991
|
-
var _stream = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2992
|
-
var messages, context, onStepFinish,
|
|
2993
|
-
return _regeneratorRuntime().wrap(function
|
|
2994
|
-
while (1) switch (
|
|
3177
|
+
var _stream = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(_ref11) {
|
|
3178
|
+
var messages, context, onStepFinish, _onFinish4, _ref11$maxSteps, maxSteps, threadIdInFn, resourceid, runId, _this$__primitive4, before, after, _yield$before4, threadId, messageObjects, convertedTools;
|
|
3179
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
3180
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
2995
3181
|
case 0:
|
|
2996
|
-
messages =
|
|
2997
|
-
_this$
|
|
3182
|
+
messages = _ref11.messages, context = _ref11.context, onStepFinish = _ref11.onStepFinish, _onFinish4 = _ref11.onFinish, _ref11$maxSteps = _ref11.maxSteps, maxSteps = _ref11$maxSteps === void 0 ? 5 : _ref11$maxSteps, threadIdInFn = _ref11.threadId, resourceid = _ref11.resourceid, runId = _ref11.runId;
|
|
3183
|
+
_this$__primitive4 = this.__primitive({
|
|
2998
3184
|
messages: messages,
|
|
2999
3185
|
context: context,
|
|
3000
3186
|
threadId: threadIdInFn,
|
|
3001
3187
|
resourceid: resourceid,
|
|
3002
3188
|
runId: runId
|
|
3003
|
-
}), before = _this$
|
|
3004
|
-
|
|
3189
|
+
}), before = _this$__primitive4.before, after = _this$__primitive4.after;
|
|
3190
|
+
_context15.next = 4;
|
|
3005
3191
|
return before();
|
|
3006
3192
|
case 4:
|
|
3007
|
-
_yield$
|
|
3008
|
-
threadId = _yield$
|
|
3009
|
-
messageObjects = _yield$
|
|
3010
|
-
convertedTools = _yield$
|
|
3011
|
-
return
|
|
3193
|
+
_yield$before4 = _context15.sent;
|
|
3194
|
+
threadId = _yield$before4.threadId;
|
|
3195
|
+
messageObjects = _yield$before4.messageObjects;
|
|
3196
|
+
convertedTools = _yield$before4.convertedTools;
|
|
3197
|
+
return _context15.abrupt("return", this.llm.__stream({
|
|
3012
3198
|
messages: messageObjects,
|
|
3013
3199
|
enabledTools: this.enabledTools,
|
|
3014
3200
|
convertedTools: convertedTools,
|
|
3015
3201
|
onStepFinish: onStepFinish,
|
|
3016
3202
|
onFinish: function () {
|
|
3017
|
-
var
|
|
3203
|
+
var _onFinish5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(result) {
|
|
3018
3204
|
var res;
|
|
3019
|
-
return _regeneratorRuntime().wrap(function
|
|
3020
|
-
while (1) switch (
|
|
3205
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
3206
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
3021
3207
|
case 0:
|
|
3022
|
-
|
|
3208
|
+
_context14.prev = 0;
|
|
3023
3209
|
res = JSON.parse(result) || {};
|
|
3024
|
-
|
|
3210
|
+
_context14.next = 4;
|
|
3025
3211
|
return after({
|
|
3026
3212
|
result: res,
|
|
3027
3213
|
threadId: threadId
|
|
3028
3214
|
});
|
|
3029
3215
|
case 4:
|
|
3030
|
-
|
|
3216
|
+
_context14.next = 9;
|
|
3031
3217
|
break;
|
|
3032
3218
|
case 6:
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
console.error('Error saving memory on finish',
|
|
3219
|
+
_context14.prev = 6;
|
|
3220
|
+
_context14.t0 = _context14["catch"](0);
|
|
3221
|
+
console.error('Error saving memory on finish', _context14.t0);
|
|
3036
3222
|
case 9:
|
|
3037
|
-
|
|
3223
|
+
_onFinish4 == null || _onFinish4(result);
|
|
3038
3224
|
case 10:
|
|
3039
3225
|
case "end":
|
|
3040
|
-
return
|
|
3226
|
+
return _context14.stop();
|
|
3041
3227
|
}
|
|
3042
|
-
},
|
|
3228
|
+
}, _callee14, null, [[0, 6]]);
|
|
3043
3229
|
}));
|
|
3044
|
-
function onFinish(
|
|
3045
|
-
return
|
|
3230
|
+
function onFinish(_x15) {
|
|
3231
|
+
return _onFinish5.apply(this, arguments);
|
|
3046
3232
|
}
|
|
3047
3233
|
return onFinish;
|
|
3048
3234
|
}(),
|
|
@@ -3051,72 +3237,72 @@ exports.Agent = (_tools = /*#__PURE__*/_classPrivateFieldLooseKey("tools"), _log
|
|
|
3051
3237
|
}));
|
|
3052
3238
|
case 9:
|
|
3053
3239
|
case "end":
|
|
3054
|
-
return
|
|
3240
|
+
return _context15.stop();
|
|
3055
3241
|
}
|
|
3056
|
-
},
|
|
3242
|
+
}, _callee15, this);
|
|
3057
3243
|
}));
|
|
3058
|
-
function stream(
|
|
3244
|
+
function stream(_x14) {
|
|
3059
3245
|
return _stream.apply(this, arguments);
|
|
3060
3246
|
}
|
|
3061
3247
|
return stream;
|
|
3062
3248
|
}();
|
|
3063
3249
|
_proto.streamObject = /*#__PURE__*/function () {
|
|
3064
|
-
var _streamObject = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3065
|
-
var messages, context, structuredOutput, onStepFinish,
|
|
3066
|
-
return _regeneratorRuntime().wrap(function
|
|
3067
|
-
while (1) switch (
|
|
3250
|
+
var _streamObject = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref12) {
|
|
3251
|
+
var messages, context, structuredOutput, onStepFinish, _onFinish6, _ref12$maxSteps, maxSteps, threadIdInFn, resourceid, runId, _this$__primitive5, before, after, _yield$before5, threadId, messageObjects, convertedTools;
|
|
3252
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
3253
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
3068
3254
|
case 0:
|
|
3069
|
-
messages =
|
|
3070
|
-
_this$
|
|
3255
|
+
messages = _ref12.messages, context = _ref12.context, structuredOutput = _ref12.structuredOutput, onStepFinish = _ref12.onStepFinish, _onFinish6 = _ref12.onFinish, _ref12$maxSteps = _ref12.maxSteps, maxSteps = _ref12$maxSteps === void 0 ? 5 : _ref12$maxSteps, threadIdInFn = _ref12.threadId, resourceid = _ref12.resourceid, runId = _ref12.runId;
|
|
3256
|
+
_this$__primitive5 = this.__primitive({
|
|
3071
3257
|
messages: messages,
|
|
3072
3258
|
context: context,
|
|
3073
3259
|
threadId: threadIdInFn,
|
|
3074
3260
|
resourceid: resourceid,
|
|
3075
3261
|
runId: runId
|
|
3076
|
-
}), before = _this$
|
|
3077
|
-
|
|
3262
|
+
}), before = _this$__primitive5.before, after = _this$__primitive5.after;
|
|
3263
|
+
_context17.next = 4;
|
|
3078
3264
|
return before();
|
|
3079
3265
|
case 4:
|
|
3080
|
-
_yield$
|
|
3081
|
-
threadId = _yield$
|
|
3082
|
-
messageObjects = _yield$
|
|
3083
|
-
convertedTools = _yield$
|
|
3084
|
-
return
|
|
3266
|
+
_yield$before5 = _context17.sent;
|
|
3267
|
+
threadId = _yield$before5.threadId;
|
|
3268
|
+
messageObjects = _yield$before5.messageObjects;
|
|
3269
|
+
convertedTools = _yield$before5.convertedTools;
|
|
3270
|
+
return _context17.abrupt("return", this.llm.__streamObject({
|
|
3085
3271
|
messages: messageObjects,
|
|
3086
3272
|
structuredOutput: structuredOutput,
|
|
3087
3273
|
enabledTools: this.enabledTools,
|
|
3088
3274
|
convertedTools: convertedTools,
|
|
3089
3275
|
onStepFinish: onStepFinish,
|
|
3090
3276
|
onFinish: function () {
|
|
3091
|
-
var
|
|
3277
|
+
var _onFinish7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(result) {
|
|
3092
3278
|
var res;
|
|
3093
|
-
return _regeneratorRuntime().wrap(function
|
|
3094
|
-
while (1) switch (
|
|
3279
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
3280
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
3095
3281
|
case 0:
|
|
3096
|
-
|
|
3282
|
+
_context16.prev = 0;
|
|
3097
3283
|
res = JSON.parse(result) || {};
|
|
3098
|
-
|
|
3284
|
+
_context16.next = 4;
|
|
3099
3285
|
return after({
|
|
3100
3286
|
result: res,
|
|
3101
3287
|
threadId: threadId
|
|
3102
3288
|
});
|
|
3103
3289
|
case 4:
|
|
3104
|
-
|
|
3290
|
+
_context16.next = 9;
|
|
3105
3291
|
break;
|
|
3106
3292
|
case 6:
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
console.error('Error saving memory on finish',
|
|
3293
|
+
_context16.prev = 6;
|
|
3294
|
+
_context16.t0 = _context16["catch"](0);
|
|
3295
|
+
console.error('Error saving memory on finish', _context16.t0);
|
|
3110
3296
|
case 9:
|
|
3111
|
-
|
|
3297
|
+
_onFinish6 == null || _onFinish6(result);
|
|
3112
3298
|
case 10:
|
|
3113
3299
|
case "end":
|
|
3114
|
-
return
|
|
3300
|
+
return _context16.stop();
|
|
3115
3301
|
}
|
|
3116
|
-
},
|
|
3302
|
+
}, _callee16, null, [[0, 6]]);
|
|
3117
3303
|
}));
|
|
3118
|
-
function onFinish(
|
|
3119
|
-
return
|
|
3304
|
+
function onFinish(_x17) {
|
|
3305
|
+
return _onFinish7.apply(this, arguments);
|
|
3120
3306
|
}
|
|
3121
3307
|
return onFinish;
|
|
3122
3308
|
}(),
|
|
@@ -3125,11 +3311,11 @@ exports.Agent = (_tools = /*#__PURE__*/_classPrivateFieldLooseKey("tools"), _log
|
|
|
3125
3311
|
}));
|
|
3126
3312
|
case 9:
|
|
3127
3313
|
case "end":
|
|
3128
|
-
return
|
|
3314
|
+
return _context17.stop();
|
|
3129
3315
|
}
|
|
3130
|
-
},
|
|
3316
|
+
}, _callee17, this);
|
|
3131
3317
|
}));
|
|
3132
|
-
function streamObject(
|
|
3318
|
+
function streamObject(_x16) {
|
|
3133
3319
|
return _streamObject.apply(this, arguments);
|
|
3134
3320
|
}
|
|
3135
3321
|
return streamObject;
|