@aigne/core 0.4.199 → 0.4.201-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -57,24 +57,20 @@ exports.FunctionAgent = FunctionAgent = FunctionAgent_1 = __decorate([
57
57
  __metadata("design:paramtypes", [Object, function_runner_1.FunctionRunner])
58
58
  ], FunctionAgent);
59
59
  function createFunctionAgentDefinition(options) {
60
- const inputs = utils_1.OrderedRecord.fromArray(options.inputs?.map((i) => ({
61
- id: (0, nanoid_1.nanoid)(),
62
- name: i.name,
63
- type: i.type,
64
- required: i.required,
65
- })));
66
- const outputs = utils_1.OrderedRecord.fromArray(options.outputs?.map((i) => ({
67
- id: (0, nanoid_1.nanoid)(),
68
- name: i.name,
69
- type: i.type,
70
- required: i.required,
71
- })));
72
60
  return {
73
61
  id: options.id || options.name || (0, nanoid_1.nanoid)(),
74
62
  name: options.name,
75
63
  type: 'function_agent',
76
- inputs,
77
- outputs,
64
+ inputs: utils_1.OrderedRecord.fromArray(Object.entries(options.inputs).map(([name, { ...dataType }]) => ({
65
+ ...dataType,
66
+ id: (0, nanoid_1.nanoid)(),
67
+ name,
68
+ }))),
69
+ outputs: utils_1.OrderedRecord.fromArray(Object.entries(options.outputs).map(([name, { ...dataType }]) => ({
70
+ ...dataType,
71
+ id: (0, nanoid_1.nanoid)(),
72
+ name,
73
+ }))),
78
74
  language: options.language,
79
75
  code: options.code,
80
76
  };
@@ -112,26 +112,26 @@ exports.LLMAgent = LLMAgent = LLMAgent_1 = __decorate([
112
112
  __metadata("design:paramtypes", [Object, llm_model_1.LLMModel])
113
113
  ], LLMAgent);
114
114
  function createLLMAgentDefinition(options) {
115
- const inputs = ordered_map_1.OrderedRecord.fromArray(options.inputs?.map((i) => ({
116
- id: (0, nanoid_1.nanoid)(),
117
- name: i.name,
118
- type: i.type,
119
- required: i.required,
120
- })));
121
- const outputs = ordered_map_1.OrderedRecord.fromArray(options.outputs?.map((i) => ({ ...i, id: (0, nanoid_1.nanoid)() })));
122
- const messages = ordered_map_1.OrderedRecord.fromArray(options.messages?.map((i) => ({
123
- id: (0, nanoid_1.nanoid)(),
124
- role: i.role,
125
- content: i.content,
126
- })));
127
115
  return {
128
116
  id: options.id || options.name || (0, nanoid_1.nanoid)(),
129
117
  name: options.name,
130
118
  type: 'llm_agent',
131
- inputs,
132
- outputs,
133
- messages,
119
+ inputs: ordered_map_1.OrderedRecord.fromArray(Object.entries(options.inputs).map(([name, { ...dataType }]) => ({
120
+ ...dataType,
121
+ id: (0, nanoid_1.nanoid)(),
122
+ name,
123
+ }))),
124
+ outputs: ordered_map_1.OrderedRecord.fromArray(Object.entries(options.outputs).map(([name, { ...dataType }]) => ({
125
+ ...dataType,
126
+ id: (0, nanoid_1.nanoid)(),
127
+ name,
128
+ }))),
134
129
  modelOptions: options.modelOptions,
130
+ messages: ordered_map_1.OrderedRecord.fromArray(options.messages?.map((i) => ({
131
+ id: (0, nanoid_1.nanoid)(),
132
+ role: i.role,
133
+ content: i.content,
134
+ }))),
135
135
  };
136
136
  }
137
137
  function outputsToJsonSchema(outputs) {
@@ -114,11 +114,10 @@ exports.LLMDecisionAgent = LLMDecisionAgent = LLMDecisionAgent_1 = __decorate([
114
114
  __metadata("design:paramtypes", [Object, llm_model_1.LLMModel, Object])
115
115
  ], LLMDecisionAgent);
116
116
  function createLLMDecisionAgentDefinition(options) {
117
- const inputs = utils_1.OrderedRecord.fromArray(options.inputs?.map((i) => ({
117
+ const inputs = utils_1.OrderedRecord.fromArray(Object.entries(options.inputs).map(([name, { ...dataType }]) => ({
118
+ ...dataType,
118
119
  id: (0, nanoid_1.nanoid)(),
119
- name: i.name,
120
- type: i.type,
121
- required: i.required,
120
+ name: name,
122
121
  })));
123
122
  const messages = utils_1.OrderedRecord.fromArray([
124
123
  {
@@ -57,17 +57,15 @@ exports.LocalFunctionAgent = LocalFunctionAgent = LocalFunctionAgent_1 = __decor
57
57
  __metadata("design:paramtypes", [Object, Object])
58
58
  ], LocalFunctionAgent);
59
59
  function createLocalFunctionAgentDefinition(options) {
60
- const inputs = utils_1.OrderedRecord.fromArray(options.inputs?.map((i) => ({
60
+ const inputs = utils_1.OrderedRecord.fromArray(Object.entries(options.inputs).map(([name, i]) => ({
61
+ ...i,
61
62
  id: (0, nanoid_1.nanoid)(),
62
- name: i.name,
63
- type: i.type,
64
- required: i.required,
63
+ name,
65
64
  })));
66
- const outputs = utils_1.OrderedRecord.fromArray(options.outputs?.map((i) => ({
65
+ const outputs = utils_1.OrderedRecord.fromArray(Object.entries(options.outputs).map(([name, o]) => ({
66
+ ...o,
67
67
  id: (0, nanoid_1.nanoid)(),
68
- name: i.name,
69
- type: i.type,
70
- required: i.required,
68
+ name,
71
69
  })));
72
70
  return {
73
71
  id: options.id || options.name || (0, nanoid_1.nanoid)(),
@@ -145,11 +145,10 @@ exports.PipelineAgent = PipelineAgent = PipelineAgent_1 = __decorate([
145
145
  __metadata("design:paramtypes", [Object, Object])
146
146
  ], PipelineAgent);
147
147
  function createPipelineAgentDefinition(options) {
148
- const inputs = ordered_map_1.OrderedRecord.fromArray(options.inputs?.map((i) => ({
148
+ const inputs = ordered_map_1.OrderedRecord.fromArray(Object.entries(options.inputs).map(([name, { ...dataType }]) => ({
149
+ ...dataType,
149
150
  id: (0, nanoid_1.nanoid)(),
150
- name: i.name,
151
- type: i.type,
152
- required: i.required,
151
+ name,
153
152
  })));
154
153
  const processes = ordered_map_1.OrderedRecord.fromArray([]);
155
154
  for (const p of options.processes || []) {
@@ -181,19 +180,17 @@ function createPipelineAgentDefinition(options) {
181
180
  }).filter(is_non_nullable_1.isNonNullable)),
182
181
  });
183
182
  }
184
- const outputs = ordered_map_1.OrderedRecord.fromArray(options.outputs.map((output) => {
185
- const from = ordered_map_1.OrderedRecord.find(inputs, (i) => i.name === output.fromVariable) ||
186
- ordered_map_1.OrderedRecord.find(processes, (p) => p.name === output.fromVariable);
183
+ const outputs = ordered_map_1.OrderedRecord.fromArray(Object.entries(options.outputs).map(([name, { fromVariable, ...output }]) => {
184
+ const from = ordered_map_1.OrderedRecord.find(inputs, (i) => i.name === fromVariable) ||
185
+ ordered_map_1.OrderedRecord.find(processes, (p) => p.name === fromVariable);
187
186
  if (!from)
188
- throw new Error(`Output ${output.name} not found in inputs or processes`);
187
+ throw new Error(`Output ${name} not found in inputs or processes`);
189
188
  return {
189
+ ...output,
190
190
  id: (0, nanoid_1.nanoid)(),
191
- name: output.name,
192
- type: output.type,
193
- required: output.required,
191
+ name,
194
192
  from: 'variable',
195
193
  fromVariableId: from.id,
196
- fromVariablePropPath: output.fromVariablePropPath,
197
194
  };
198
195
  }));
199
196
  return {