@aigne/core 0.4.201-2 → 0.4.201-4
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/data-type-schema.js +51 -0
- package/lib/cjs/function-agent.js +3 -10
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/llm-agent.js +3 -10
- package/lib/cjs/llm-decision-agent.js +2 -5
- package/lib/cjs/local-function-agent.js +3 -10
- package/lib/cjs/pipeline-agent.js +5 -13
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/data-type-schema.js +48 -0
- package/lib/esm/function-agent.js +4 -11
- package/lib/esm/index.js +1 -0
- package/lib/esm/llm-agent.js +3 -10
- package/lib/esm/llm-decision-agent.js +2 -5
- package/lib/esm/local-function-agent.js +5 -12
- package/lib/esm/pipeline-agent.js +5 -13
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/types/data-type-schema.d.ts +38 -0
- package/lib/types/data-type.d.ts +0 -7
- package/lib/types/function-agent.d.ts +8 -9
- package/lib/types/index.d.ts +1 -0
- package/lib/types/llm-agent.d.ts +8 -9
- package/lib/types/llm-decision-agent.d.ts +7 -8
- package/lib/types/local-function-agent.d.ts +11 -12
- package/lib/types/pipeline-agent.d.ts +8 -9
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { DataType } from './data-type';
|
|
2
|
+
import { OrderedRecord } from './utils';
|
|
3
|
+
export declare function SchemaToDataType(dataType: {
|
|
4
|
+
[name: string]: DataTypeSchema;
|
|
5
|
+
}): OrderedRecord<DataType>;
|
|
6
|
+
export type DataTypeSchema = DataTypeSchemaString | DataTypeSchemaNumber | DataTypeSchemaBoolean | DataTypeSchemaObject | DataTypeSchemaArray;
|
|
7
|
+
export interface DataTypeSchemaBase {
|
|
8
|
+
required?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface DataTypeSchemaString extends DataTypeSchemaBase {
|
|
11
|
+
type: 'string';
|
|
12
|
+
}
|
|
13
|
+
export interface DataTypeSchemaNumber extends DataTypeSchemaBase {
|
|
14
|
+
type: 'number';
|
|
15
|
+
}
|
|
16
|
+
export interface DataTypeSchemaBoolean extends DataTypeSchemaBase {
|
|
17
|
+
type: 'boolean';
|
|
18
|
+
}
|
|
19
|
+
export interface DataTypeSchemaObject extends DataTypeSchemaBase {
|
|
20
|
+
type: 'object';
|
|
21
|
+
properties: {
|
|
22
|
+
[key: string]: DataTypeSchema;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface DataTypeSchemaArray extends DataTypeSchemaBase {
|
|
26
|
+
type: 'array';
|
|
27
|
+
items: DataTypeSchema;
|
|
28
|
+
}
|
|
29
|
+
type SchemaTypeInner<T extends DataTypeSchema> = T extends DataTypeSchemaString ? string : T extends DataTypeSchemaNumber ? number : T extends DataTypeSchemaBoolean ? boolean : T extends DataTypeSchemaObject ? {
|
|
30
|
+
[K in keyof T['properties']]: SchemaType<T['properties'][K]>;
|
|
31
|
+
} : T extends DataTypeSchemaArray ? SchemaType<T['items']>[] : never;
|
|
32
|
+
export type SchemaType<T extends DataTypeSchema> = T['required'] extends true ? SchemaTypeInner<T> : SchemaTypeInner<T> | undefined;
|
|
33
|
+
export type SchemaMapType<T extends Record<string, DataTypeSchema>> = SchemaType<{
|
|
34
|
+
type: 'object';
|
|
35
|
+
required: true;
|
|
36
|
+
properties: T;
|
|
37
|
+
}>;
|
|
38
|
+
export {};
|
package/lib/types/data-type.d.ts
CHANGED
|
@@ -30,10 +30,3 @@ export interface DataTypeArray extends DataTypeBase {
|
|
|
30
30
|
defaultValue?: object[];
|
|
31
31
|
items?: OmitPropsFromUnion<DataType, 'id'>;
|
|
32
32
|
}
|
|
33
|
-
type SchemaTypeInner<T extends Record<string, OmitPropsFromUnion<DataType, 'id' | 'name'>>> = {
|
|
34
|
-
[K in keyof T]: T[K]['type'] extends 'string' ? string : T[K]['type'] extends 'number' ? number : T[K]['type'] extends 'boolean' ? boolean : T[K]['type'] extends 'object' ? object : T[K]['type'] extends 'array' ? object[] : never;
|
|
35
|
-
};
|
|
36
|
-
export type SchemaType<T extends Record<string, OmitPropsFromUnion<DataType, 'id' | 'name'>>> = {
|
|
37
|
-
[K in keyof T]: T[K]['required'] extends true ? SchemaTypeInner<T>[K] : SchemaTypeInner<T>[K] | undefined;
|
|
38
|
-
};
|
|
39
|
-
export {};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DataTypeSchema, SchemaMapType } from './data-type-schema';
|
|
2
2
|
import { FunctionRunner } from './function-runner';
|
|
3
3
|
import { RunOptions, Runnable, RunnableDefinition, RunnableResponseStream } from './runnable';
|
|
4
|
-
import { OmitPropsFromUnion } from './utils/omit';
|
|
5
4
|
export declare class FunctionAgent<I extends {} = {}, O extends {} = {}> extends Runnable<I, O> {
|
|
6
5
|
definition: FunctionAgentDefinition;
|
|
7
6
|
runner?: FunctionRunner | undefined;
|
|
8
|
-
static create<I extends {
|
|
9
|
-
[name: string]:
|
|
10
|
-
}
|
|
11
|
-
[name: string]:
|
|
12
|
-
}
|
|
7
|
+
static create<I extends {
|
|
8
|
+
[name: string]: DataTypeSchema;
|
|
9
|
+
}, O extends {
|
|
10
|
+
[name: string]: DataTypeSchema;
|
|
11
|
+
}>(options: Parameters<typeof createFunctionAgentDefinition<I, O>>[0]): FunctionAgent<SchemaMapType<I>, SchemaMapType<O>>;
|
|
13
12
|
constructor(definition: FunctionAgentDefinition, runner?: FunctionRunner | undefined);
|
|
14
13
|
run(input: I, options: RunOptions & {
|
|
15
14
|
stream: true;
|
|
@@ -19,9 +18,9 @@ export declare class FunctionAgent<I extends {} = {}, O extends {} = {}> extends
|
|
|
19
18
|
}): Promise<O>;
|
|
20
19
|
}
|
|
21
20
|
export declare function createFunctionAgentDefinition<I extends {
|
|
22
|
-
[name: string]:
|
|
21
|
+
[name: string]: DataTypeSchema;
|
|
23
22
|
}, O extends {
|
|
24
|
-
[name: string]:
|
|
23
|
+
[name: string]: DataTypeSchema;
|
|
25
24
|
}>(options: {
|
|
26
25
|
id?: string;
|
|
27
26
|
name?: string;
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/llm-agent.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DataTypeSchema, SchemaMapType } from './data-type-schema';
|
|
2
2
|
import { LLMModel, LLMModelInputs, Role } from './llm-model';
|
|
3
3
|
import { RunOptions, Runnable, RunnableDefinition, RunnableResponseStream } from './runnable';
|
|
4
|
-
import { OmitPropsFromUnion } from './utils/omit';
|
|
5
4
|
import { OrderedRecord } from './utils/ordered-map';
|
|
6
5
|
export declare class LLMAgent<I extends {} = {}, O extends {} = {}> extends Runnable<I, O> {
|
|
7
6
|
definition: LLMAgentDefinition;
|
|
8
7
|
model?: LLMModel | undefined;
|
|
9
|
-
static create<I extends {
|
|
10
|
-
[name: string]:
|
|
11
|
-
}
|
|
12
|
-
[name: string]:
|
|
13
|
-
}
|
|
8
|
+
static create<I extends {
|
|
9
|
+
[name: string]: DataTypeSchema;
|
|
10
|
+
}, O extends {
|
|
11
|
+
[name: string]: DataTypeSchema;
|
|
12
|
+
}>(options: Parameters<typeof createLLMAgentDefinition<I, O>>[0]): LLMAgent<SchemaMapType<I>, SchemaMapType<O>>;
|
|
14
13
|
constructor(definition: LLMAgentDefinition, model?: LLMModel | undefined);
|
|
15
14
|
run(input: I, options: RunOptions & {
|
|
16
15
|
stream: true;
|
|
@@ -20,9 +19,9 @@ export declare class LLMAgent<I extends {} = {}, O extends {} = {}> extends Runn
|
|
|
20
19
|
}): Promise<O>;
|
|
21
20
|
}
|
|
22
21
|
export declare function createLLMAgentDefinition<I extends {
|
|
23
|
-
[name: string]:
|
|
22
|
+
[name: string]: DataTypeSchema;
|
|
24
23
|
}, O extends {
|
|
25
|
-
[name: string]:
|
|
24
|
+
[name: string]: DataTypeSchema;
|
|
26
25
|
}>(options: {
|
|
27
26
|
id?: string;
|
|
28
27
|
name?: string;
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import type { Context } from './context';
|
|
2
|
-
import {
|
|
2
|
+
import { DataTypeSchema, SchemaMapType } from './data-type-schema';
|
|
3
3
|
import { LLMModel, LLMModelInputMessage, LLMModelInputs, LLMModelOptions } from './llm-model';
|
|
4
4
|
import { RunOptions, Runnable, RunnableDefinition, RunnableResponseStream } from './runnable';
|
|
5
5
|
import { OrderedRecord } from './utils';
|
|
6
|
-
import { OmitPropsFromUnion } from './utils/omit';
|
|
7
6
|
export declare class LLMDecisionAgent<I extends {
|
|
8
7
|
[key: string]: any;
|
|
9
8
|
} = {}, O extends {} = {}> extends Runnable<I, O> {
|
|
10
9
|
definition: LLMDecisionAgentDefinition;
|
|
11
10
|
model?: LLMModel | undefined;
|
|
12
11
|
context?: Context | undefined;
|
|
13
|
-
static create<I extends {
|
|
14
|
-
[name: string]:
|
|
15
|
-
}
|
|
16
|
-
[name: string]:
|
|
17
|
-
}
|
|
12
|
+
static create<I extends {
|
|
13
|
+
[name: string]: DataTypeSchema;
|
|
14
|
+
}, O extends {
|
|
15
|
+
[name: string]: DataTypeSchema;
|
|
16
|
+
}>(options: Parameters<typeof createLLMDecisionAgentDefinition<I>>[0]): LLMDecisionAgent<SchemaMapType<I>, SchemaMapType<O>>;
|
|
18
17
|
constructor(definition: LLMDecisionAgentDefinition, model?: LLMModel | undefined, context?: Context | undefined);
|
|
19
18
|
run(input: I, options: RunOptions & {
|
|
20
19
|
stream: true;
|
|
@@ -35,7 +34,7 @@ export interface DecisionAgentCaseParameter<I extends {} = {}, O extends {} = {}
|
|
|
35
34
|
};
|
|
36
35
|
}
|
|
37
36
|
export declare function createLLMDecisionAgentDefinition<I extends {
|
|
38
|
-
[name: string]:
|
|
37
|
+
[name: string]: DataTypeSchema;
|
|
39
38
|
}>(options: {
|
|
40
39
|
id?: string;
|
|
41
40
|
name?: string;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import type { Context } from './context';
|
|
2
|
-
import {
|
|
2
|
+
import { DataTypeSchema, SchemaMapType } from './data-type-schema';
|
|
3
3
|
import { RunOptions, Runnable, RunnableDefinition, RunnableResponse, RunnableResponseStream } from './runnable';
|
|
4
|
-
import { OmitPropsFromUnion } from './utils/omit';
|
|
5
4
|
export declare class LocalFunctionAgent<I extends {} = {}, O extends {} = {}, State = {}> extends Runnable<I, O> {
|
|
6
5
|
definition: LocalFunctionAgentDefinition<I, O, State>;
|
|
7
6
|
context?: Context<State> | undefined;
|
|
8
|
-
static create<I extends {
|
|
9
|
-
[name: string]:
|
|
10
|
-
}
|
|
11
|
-
[name: string]:
|
|
12
|
-
} = {}>(options: Parameters<typeof createLocalFunctionAgentDefinition<
|
|
7
|
+
static create<I extends {
|
|
8
|
+
[name: string]: DataTypeSchema;
|
|
9
|
+
}, O extends {
|
|
10
|
+
[name: string]: DataTypeSchema;
|
|
11
|
+
}, State = {}>(options: Parameters<typeof createLocalFunctionAgentDefinition<I, O, State>>[0]): LocalFunctionAgent<SchemaMapType<I>, SchemaMapType<O>, State>;
|
|
13
12
|
constructor(definition: LocalFunctionAgentDefinition<I, O, State>, context?: Context<State> | undefined);
|
|
14
13
|
run(input: I, options: RunOptions & {
|
|
15
14
|
stream: true;
|
|
@@ -19,18 +18,18 @@ export declare class LocalFunctionAgent<I extends {} = {}, O extends {} = {}, St
|
|
|
19
18
|
}): Promise<O>;
|
|
20
19
|
}
|
|
21
20
|
export declare function createLocalFunctionAgentDefinition<I extends {
|
|
22
|
-
[name: string]:
|
|
21
|
+
[name: string]: DataTypeSchema;
|
|
23
22
|
}, O extends {
|
|
24
|
-
[name: string]:
|
|
23
|
+
[name: string]: DataTypeSchema;
|
|
25
24
|
}, State = {}>(options: {
|
|
26
25
|
id?: string;
|
|
27
26
|
name?: string;
|
|
28
27
|
inputs: I;
|
|
29
28
|
outputs: O;
|
|
30
|
-
function?: (input:
|
|
29
|
+
function?: (input: SchemaMapType<I>, options: {
|
|
31
30
|
context: Context<State>;
|
|
32
|
-
}) => Promise<RunnableResponse<
|
|
33
|
-
}): LocalFunctionAgentDefinition<
|
|
31
|
+
}) => Promise<RunnableResponse<SchemaMapType<O>>>;
|
|
32
|
+
}): LocalFunctionAgentDefinition<SchemaMapType<I>, SchemaMapType<O>, State>;
|
|
34
33
|
export interface LocalFunctionAgentDefinition<I extends {} = {}, O extends {} = {}, State = {}> extends RunnableDefinition {
|
|
35
34
|
type: 'local_function_agent';
|
|
36
35
|
function?: (input: I, options: {
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import type { Context } from './context';
|
|
2
|
-
import {
|
|
2
|
+
import { DataTypeSchema, SchemaMapType } from './data-type-schema';
|
|
3
3
|
import { RunOptions, Runnable, RunnableDefinition, RunnableOutput, RunnableResponseStream } from './runnable';
|
|
4
|
-
import { OmitPropsFromUnion } from './utils/omit';
|
|
5
4
|
import { OrderedRecord } from './utils/ordered-map';
|
|
6
5
|
export declare class PipelineAgent<I extends {
|
|
7
6
|
[key: string]: any;
|
|
8
7
|
} = {}, O extends {} = {}> extends Runnable<I, O> {
|
|
9
8
|
definition: PipelineAgentDefinition;
|
|
10
9
|
context?: Context | undefined;
|
|
11
|
-
static create<I extends {
|
|
12
|
-
[name: string]:
|
|
13
|
-
}
|
|
14
|
-
[name: string]:
|
|
10
|
+
static create<I extends {
|
|
11
|
+
[name: string]: DataTypeSchema;
|
|
12
|
+
}, O extends {
|
|
13
|
+
[name: string]: DataTypeSchema & {
|
|
15
14
|
fromVariable: string;
|
|
16
15
|
fromVariablePropPath?: string[];
|
|
17
16
|
};
|
|
18
|
-
}
|
|
17
|
+
}>(options: Parameters<typeof createPipelineAgentDefinition<I, O>>[0]): PipelineAgent<SchemaMapType<I>, SchemaMapType<O>>;
|
|
19
18
|
constructor(definition: PipelineAgentDefinition, context?: Context | undefined);
|
|
20
19
|
run(input: I, options: RunOptions & {
|
|
21
20
|
stream: true;
|
|
@@ -35,9 +34,9 @@ export interface PipelineAgentProcessParameter<I extends {} = {}, O extends {} =
|
|
|
35
34
|
};
|
|
36
35
|
}
|
|
37
36
|
export declare function createPipelineAgentDefinition<I extends {
|
|
38
|
-
[name: string]:
|
|
37
|
+
[name: string]: DataTypeSchema;
|
|
39
38
|
}, O extends {
|
|
40
|
-
[name: string]:
|
|
39
|
+
[name: string]: DataTypeSchema & {
|
|
41
40
|
fromVariable: string;
|
|
42
41
|
fromVariablePropPath?: string[];
|
|
43
42
|
};
|