@aigne/core 0.4.207 → 0.4.208-beta.1
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/lib/cjs/constants.js +0 -1
- package/lib/cjs/data-type-schema.js +46 -0
- package/lib/cjs/data-type.js +2 -0
- package/lib/cjs/llm-decision-agent.js +1 -1
- package/lib/cjs/memory.js +32 -0
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/constants.js +0 -1
- package/lib/esm/data-type-schema.js +43 -0
- package/lib/esm/data-type.js +1 -0
- package/lib/esm/llm-decision-agent.js +1 -1
- package/lib/esm/memory.js +27 -0
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/types/constants.d.ts +0 -1
- package/lib/types/context.d.ts +6 -1
- package/lib/types/data-type-schema.d.ts +46 -0
- package/lib/types/data-type.d.ts +32 -0
- package/lib/types/memory.d.ts +184 -0
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/lib/cjs/constants.js
CHANGED
|
@@ -5,7 +5,6 @@ exports.TYPES = {
|
|
|
5
5
|
context: Symbol.for('AIGNE_CONTEXT'),
|
|
6
6
|
definition: Symbol.for('AIGNE_DEFINITION'),
|
|
7
7
|
llmModel: Symbol.for('AIGNE_LLM_MODEL'),
|
|
8
|
-
llmModelConfiguration: Symbol.for('AIGNE_LLM_MODEL_CONFIGURATION'),
|
|
9
8
|
functionRunner: Symbol.for('AIGNE_FUNCTION_RUNNER'),
|
|
10
9
|
};
|
|
11
10
|
exports.StreamTextOutputName = '$text';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.schemaToDataType = schemaToDataType;
|
|
4
|
+
const nanoid_1 = require("nanoid");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
function schemaToDataType(dataType) {
|
|
7
|
+
return utils_1.OrderedRecord.fromArray(Object.entries(dataType).map(([name, schema]) => {
|
|
8
|
+
const base = {
|
|
9
|
+
...schema,
|
|
10
|
+
id: (0, nanoid_1.nanoid)(),
|
|
11
|
+
name,
|
|
12
|
+
};
|
|
13
|
+
switch (schema.type) {
|
|
14
|
+
case 'string':
|
|
15
|
+
return {
|
|
16
|
+
...base,
|
|
17
|
+
type: 'string',
|
|
18
|
+
};
|
|
19
|
+
case 'number':
|
|
20
|
+
return {
|
|
21
|
+
...base,
|
|
22
|
+
type: 'number',
|
|
23
|
+
};
|
|
24
|
+
case 'boolean':
|
|
25
|
+
return {
|
|
26
|
+
...base,
|
|
27
|
+
type: 'boolean',
|
|
28
|
+
};
|
|
29
|
+
case 'object':
|
|
30
|
+
return {
|
|
31
|
+
...base,
|
|
32
|
+
type: 'object',
|
|
33
|
+
properties: schemaToDataType(schema.properties),
|
|
34
|
+
};
|
|
35
|
+
case 'array':
|
|
36
|
+
return {
|
|
37
|
+
...base,
|
|
38
|
+
type: 'array',
|
|
39
|
+
items: utils_1.OrderedRecord.find(schemaToDataType({ items: schema.items }), (i) => i.name === 'items'),
|
|
40
|
+
};
|
|
41
|
+
default: {
|
|
42
|
+
throw new Error(`Unknown data type: ${schema.type}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
@@ -66,7 +66,7 @@ let LLMDecisionAgent = class LLMDecisionAgent extends agent_1.Agent {
|
|
|
66
66
|
};
|
|
67
67
|
const { toolCalls } = await model.run(llmInputs);
|
|
68
68
|
// TODO: support run multiple calls
|
|
69
|
-
const functionNameToCall = toolCalls?.[0]
|
|
69
|
+
const functionNameToCall = toolCalls?.[0]?.function?.name;
|
|
70
70
|
if (!functionNameToCall)
|
|
71
71
|
throw new Error('No any runnable called');
|
|
72
72
|
const caseToCall = cases.find((i) => i.name === functionNameToCall);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemoryRunner = exports.Memory = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const runnable_1 = require("./runnable");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
class Memory extends runnable_1.Runnable {
|
|
8
|
+
constructor() {
|
|
9
|
+
super({
|
|
10
|
+
id: 'memory',
|
|
11
|
+
type: 'memory',
|
|
12
|
+
name: 'Memory',
|
|
13
|
+
inputs: utils_1.OrderedRecord.fromArray([]),
|
|
14
|
+
outputs: utils_1.OrderedRecord.fromArray([]),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.Memory = Memory;
|
|
19
|
+
class MemoryRunner extends runnable_1.Runnable {
|
|
20
|
+
constructor(name) {
|
|
21
|
+
const id = `${(0, lodash_1.camelCase)(name)}_runner`;
|
|
22
|
+
super({
|
|
23
|
+
id,
|
|
24
|
+
type: id,
|
|
25
|
+
name: `${(0, lodash_1.startCase)(name)} Runner`,
|
|
26
|
+
description: `${(0, lodash_1.startCase)(name)} Runner`,
|
|
27
|
+
inputs: utils_1.OrderedRecord.fromArray([]),
|
|
28
|
+
outputs: utils_1.OrderedRecord.fromArray([]),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.MemoryRunner = MemoryRunner;
|