@aigne/core 0.4.211-beta.2 → 1.0.0
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/agent.js +18 -11
- package/lib/cjs/constants.js +5 -5
- package/lib/cjs/definitions/data-type-schema.js +12 -11
- package/lib/cjs/definitions/memory.js +3 -1
- package/lib/cjs/function-agent.js +5 -6
- package/lib/cjs/function-runner.js +13 -13
- package/lib/cjs/llm-agent.js +16 -15
- package/lib/cjs/llm-decision-agent.js +15 -13
- package/lib/cjs/llm-model.js +11 -11
- package/lib/cjs/local-function-agent.js +3 -3
- package/lib/cjs/memorable.js +3 -3
- package/lib/cjs/open-api-agent.js +4 -4
- package/lib/cjs/pipeline-agent.js +26 -17
- package/lib/cjs/runnable.js +2 -2
- package/lib/cjs/utils/fetch-open-api.js +9 -8
- package/lib/cjs/utils/fetch.js +3 -2
- package/lib/cjs/utils/is-non-nullable.js +1 -4
- package/lib/cjs/utils/message-utils.js +23 -16
- package/lib/cjs/utils/mustache-utils.js +2 -5
- package/lib/cjs/utils/open-api-parameter.js +19 -22
- package/lib/cjs/utils/stream-utils.js +6 -5
- package/lib/cjs/utils/structured-output-schema.js +10 -9
- package/lib/esm/agent.js +20 -10
- package/lib/esm/constants.js +5 -5
- package/lib/esm/definitions/data-type-schema.js +14 -13
- package/lib/esm/definitions/memory.js +5 -3
- package/lib/esm/function-agent.js +11 -12
- package/lib/esm/function-runner.js +15 -15
- package/lib/esm/index.js +18 -18
- package/lib/esm/llm-agent.js +26 -25
- package/lib/esm/llm-decision-agent.js +22 -20
- package/lib/esm/llm-model.js +13 -13
- package/lib/esm/local-function-agent.js +9 -9
- package/lib/esm/memorable.js +6 -6
- package/lib/esm/open-api-agent.js +11 -11
- package/lib/esm/pipeline-agent.js +35 -23
- package/lib/esm/runnable.js +3 -3
- package/lib/esm/utils/fetch-open-api.js +11 -9
- package/lib/esm/utils/fetch.js +3 -2
- package/lib/esm/utils/index.js +10 -10
- package/lib/esm/utils/is-non-nullable.js +1 -1
- package/lib/esm/utils/message-utils.js +26 -16
- package/lib/esm/utils/mustache-utils.js +2 -2
- package/lib/esm/utils/open-api-parameter.js +21 -21
- package/lib/esm/utils/stream-utils.js +7 -6
- package/lib/esm/utils/structured-output-schema.js +12 -8
- package/lib/types/agent.d.ts +3 -3
- package/lib/types/context.d.ts +2 -2
- package/lib/types/definitions/data-type-schema.d.ts +14 -14
- package/lib/types/definitions/data-type.d.ts +8 -8
- package/lib/types/definitions/memory.d.ts +5 -5
- package/lib/types/definitions/open-api.d.ts +9 -9
- package/lib/types/function-agent.d.ts +9 -9
- package/lib/types/function-runner.d.ts +4 -4
- package/lib/types/index.d.ts +18 -18
- package/lib/types/llm-agent.d.ts +12 -12
- package/lib/types/llm-decision-agent.d.ts +20 -20
- package/lib/types/llm-model.d.ts +12 -12
- package/lib/types/local-function-agent.d.ts +14 -16
- package/lib/types/memorable.d.ts +51 -51
- package/lib/types/open-api-agent.d.ts +12 -12
- package/lib/types/pipeline-agent.d.ts +14 -14
- package/lib/types/runnable.d.ts +5 -5
- package/lib/types/utils/fetch-open-api.d.ts +2 -2
- package/lib/types/utils/index.d.ts +10 -10
- package/lib/types/utils/message-utils.d.ts +4 -4
- package/lib/types/utils/open-api-parameter.d.ts +3 -3
- package/lib/types/utils/runnable-type.d.ts +1 -1
- package/lib/types/utils/stream-utils.d.ts +1 -1
- package/lib/types/utils/structured-output-schema.d.ts +2 -2
- package/package.json +11 -10
- package/tsconfig.json +3 -1
- package/lib/cjs/api-agent.js +0 -70
- package/lib/cjs/data-type-schema.js +0 -46
- package/lib/cjs/data-type.js +0 -2
- package/lib/cjs/definitions/api-parameter.js +0 -10
- package/lib/cjs/memory.js +0 -32
- package/lib/cjs/tsconfig.tsbuildinfo +0 -1
- package/lib/cjs/utils/fetch-api.js +0 -35
- package/lib/cjs/utils/flatten-openapi.js +0 -14
- package/lib/cjs/utils/format-parameter.js +0 -126
- package/lib/esm/api-agent.js +0 -67
- package/lib/esm/data-type-schema.js +0 -43
- package/lib/esm/data-type.js +0 -1
- package/lib/esm/definitions/api-parameter.js +0 -7
- package/lib/esm/memory.js +0 -27
- package/lib/esm/tsconfig.tsbuildinfo +0 -1
- package/lib/esm/utils/fetch-api.js +0 -31
- package/lib/esm/utils/flatten-openapi.js +0 -11
- package/lib/esm/utils/format-parameter.js +0 -116
- package/lib/types/api-agent.d.ts +0 -53
- package/lib/types/data-type-schema.d.ts +0 -46
- package/lib/types/data-type.d.ts +0 -32
- package/lib/types/definitions/api-parameter.d.ts +0 -55
- package/lib/types/memory.d.ts +0 -184
- package/lib/types/tsconfig.tsbuildinfo +0 -1
- package/lib/types/utils/fetch-api.d.ts +0 -3
- package/lib/types/utils/flatten-openapi.d.ts +0 -25
- package/lib/types/utils/format-parameter.d.ts +0 -6
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Agent, AgentProcessOptions } from
|
|
2
|
-
import type { Context, ContextState } from
|
|
3
|
-
import { DataTypeSchema } from
|
|
4
|
-
import { CreateRunnableMemory } from
|
|
5
|
-
import { CreateLLMAgentOptions, LLMAgentDefinition } from
|
|
6
|
-
import { LLMModel } from
|
|
7
|
-
import { MemorableSearchOutput, MemoryItemWithScore } from
|
|
8
|
-
import { Runnable, RunnableDefinition } from
|
|
9
|
-
import { OrderedRecord } from
|
|
10
|
-
import { ExtractRunnableInputType, ExtractRunnableOutputType } from
|
|
11
|
-
import { UnionToIntersection } from
|
|
1
|
+
import { Agent, type AgentProcessOptions } from "./agent";
|
|
2
|
+
import type { Context, ContextState } from "./context";
|
|
3
|
+
import type { DataTypeSchema } from "./definitions/data-type-schema";
|
|
4
|
+
import { type CreateRunnableMemory } from "./definitions/memory";
|
|
5
|
+
import type { CreateLLMAgentOptions, LLMAgentDefinition } from "./llm-agent";
|
|
6
|
+
import type { LLMModel } from "./llm-model";
|
|
7
|
+
import type { MemorableSearchOutput, MemoryItemWithScore } from "./memorable";
|
|
8
|
+
import type { Runnable, RunnableDefinition } from "./runnable";
|
|
9
|
+
import { OrderedRecord } from "./utils";
|
|
10
|
+
import type { ExtractRunnableInputType, ExtractRunnableOutputType } from "./utils/runnable-type";
|
|
11
|
+
import type { UnionToIntersection } from "./utils/union";
|
|
12
12
|
export declare class LLMDecisionAgent<I extends {
|
|
13
13
|
[name: string]: any;
|
|
14
14
|
} = {}, O extends {
|
|
@@ -29,21 +29,21 @@ export interface DecisionAgentCaseParameter<R extends Runnable = Runnable> {
|
|
|
29
29
|
/**
|
|
30
30
|
* Options to create LLMDecisionAgent.
|
|
31
31
|
*/
|
|
32
|
-
export interface CreateLLMDecisionAgentOptions<Case extends DecisionAgentCaseParameter, I extends UnionToIntersection<ExtractRunnableInputType<Case[
|
|
32
|
+
export interface CreateLLMDecisionAgentOptions<Case extends DecisionAgentCaseParameter, I extends UnionToIntersection<ExtractRunnableInputType<Case["runnable"]>, {
|
|
33
33
|
[name: string]: DataTypeSchema;
|
|
34
|
-
}>, O extends UnionToIntersection<ExtractRunnableOutputType<Case[
|
|
34
|
+
}>, O extends UnionToIntersection<ExtractRunnableOutputType<Case["runnable"]>, {
|
|
35
35
|
[name: string]: DataTypeSchema;
|
|
36
36
|
}>, Memories extends {
|
|
37
37
|
[name: string]: CreateRunnableMemory<I>;
|
|
38
|
-
}, State extends ContextState> extends Pick<CreateLLMAgentOptions<I, O, Memories, State>,
|
|
38
|
+
}, State extends ContextState> extends Pick<CreateLLMAgentOptions<I, O, Memories, State>, "name" | "memories" | "messages" | "modelOptions"> {
|
|
39
39
|
context: Context<State>;
|
|
40
40
|
cases: {
|
|
41
41
|
[name: string]: Case;
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
declare function create<Case extends DecisionAgentCaseParameter, I extends UnionToIntersection<ExtractRunnableInputType<Case[
|
|
44
|
+
declare function create<Case extends DecisionAgentCaseParameter, I extends UnionToIntersection<ExtractRunnableInputType<Case["runnable"]>, {
|
|
45
45
|
[name: string]: DataTypeSchema;
|
|
46
|
-
}>, O extends UnionToIntersection<ExtractRunnableOutputType<Case[
|
|
46
|
+
}>, O extends UnionToIntersection<ExtractRunnableOutputType<Case["runnable"]>, {
|
|
47
47
|
[name: string]: DataTypeSchema;
|
|
48
48
|
}>, Memories extends {
|
|
49
49
|
[name: string]: CreateRunnableMemory<I> & {
|
|
@@ -55,11 +55,11 @@ declare function create<Case extends DecisionAgentCaseParameter, I extends Union
|
|
|
55
55
|
*/
|
|
56
56
|
primary?: boolean;
|
|
57
57
|
};
|
|
58
|
-
}, State extends ContextState>({ context, ...options }: CreateLLMDecisionAgentOptions<Case, I, O, Memories, State>): LLMDecisionAgent<UnionToIntersection<ExtractRunnableInputType<Case[
|
|
59
|
-
[name in keyof Memories]: MemorableSearchOutput<Memories[name][
|
|
58
|
+
}, State extends ContextState>({ context, ...options }: CreateLLMDecisionAgentOptions<Case, I, O, Memories, State>): LLMDecisionAgent<UnionToIntersection<ExtractRunnableInputType<Case["runnable"]>, {}>, ExtractRunnableOutputType<Case["runnable"]>, {
|
|
59
|
+
[name in keyof Memories]: MemorableSearchOutput<Memories[name]["memory"]>;
|
|
60
60
|
}, State>;
|
|
61
|
-
export interface LLMDecisionAgentDefinition extends RunnableDefinition, Pick<LLMAgentDefinition,
|
|
62
|
-
type:
|
|
61
|
+
export interface LLMDecisionAgentDefinition extends RunnableDefinition, Pick<LLMAgentDefinition, "modelOptions" | "messages" | "primaryMemoryId"> {
|
|
62
|
+
type: "llm_decision_agent";
|
|
63
63
|
cases?: OrderedRecord<LLMDecisionCase>;
|
|
64
64
|
}
|
|
65
65
|
export interface LLMDecisionCase {
|
package/lib/types/llm-model.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Agent } from
|
|
2
|
-
import { Context } from
|
|
3
|
-
export type Role =
|
|
1
|
+
import { Agent } from "./agent";
|
|
2
|
+
import type { Context } from "./context";
|
|
3
|
+
export type Role = "system" | "user" | "assistant" | "tool";
|
|
4
4
|
export interface LLMModelInputs {
|
|
5
5
|
messages: LLMModelInputMessage[];
|
|
6
6
|
responseFormat?: {
|
|
7
|
-
type:
|
|
7
|
+
type: "text";
|
|
8
8
|
} | {
|
|
9
|
-
type:
|
|
9
|
+
type: "json_schema";
|
|
10
10
|
jsonSchema: {
|
|
11
11
|
name: string;
|
|
12
12
|
description?: string;
|
|
@@ -15,8 +15,8 @@ export interface LLMModelInputs {
|
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
tools?: LLMModelInputTool[];
|
|
18
|
-
toolChoice?:
|
|
19
|
-
type:
|
|
18
|
+
toolChoice?: "auto" | "none" | "required" | {
|
|
19
|
+
type: "function";
|
|
20
20
|
function: {
|
|
21
21
|
name: string;
|
|
22
22
|
description?: string;
|
|
@@ -27,17 +27,17 @@ export interface LLMModelInputs {
|
|
|
27
27
|
export interface LLMModelInputMessage {
|
|
28
28
|
role: Role;
|
|
29
29
|
content: string | ({
|
|
30
|
-
type:
|
|
30
|
+
type: "text";
|
|
31
31
|
text: string;
|
|
32
32
|
} | {
|
|
33
|
-
type:
|
|
33
|
+
type: "image_url";
|
|
34
34
|
imageUrl: {
|
|
35
35
|
url: string;
|
|
36
36
|
};
|
|
37
37
|
})[];
|
|
38
38
|
toolCalls?: {
|
|
39
39
|
id: string;
|
|
40
|
-
type:
|
|
40
|
+
type: "function";
|
|
41
41
|
function: {
|
|
42
42
|
name: string;
|
|
43
43
|
arguments: string;
|
|
@@ -46,7 +46,7 @@ export interface LLMModelInputMessage {
|
|
|
46
46
|
toolCallId?: string;
|
|
47
47
|
}
|
|
48
48
|
export interface LLMModelInputTool {
|
|
49
|
-
type:
|
|
49
|
+
type: "function";
|
|
50
50
|
function: {
|
|
51
51
|
name: string;
|
|
52
52
|
description?: string;
|
|
@@ -64,7 +64,7 @@ export interface LLMModelOutputs {
|
|
|
64
64
|
$text?: string | null;
|
|
65
65
|
toolCalls?: {
|
|
66
66
|
id?: string;
|
|
67
|
-
type?:
|
|
67
|
+
type?: "function";
|
|
68
68
|
function?: {
|
|
69
69
|
name?: string;
|
|
70
70
|
arguments?: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Agent, AgentProcessOptions } from
|
|
2
|
-
import type { Context, ContextState } from
|
|
3
|
-
import { DataTypeSchema, SchemaMapType } from
|
|
4
|
-
import { CreateRunnableMemory } from
|
|
5
|
-
import { MemorableSearchOutput, MemoryItemWithScore } from
|
|
6
|
-
import { RunnableDefinition, RunnableResponse, RunnableResponseChunk } from
|
|
1
|
+
import { Agent, type AgentProcessOptions } from "./agent";
|
|
2
|
+
import type { Context, ContextState } from "./context";
|
|
3
|
+
import { type DataTypeSchema, type SchemaMapType } from "./definitions/data-type-schema";
|
|
4
|
+
import { type CreateRunnableMemory } from "./definitions/memory";
|
|
5
|
+
import type { MemorableSearchOutput, MemoryItemWithScore } from "./memorable";
|
|
6
|
+
import type { RunnableDefinition, RunnableResponse, RunnableResponseChunk } from "./runnable";
|
|
7
7
|
export declare class LocalFunctionAgent<I extends {
|
|
8
8
|
[name: string]: any;
|
|
9
9
|
} = {}, O extends {
|
|
@@ -23,21 +23,19 @@ export interface LocalFunctionAgentDefinition<I extends {
|
|
|
23
23
|
}, Memories extends {
|
|
24
24
|
[name: string]: MemoryItemWithScore[];
|
|
25
25
|
}, State extends ContextState> extends RunnableDefinition {
|
|
26
|
-
type:
|
|
26
|
+
type: "local_function_agent";
|
|
27
27
|
function?: LocalFunctionFuncType<I, O, Memories, State>;
|
|
28
28
|
}
|
|
29
|
-
export
|
|
29
|
+
export type LocalFunctionFuncType<I extends {
|
|
30
30
|
[name: string]: any;
|
|
31
31
|
}, O extends {
|
|
32
32
|
[name: string]: any;
|
|
33
33
|
}, Memories extends {
|
|
34
34
|
[name: string]: MemoryItemWithScore[];
|
|
35
|
-
}, State extends ContextState> {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}): Promise<RunnableResponse<O> | AsyncGenerator<RunnableResponseChunk<O>, void>> | AsyncGenerator<RunnableResponseChunk<O>, void>;
|
|
40
|
-
}
|
|
35
|
+
}, State extends ContextState> = (input: I, options: {
|
|
36
|
+
memories: Memories;
|
|
37
|
+
context: Context<State>;
|
|
38
|
+
}) => Promise<RunnableResponse<O> | AsyncGenerator<RunnableResponseChunk<O>, void>> | AsyncGenerator<RunnableResponseChunk<O>, void>;
|
|
41
39
|
export interface CreateLocalFunctionAgentOptions<I extends {
|
|
42
40
|
[name: string]: DataTypeSchema;
|
|
43
41
|
}, O extends {
|
|
@@ -51,7 +49,7 @@ export interface CreateLocalFunctionAgentOptions<I extends {
|
|
|
51
49
|
outputs: O;
|
|
52
50
|
memories?: Memories;
|
|
53
51
|
function?: LocalFunctionFuncType<SchemaMapType<I>, SchemaMapType<O>, {
|
|
54
|
-
[key in keyof Memories]: MemorableSearchOutput<Memories[key][
|
|
52
|
+
[key in keyof Memories]: MemorableSearchOutput<Memories[key]["memory"]>;
|
|
55
53
|
}, State>;
|
|
56
54
|
}
|
|
57
55
|
declare function create<I extends {
|
|
@@ -61,6 +59,6 @@ declare function create<I extends {
|
|
|
61
59
|
}, Memories extends {
|
|
62
60
|
[name: string]: CreateRunnableMemory<I>;
|
|
63
61
|
}, State extends ContextState>({ context, ...options }: CreateLocalFunctionAgentOptions<I, O, Memories, State>): LocalFunctionAgent<SchemaMapType<I>, SchemaMapType<O>, {
|
|
64
|
-
[name in keyof Memories]: MemorableSearchOutput<Memories[name][
|
|
62
|
+
[name in keyof Memories]: MemorableSearchOutput<Memories[name]["memory"]>;
|
|
65
63
|
}, State>;
|
|
66
64
|
export {};
|
package/lib/types/memorable.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import type { LLMModelInputMessage } from
|
|
2
|
-
import { Runnable } from
|
|
1
|
+
import type { LLMModelInputMessage } from "./llm-model";
|
|
2
|
+
import { Runnable } from "./runnable";
|
|
3
3
|
export interface MemoryMetadata {
|
|
4
4
|
[key: string]: any;
|
|
5
5
|
}
|
|
6
6
|
export type MemoryActionItem<T> = {
|
|
7
|
-
event:
|
|
7
|
+
event: "add";
|
|
8
8
|
id: string;
|
|
9
9
|
memory: T;
|
|
10
10
|
metadata?: MemoryMetadata;
|
|
11
11
|
} | {
|
|
12
|
-
event:
|
|
12
|
+
event: "update";
|
|
13
13
|
id: string;
|
|
14
14
|
memory: T;
|
|
15
15
|
oldMemory: T;
|
|
16
16
|
metadata?: MemoryMetadata;
|
|
17
17
|
} | {
|
|
18
|
-
event:
|
|
18
|
+
event: "delete";
|
|
19
19
|
id: string;
|
|
20
20
|
memory: T;
|
|
21
21
|
} | {
|
|
22
|
-
event:
|
|
22
|
+
event: "none";
|
|
23
23
|
memory: T;
|
|
24
24
|
};
|
|
25
25
|
export interface MemoryItem<T> {
|
|
@@ -36,7 +36,7 @@ export interface MemoryItemWithScore<T = any> extends MemoryItem<T> {
|
|
|
36
36
|
}
|
|
37
37
|
export type MemoryMessage = LLMModelInputMessage;
|
|
38
38
|
export type MemoryActions<T> = {
|
|
39
|
-
action:
|
|
39
|
+
action: "add";
|
|
40
40
|
inputs: {
|
|
41
41
|
messages: MemoryMessage[];
|
|
42
42
|
options?: {
|
|
@@ -49,7 +49,7 @@ export type MemoryActions<T> = {
|
|
|
49
49
|
results: MemoryActionItem<T>[];
|
|
50
50
|
};
|
|
51
51
|
} | {
|
|
52
|
-
action:
|
|
52
|
+
action: "search";
|
|
53
53
|
inputs: {
|
|
54
54
|
query: string;
|
|
55
55
|
options?: {
|
|
@@ -64,7 +64,7 @@ export type MemoryActions<T> = {
|
|
|
64
64
|
results: MemoryItemWithScore<T>[];
|
|
65
65
|
};
|
|
66
66
|
} | {
|
|
67
|
-
action:
|
|
67
|
+
action: "filter";
|
|
68
68
|
inputs: {
|
|
69
69
|
options?: {
|
|
70
70
|
k?: number;
|
|
@@ -78,7 +78,7 @@ export type MemoryActions<T> = {
|
|
|
78
78
|
results: MemoryItem<T>[];
|
|
79
79
|
};
|
|
80
80
|
} | {
|
|
81
|
-
action:
|
|
81
|
+
action: "get";
|
|
82
82
|
inputs: {
|
|
83
83
|
memoryId: string;
|
|
84
84
|
};
|
|
@@ -86,7 +86,7 @@ export type MemoryActions<T> = {
|
|
|
86
86
|
result: MemoryItem<T> | null;
|
|
87
87
|
};
|
|
88
88
|
} | {
|
|
89
|
-
action:
|
|
89
|
+
action: "create";
|
|
90
90
|
inputs: {
|
|
91
91
|
memory: T;
|
|
92
92
|
options?: {
|
|
@@ -99,7 +99,7 @@ export type MemoryActions<T> = {
|
|
|
99
99
|
result: MemoryItem<T>;
|
|
100
100
|
};
|
|
101
101
|
} | {
|
|
102
|
-
action:
|
|
102
|
+
action: "update";
|
|
103
103
|
inputs: {
|
|
104
104
|
memoryId: string;
|
|
105
105
|
memory: T;
|
|
@@ -108,65 +108,65 @@ export type MemoryActions<T> = {
|
|
|
108
108
|
result: MemoryItem<T> | null;
|
|
109
109
|
};
|
|
110
110
|
} | {
|
|
111
|
-
action:
|
|
111
|
+
action: "delete";
|
|
112
112
|
inputs: {
|
|
113
113
|
filter: string | string[] | Record<string, any>;
|
|
114
114
|
};
|
|
115
115
|
outputs: {};
|
|
116
116
|
} | {
|
|
117
|
-
action:
|
|
117
|
+
action: "reset";
|
|
118
118
|
inputs: {};
|
|
119
119
|
outputs: {};
|
|
120
120
|
};
|
|
121
121
|
export interface SortItem {
|
|
122
122
|
field: string;
|
|
123
|
-
direction:
|
|
123
|
+
direction: "asc" | "desc";
|
|
124
124
|
}
|
|
125
125
|
export type MemorySortOptions = SortItem | SortItem[];
|
|
126
|
-
export declare abstract class Memorable<T, C = undefined> extends Runnable<MemoryActions<T>, MemoryActions<T>[
|
|
126
|
+
export declare abstract class Memorable<T, C = undefined> extends Runnable<MemoryActions<T>, MemoryActions<T>["outputs"]> {
|
|
127
127
|
constructor();
|
|
128
128
|
abstract runner?: MemoryRunner<T, C>;
|
|
129
129
|
abstract add(messages: Extract<MemoryActions<T>, {
|
|
130
|
-
action:
|
|
131
|
-
}>[
|
|
132
|
-
action:
|
|
133
|
-
}>[
|
|
134
|
-
action:
|
|
135
|
-
}>[
|
|
130
|
+
action: "add";
|
|
131
|
+
}>["inputs"]["messages"], options?: Extract<MemoryActions<T>, {
|
|
132
|
+
action: "add";
|
|
133
|
+
}>["inputs"]["options"]): Promise<Extract<MemoryActions<T>, {
|
|
134
|
+
action: "add";
|
|
135
|
+
}>["outputs"]>;
|
|
136
136
|
abstract search(query: Extract<MemoryActions<T>, {
|
|
137
|
-
action:
|
|
138
|
-
}>[
|
|
139
|
-
action:
|
|
140
|
-
}>[
|
|
141
|
-
action:
|
|
142
|
-
}>[
|
|
137
|
+
action: "search";
|
|
138
|
+
}>["inputs"]["query"], options?: Extract<MemoryActions<T>, {
|
|
139
|
+
action: "search";
|
|
140
|
+
}>["inputs"]["options"]): Promise<Extract<MemoryActions<T>, {
|
|
141
|
+
action: "search";
|
|
142
|
+
}>["outputs"]>;
|
|
143
143
|
abstract filter(options: Extract<MemoryActions<T>, {
|
|
144
|
-
action:
|
|
145
|
-
}>[
|
|
146
|
-
action:
|
|
147
|
-
}>[
|
|
144
|
+
action: "filter";
|
|
145
|
+
}>["inputs"]["options"]): Promise<Extract<MemoryActions<T>, {
|
|
146
|
+
action: "filter";
|
|
147
|
+
}>["outputs"]>;
|
|
148
148
|
abstract get(memoryId: Extract<MemoryActions<T>, {
|
|
149
|
-
action:
|
|
150
|
-
}>[
|
|
151
|
-
action:
|
|
152
|
-
}>[
|
|
149
|
+
action: "get";
|
|
150
|
+
}>["inputs"]["memoryId"]): Promise<Extract<MemoryActions<T>, {
|
|
151
|
+
action: "get";
|
|
152
|
+
}>["outputs"]>;
|
|
153
153
|
abstract create(memory: Extract<MemoryActions<T>, {
|
|
154
|
-
action:
|
|
155
|
-
}>[
|
|
156
|
-
action:
|
|
157
|
-
}>[
|
|
158
|
-
action:
|
|
159
|
-
}>[
|
|
154
|
+
action: "create";
|
|
155
|
+
}>["inputs"]["memory"], options?: Extract<MemoryActions<T>, {
|
|
156
|
+
action: "create";
|
|
157
|
+
}>["inputs"]["options"]): Promise<Extract<MemoryActions<T>, {
|
|
158
|
+
action: "create";
|
|
159
|
+
}>["outputs"]>;
|
|
160
160
|
abstract update(memoryId: Extract<MemoryActions<T>, {
|
|
161
|
-
action:
|
|
162
|
-
}>[
|
|
163
|
-
action:
|
|
164
|
-
}>[
|
|
161
|
+
action: "update";
|
|
162
|
+
}>["inputs"]["memoryId"], memory: T): Promise<Extract<MemoryActions<T>, {
|
|
163
|
+
action: "update";
|
|
164
|
+
}>["outputs"]>;
|
|
165
165
|
abstract delete(memoryId: Extract<MemoryActions<T>, {
|
|
166
|
-
action:
|
|
167
|
-
}>[
|
|
168
|
-
action:
|
|
169
|
-
}>[
|
|
166
|
+
action: "delete";
|
|
167
|
+
}>["inputs"]["filter"]): Promise<Extract<MemoryActions<T>, {
|
|
168
|
+
action: "delete";
|
|
169
|
+
}>["outputs"]>;
|
|
170
170
|
abstract reset(): Promise<void>;
|
|
171
171
|
}
|
|
172
172
|
export interface MemoryRunnerInput<C = undefined> {
|
|
@@ -180,4 +180,4 @@ export interface MemoryRunnerInput<C = undefined> {
|
|
|
180
180
|
export declare abstract class MemoryRunner<T, C = undefined> extends Runnable<MemoryRunnerInput<C>, MemoryActionItem<T>[]> {
|
|
181
181
|
constructor(name: string);
|
|
182
182
|
}
|
|
183
|
-
export type MemorableSearchOutput<T extends Memorable<any>> = Awaited<ReturnType<T[
|
|
183
|
+
export type MemorableSearchOutput<T extends Memorable<any>> = Awaited<ReturnType<T["search"]>>["results"];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Agent } from
|
|
2
|
-
import type { Context, ContextState } from
|
|
3
|
-
import { DataTypeSchema, SchemaMapType } from
|
|
4
|
-
import { CreateRunnableMemory } from
|
|
5
|
-
import { AuthConfig, FetchRequest, HTTPMethod, OpenAPIDataType, OpenAPIDataTypeSchema } from
|
|
6
|
-
import { MemorableSearchOutput, MemoryItemWithScore } from
|
|
7
|
-
import { RunnableDefinition } from
|
|
8
|
-
import { OrderedRecord } from
|
|
1
|
+
import { Agent } from "./agent";
|
|
2
|
+
import type { Context, ContextState } from "./context";
|
|
3
|
+
import { type DataTypeSchema, type SchemaMapType } from "./definitions/data-type-schema";
|
|
4
|
+
import type { CreateRunnableMemory } from "./definitions/memory";
|
|
5
|
+
import type { AuthConfig, FetchRequest, HTTPMethod, OpenAPIDataType, OpenAPIDataTypeSchema } from "./definitions/open-api";
|
|
6
|
+
import type { MemorableSearchOutput, MemoryItemWithScore } from "./memorable";
|
|
7
|
+
import type { RunnableDefinition } from "./runnable";
|
|
8
|
+
import type { OrderedRecord } from "./utils";
|
|
9
9
|
export declare class OpenAPIAgent<I extends {
|
|
10
10
|
[name: string]: any;
|
|
11
11
|
} = {}, O extends {
|
|
@@ -16,11 +16,11 @@ export declare class OpenAPIAgent<I extends {
|
|
|
16
16
|
definition: OpenAPIAgentDefinition;
|
|
17
17
|
static create: typeof create;
|
|
18
18
|
constructor(definition: OpenAPIAgentDefinition, context?: Context<State>);
|
|
19
|
-
process(input: I): Promise<
|
|
20
|
-
fetch(request: FetchRequest): Promise<
|
|
19
|
+
process(input: I): Promise<O>;
|
|
20
|
+
fetch<T>(request: FetchRequest): Promise<T>;
|
|
21
21
|
}
|
|
22
22
|
export interface OpenAPIAgentDefinition extends RunnableDefinition {
|
|
23
|
-
type:
|
|
23
|
+
type: "open_api_agent";
|
|
24
24
|
inputs: OrderedRecord<OpenAPIDataType>;
|
|
25
25
|
url: string;
|
|
26
26
|
method?: HTTPMethod;
|
|
@@ -50,6 +50,6 @@ declare function create<I extends {
|
|
|
50
50
|
}, Memories extends {
|
|
51
51
|
[name: string]: CreateRunnableMemory<I>;
|
|
52
52
|
}, State extends ContextState>({ context, ...options }: CreateOpenAPIAgentOptions<I, O, Memories, State>): OpenAPIAgent<SchemaMapType<I>, SchemaMapType<O>, {
|
|
53
|
-
[name in keyof Memories]: MemorableSearchOutput<Memories[name][
|
|
53
|
+
[name in keyof Memories]: MemorableSearchOutput<Memories[name]["memory"]>;
|
|
54
54
|
}, State>;
|
|
55
55
|
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Agent, AgentProcessOptions } from
|
|
2
|
-
import type { Context, ContextState } from
|
|
3
|
-
import { DataTypeSchema, SchemaMapType } from
|
|
4
|
-
import { CreateRunnableMemory } from
|
|
5
|
-
import { MemorableSearchOutput, MemoryItemWithScore } from
|
|
6
|
-
import { Runnable, RunnableDefinition, RunnableOutput, RunnableResponseDelta } from
|
|
7
|
-
import { MakeNullablePropertyOptional } from
|
|
8
|
-
import { OrderedRecord } from
|
|
9
|
-
import { ExtractRunnableInputType } from
|
|
1
|
+
import { Agent, type AgentProcessOptions } from "./agent";
|
|
2
|
+
import type { Context, ContextState } from "./context";
|
|
3
|
+
import { type DataTypeSchema, type SchemaMapType } from "./definitions/data-type-schema";
|
|
4
|
+
import { type CreateRunnableMemory } from "./definitions/memory";
|
|
5
|
+
import type { MemorableSearchOutput, MemoryItemWithScore } from "./memorable";
|
|
6
|
+
import type { Runnable, RunnableDefinition, RunnableOutput, RunnableResponseDelta } from "./runnable";
|
|
7
|
+
import type { MakeNullablePropertyOptional } from "./utils/nullable";
|
|
8
|
+
import { OrderedRecord } from "./utils/ordered-map";
|
|
9
|
+
import type { ExtractRunnableInputType } from "./utils/runnable-type";
|
|
10
10
|
export declare class PipelineAgent<I extends {
|
|
11
11
|
[key: string]: any;
|
|
12
12
|
} = {}, O extends {
|
|
@@ -17,7 +17,7 @@ export declare class PipelineAgent<I extends {
|
|
|
17
17
|
definition: PipelineAgentDefinition;
|
|
18
18
|
static create: typeof create;
|
|
19
19
|
constructor(definition: PipelineAgentDefinition, context?: Context<State>);
|
|
20
|
-
process(input: I, options: AgentProcessOptions<Memories>): Promise<ReadableStream<RunnableResponseDelta<O>>>;
|
|
20
|
+
process(input: I, options: AgentProcessOptions<Memories>): Promise<import("stream/web").ReadableStream<RunnableResponseDelta<O>>>;
|
|
21
21
|
}
|
|
22
22
|
type VariableWithPropPath = {
|
|
23
23
|
fromVariable: string;
|
|
@@ -50,15 +50,15 @@ declare function create<I extends {
|
|
|
50
50
|
memories?: Memories;
|
|
51
51
|
processes: Processes;
|
|
52
52
|
}): PipelineAgent<SchemaMapType<I>, SchemaMapType<O>, {
|
|
53
|
-
[name in keyof Memories]: MemorableSearchOutput<Memories[name][
|
|
53
|
+
[name in keyof Memories]: MemorableSearchOutput<Memories[name]["memory"]>;
|
|
54
54
|
}, State>;
|
|
55
55
|
export interface PipelineAgentDefinition extends RunnableDefinition {
|
|
56
|
-
type:
|
|
56
|
+
type: "pipeline_agent";
|
|
57
57
|
processes?: OrderedRecord<PipelineAgentProcess>;
|
|
58
58
|
outputs: OrderedRecord<PipelineAgentOutput>;
|
|
59
59
|
}
|
|
60
60
|
export type PipelineAgentOutput = RunnableOutput & {
|
|
61
|
-
from:
|
|
61
|
+
from: "variable";
|
|
62
62
|
fromVariableId?: string;
|
|
63
63
|
fromVariablePropPath?: (string | number)[];
|
|
64
64
|
};
|
|
@@ -70,7 +70,7 @@ export type PipelineAgentProcess = {
|
|
|
70
70
|
};
|
|
71
71
|
input?: {
|
|
72
72
|
[inputId: string]: {
|
|
73
|
-
from:
|
|
73
|
+
from: "variable";
|
|
74
74
|
fromVariableId?: string;
|
|
75
75
|
fromVariablePropPath?: (string | number | symbol)[];
|
|
76
76
|
};
|
package/lib/types/runnable.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Context, ContextState } from
|
|
2
|
-
import type { DataType } from
|
|
3
|
-
import type { Memorable } from
|
|
4
|
-
import { OrderedRecord } from
|
|
1
|
+
import type { Context, ContextState } from "./context";
|
|
2
|
+
import type { DataType } from "./definitions/data-type";
|
|
3
|
+
import type { Memorable } from "./memorable";
|
|
4
|
+
import { OrderedRecord } from "./utils/ordered-map";
|
|
5
5
|
export interface RunOptions {
|
|
6
6
|
stream?: boolean;
|
|
7
7
|
}
|
|
@@ -44,7 +44,7 @@ export interface RunnableMemory {
|
|
|
44
44
|
name?: string;
|
|
45
45
|
memory?: Memorable<any>;
|
|
46
46
|
query?: {
|
|
47
|
-
from:
|
|
47
|
+
from: "variable";
|
|
48
48
|
fromVariableId?: string;
|
|
49
49
|
fromVariablePropPath?: string[];
|
|
50
50
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { FetchRequest } from
|
|
2
|
-
export declare
|
|
1
|
+
import type { FetchRequest } from "../definitions/open-api";
|
|
2
|
+
export declare function fetchOpenApi<T>(request: FetchRequest): Promise<T>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
1
|
+
export * from "./fetch";
|
|
2
|
+
export * from "./fetch-open-api";
|
|
3
|
+
export * from "./is-non-nullable";
|
|
4
|
+
export * from "./mustache-utils";
|
|
5
|
+
export * from "./nullable";
|
|
6
|
+
export * from "./omit";
|
|
7
|
+
export * from "./open-api-parameter";
|
|
8
|
+
export * from "./ordered-map";
|
|
9
|
+
export * from "./stream-utils";
|
|
10
|
+
export * from "./union";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { LLMAgentDefinition } from
|
|
2
|
-
import type { LLMModelInputMessage } from
|
|
3
|
-
import type { MemoryItemWithScore } from
|
|
1
|
+
import type { LLMAgentDefinition } from "../llm-agent";
|
|
2
|
+
import type { LLMModelInputMessage } from "../llm-model";
|
|
3
|
+
import type { MemoryItemWithScore } from "../memorable";
|
|
4
4
|
export declare function mergeHistoryMessages(messages: LLMModelInputMessage[], history: LLMModelInputMessage[]): LLMModelInputMessage[];
|
|
5
5
|
export declare function memoriesToMessages(memories: {
|
|
6
6
|
[name: string]: MemoryItemWithScore[];
|
|
@@ -10,7 +10,7 @@ export declare function memoriesToMessages(memories: {
|
|
|
10
10
|
primaryMemory: LLMModelInputMessage[];
|
|
11
11
|
memory: string;
|
|
12
12
|
};
|
|
13
|
-
export declare function prepareMessages(definition: Pick<LLMAgentDefinition,
|
|
13
|
+
export declare function prepareMessages(definition: Pick<LLMAgentDefinition, "messages" | "memories" | "primaryMemoryId">, input: {
|
|
14
14
|
[name: string]: any;
|
|
15
15
|
}, memories: {
|
|
16
16
|
[name: string]: MemoryItemWithScore[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AuthConfig, FetchRequest, HTTPMethod } from
|
|
2
|
-
import type { OpenAPIAgentDefinition } from
|
|
1
|
+
import type { AuthConfig, FetchRequest, HTTPMethod } from "../definitions/open-api";
|
|
2
|
+
import type { OpenAPIAgentDefinition } from "../open-api-agent";
|
|
3
3
|
export declare function formatOpenAPIRequest(api: {
|
|
4
4
|
url: string;
|
|
5
5
|
method: HTTPMethod;
|
|
6
6
|
auth?: AuthConfig;
|
|
7
|
-
}, inputs: OpenAPIAgentDefinition[
|
|
7
|
+
}, inputs: OpenAPIAgentDefinition["inputs"], input: Record<string, any>): Promise<FetchRequest>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Runnable, RunnableResponseStream } from
|
|
1
|
+
import type { Runnable, RunnableResponseStream } from "../runnable";
|
|
2
2
|
export type ExtractRunnableInputType<T> = T extends Runnable<infer I, any> ? I : never;
|
|
3
3
|
export type ExtractRunnableOutputType<T> = T extends Runnable<any, infer O> ? Exclude<O, RunnableResponseStream<any>> : never;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RunnableResponse, RunnableResponseChunk, RunnableResponseStream } from
|
|
1
|
+
import { type RunnableResponse, type RunnableResponseChunk, type RunnableResponseStream } from "../runnable";
|
|
2
2
|
export declare function objectToRunnableResponseStream<T extends {
|
|
3
3
|
[key: string]: any;
|
|
4
4
|
}>(obj: T): RunnableResponseStream<T>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { RunnableOutput } from
|
|
2
|
-
import { OrderedRecord } from
|
|
1
|
+
import type { RunnableOutput } from "../runnable";
|
|
2
|
+
import { OrderedRecord } from "./ordered-map";
|
|
3
3
|
export declare function outputsToJsonSchema(outputs: OrderedRecord<RunnableOutput>): object;
|