@aigne/core 0.4.201-5 → 0.4.201-6

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.
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -11,14 +11,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
13
  var LLMDecisionAgent_1;
14
- import { get, isNil } from 'lodash';
15
14
  import { nanoid } from 'nanoid';
16
15
  import { inject, injectable } from 'tsyringe';
17
16
  import { TYPES } from './constants';
18
- import { SchemaToDataType } from './data-type-schema';
19
17
  import { LLMModel } from './llm-model';
20
- import { Runnable, } from './runnable';
21
- import { OrderedRecord, isNonNullable, renderMessage } from './utils';
18
+ import { Runnable } from './runnable';
19
+ import { OrderedRecord, renderMessage } from './utils';
22
20
  let LLMDecisionAgent = LLMDecisionAgent_1 = class LLMDecisionAgent extends Runnable {
23
21
  definition;
24
22
  model;
@@ -79,27 +77,8 @@ let LLMDecisionAgent = LLMDecisionAgent_1 = class LLMDecisionAgent extends Runna
79
77
  const caseToCall = cases.find((i) => i.name === functionNameToCall);
80
78
  if (!caseToCall)
81
79
  throw new Error('Case not found');
82
- // NOTE: 将 input 转换为 variables,其中 key 为 inputId,value 为 input 的值
83
- const variables = Object.fromEntries(OrderedRecord.map(this.definition.inputs, (i) => {
84
- const value = input[i.name || i.id];
85
- if (isNil(value))
86
- return null;
87
- return [i.id, value];
88
- }).filter(isNonNullable));
89
- const inputForCase = Object.fromEntries(Object.entries(caseToCall.input ?? {})
90
- .map(([inputId, { from, fromVariableId, fromVariablePropPath }]) => {
91
- const targetInput = OrderedRecord.find(caseToCall.runnable.definition.inputs, (i) => i.id === inputId);
92
- if (!targetInput?.name)
93
- return null;
94
- if (from !== 'variable' || !fromVariableId)
95
- return null;
96
- const v = variables[fromVariableId];
97
- const value = fromVariablePropPath?.length ? get(v, fromVariablePropPath) : v;
98
- return [targetInput.name, value];
99
- })
100
- .filter(isNonNullable));
101
80
  // TODO: check result structure and omit undefined values
102
- return (await caseToCall.runnable.run(inputForCase, options));
81
+ return (await caseToCall.runnable.run(input, options));
103
82
  }
104
83
  };
105
84
  LLMDecisionAgent = LLMDecisionAgent_1 = __decorate([
@@ -111,7 +90,6 @@ LLMDecisionAgent = LLMDecisionAgent_1 = __decorate([
111
90
  ], LLMDecisionAgent);
112
91
  export { LLMDecisionAgent };
113
92
  export function createLLMDecisionAgentDefinition(options) {
114
- const inputs = SchemaToDataType(options.inputs);
115
93
  const messages = OrderedRecord.fromArray([
116
94
  {
117
95
  id: nanoid(),
@@ -124,34 +102,13 @@ export function createLLMDecisionAgentDefinition(options) {
124
102
  name: c.name || c.runnable.name,
125
103
  description: c.description,
126
104
  runnable: { id: c.runnable.id },
127
- // TODO: pass input from decision to case runnable
128
- input: Object.fromEntries(OrderedRecord.map(c.runnable.definition.inputs, (inputOfCase) => {
129
- const i = c.input?.[inputOfCase.name || inputOfCase.id];
130
- if (!i) {
131
- if (inputOfCase.required) {
132
- throw new Error(`Input ${inputOfCase.name || inputOfCase.id} for case ${c.runnable.name || c.runnable.id} is required`);
133
- }
134
- // ignore optional input
135
- return null;
136
- }
137
- const inputFromDecision = OrderedRecord.find(inputs, (input) => input.name === i.fromVariable);
138
- if (!inputFromDecision)
139
- throw new Error(`Input ${i.fromVariable} not found`);
140
- return [
141
- inputOfCase.id,
142
- {
143
- from: 'variable',
144
- fromVariableId: inputFromDecision.id,
145
- fromVariablePropPath: i.fromVariablePropPath,
146
- },
147
- ];
148
- }).filter(isNonNullable)),
149
105
  })));
150
106
  return {
151
107
  id: options.id || options.name || nanoid(),
152
108
  name: options.name,
153
109
  type: 'llm_decision_agent',
154
- inputs,
110
+ // TODO: decision agent inputs should be the intersection of all case inputs
111
+ inputs: OrderedRecord.fromArray([]),
155
112
  // TODO: decision agent outputs should be the union of all case outputs
156
113
  outputs: OrderedRecord.fromArray([]),
157
114
  messages,