@aigne/core 0.4.194 → 0.4.196
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 +11 -0
- package/lib/cjs/function-agent.js +81 -0
- package/lib/cjs/function-runner.js +29 -0
- package/lib/cjs/index.js +13 -1
- package/lib/cjs/llm-agent.js +166 -0
- package/lib/cjs/llm-decision-agent.js +169 -0
- package/lib/cjs/llm-model.js +27 -0
- package/lib/cjs/local-function-agent.js +80 -0
- package/lib/cjs/memory.js +32 -0
- package/lib/cjs/pipeline-agent.js +199 -0
- package/lib/cjs/runnable.js +29 -0
- package/lib/cjs/tsconfig.tsbuildinfo +1 -0
- package/lib/cjs/{types → utils}/index.js +4 -2
- package/lib/cjs/utils/is-non-nullable.js +20 -0
- package/lib/cjs/utils/mustache-utils.js +14 -0
- package/lib/cjs/utils/omit.js +2 -0
- package/lib/cjs/utils/ordered-map.js +71 -0
- package/lib/cjs/utils/stream-utils.js +25 -0
- package/lib/esm/constants.js +8 -0
- package/lib/esm/function-agent.js +77 -0
- package/lib/esm/function-runner.js +25 -0
- package/lib/esm/index.js +13 -1
- package/lib/esm/llm-agent.js +162 -0
- package/lib/esm/llm-decision-agent.js +165 -0
- package/lib/esm/llm-model.js +23 -0
- package/lib/esm/local-function-agent.js +76 -0
- package/lib/esm/memory.js +27 -0
- package/lib/esm/pipeline-agent.js +192 -0
- package/lib/esm/runnable.js +23 -0
- package/lib/esm/tsconfig.tsbuildinfo +1 -0
- package/lib/esm/utils/index.js +4 -0
- package/lib/esm/utils/is-non-nullable.js +13 -0
- package/lib/esm/utils/mustache-utils.js +8 -0
- package/lib/esm/utils/omit.js +1 -0
- package/lib/esm/utils/ordered-map.js +68 -0
- package/lib/esm/utils/stream-utils.js +21 -0
- package/lib/types/constants.d.ts +8 -0
- package/lib/types/context.d.ts +5 -0
- package/lib/types/data-type.d.ts +32 -0
- package/lib/types/function-agent.d.ts +36 -0
- package/lib/types/function-runner.d.ts +11 -0
- package/lib/types/index.d.ts +13 -1
- package/lib/types/llm-agent.d.ts +37 -0
- package/lib/types/llm-decision-agent.d.ts +66 -0
- package/lib/types/llm-model.d.ts +79 -0
- package/lib/types/local-function-agent.d.ts +38 -0
- package/lib/types/memory.d.ts +186 -0
- package/lib/types/pipeline-agent.d.ts +69 -0
- package/lib/types/runnable.d.ts +49 -0
- package/lib/types/tsconfig.tsbuildinfo +1 -0
- package/lib/types/utils/index.d.ts +4 -0
- package/lib/types/utils/is-non-nullable.d.ts +2 -0
- package/lib/types/utils/mustache-utils.d.ts +3 -0
- package/lib/types/utils/omit.d.ts +1 -0
- package/lib/types/utils/ordered-map.d.ts +28 -0
- package/lib/types/utils/stream-utils.d.ts +7 -0
- package/package.json +6 -4
- package/tsconfig.json +3 -7
- package/lib/esm/types/index.js +0 -2
- package/lib/types/types/agent.d.ts +0 -5
- package/lib/types/types/index.d.ts +0 -2
- package/lib/types/types/runnable.d.ts +0 -20
- /package/lib/cjs/{types/agent.js → context.js} +0 -0
- /package/lib/cjs/{types/runnable.js → data-type.js} +0 -0
- /package/lib/esm/{types/agent.js → context.js} +0 -0
- /package/lib/esm/{types/runnable.js → data-type.js} +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Context } from './context';
|
|
2
|
+
import { DataType } from './data-type';
|
|
3
|
+
import { RunOptions, Runnable, RunnableDefinition, RunnableOutput, RunnableResponseStream } from './runnable';
|
|
4
|
+
import { OrderedRecord } from './utils/ordered-map';
|
|
5
|
+
export declare class PipelineAgent<I extends {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
} = {}, O extends {} = {}> extends Runnable<I, O> {
|
|
8
|
+
definition: PipelineAgentDefinition;
|
|
9
|
+
context?: Context | undefined;
|
|
10
|
+
static create<I extends {} = {}, O extends {} = {}>(options: Parameters<typeof createPipelineAgentDefinition>[0]): PipelineAgent<I, O>;
|
|
11
|
+
constructor(definition: PipelineAgentDefinition, context?: Context | undefined);
|
|
12
|
+
run(input: I, options: RunOptions & {
|
|
13
|
+
stream: true;
|
|
14
|
+
}): Promise<RunnableResponseStream<O>>;
|
|
15
|
+
run(input: I, options?: RunOptions & {
|
|
16
|
+
stream?: false;
|
|
17
|
+
}): Promise<O>;
|
|
18
|
+
}
|
|
19
|
+
export interface PipelineAgentProcessParameter<I extends {} = {}, O extends {} = {}, R = Runnable<I, O>> {
|
|
20
|
+
name?: string;
|
|
21
|
+
runnable: R;
|
|
22
|
+
input?: {
|
|
23
|
+
[key: string]: {
|
|
24
|
+
fromVariable: string;
|
|
25
|
+
fromVariablePropPath?: string[];
|
|
26
|
+
} | undefined;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export declare function createPipelineAgentDefinition(options: {
|
|
30
|
+
id?: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
inputs?: {
|
|
33
|
+
name: string;
|
|
34
|
+
type: DataType['type'];
|
|
35
|
+
required?: boolean;
|
|
36
|
+
}[];
|
|
37
|
+
outputs: {
|
|
38
|
+
name: string;
|
|
39
|
+
type: DataType['type'];
|
|
40
|
+
required?: boolean;
|
|
41
|
+
fromVariable: string;
|
|
42
|
+
fromVariablePropPath?: string[];
|
|
43
|
+
}[];
|
|
44
|
+
processes?: PipelineAgentProcessParameter[];
|
|
45
|
+
}): PipelineAgentDefinition;
|
|
46
|
+
export interface PipelineAgentDefinition extends RunnableDefinition {
|
|
47
|
+
type: 'pipeline_agent';
|
|
48
|
+
processes?: OrderedRecord<PipelineAgentProcess>;
|
|
49
|
+
outputs: OrderedRecord<PipelineAgentOutput>;
|
|
50
|
+
}
|
|
51
|
+
export type PipelineAgentOutput = RunnableOutput & {
|
|
52
|
+
from: 'variable';
|
|
53
|
+
fromVariableId?: string;
|
|
54
|
+
fromVariablePropPath?: (string | number)[];
|
|
55
|
+
};
|
|
56
|
+
export type PipelineAgentProcess = {
|
|
57
|
+
id: string;
|
|
58
|
+
name?: string;
|
|
59
|
+
runnable?: {
|
|
60
|
+
id?: string;
|
|
61
|
+
};
|
|
62
|
+
input?: {
|
|
63
|
+
[inputId: string]: {
|
|
64
|
+
from: 'variable';
|
|
65
|
+
fromVariableId?: string;
|
|
66
|
+
fromVariablePropPath?: (string | number)[];
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { DataType } from './data-type';
|
|
2
|
+
import { OrderedRecord } from './utils/ordered-map';
|
|
3
|
+
export interface RunOptions {
|
|
4
|
+
stream?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export type RunnableResponse<T> = T | RunnableResponseStream<T>;
|
|
7
|
+
export declare abstract class Runnable<I extends {} = {}, O extends {} = {}> {
|
|
8
|
+
definition: RunnableDefinition;
|
|
9
|
+
constructor(definition: RunnableDefinition);
|
|
10
|
+
get id(): string;
|
|
11
|
+
get name(): string | undefined;
|
|
12
|
+
inputs: {
|
|
13
|
+
[key in keyof I]: DataType;
|
|
14
|
+
};
|
|
15
|
+
outputs: {
|
|
16
|
+
[key in keyof O]: DataType;
|
|
17
|
+
};
|
|
18
|
+
abstract run(input: I, options: RunOptions & {
|
|
19
|
+
stream: true;
|
|
20
|
+
}): Promise<RunnableResponseStream<O>>;
|
|
21
|
+
abstract run(input: I, options?: RunOptions & {
|
|
22
|
+
stream?: false;
|
|
23
|
+
}): Promise<O>;
|
|
24
|
+
abstract run(input: I, options?: RunOptions): Promise<RunnableResponse<O>>;
|
|
25
|
+
}
|
|
26
|
+
export interface RunnableDefinition {
|
|
27
|
+
id: string;
|
|
28
|
+
type: string;
|
|
29
|
+
name?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
inputs: OrderedRecord<RunnableInput>;
|
|
32
|
+
outputs: OrderedRecord<RunnableOutput>;
|
|
33
|
+
}
|
|
34
|
+
export type RunnableInput = DataType;
|
|
35
|
+
export type RunnableOutput = DataType;
|
|
36
|
+
export interface RunnableResponseDelta<T> {
|
|
37
|
+
$text?: string;
|
|
38
|
+
delta?: Partial<T>;
|
|
39
|
+
}
|
|
40
|
+
export interface RunnableResponseError {
|
|
41
|
+
error: {
|
|
42
|
+
message: string;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export type RunnableResponseChunk<T> = RunnableResponseDelta<T>;
|
|
46
|
+
export type RunnableResponseChunkWithError<T> = RunnableResponseChunk<T> | RunnableResponseError;
|
|
47
|
+
export declare function isRunnableResponseDelta<T>(chunk: RunnableResponseChunkWithError<T>): chunk is RunnableResponseDelta<T>;
|
|
48
|
+
export declare function isRunnableResponseError<T>(chunk: RunnableResponseChunkWithError<T>): chunk is RunnableResponseError;
|
|
49
|
+
export type RunnableResponseStream<T> = ReadableStream<RunnableResponseChunk<T>>;
|