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