@agentica/core 0.13.5 → 0.14.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/Agentica.js +8 -10
- package/lib/Agentica.js.map +1 -1
- package/lib/context/AgenticaCancelPrompt.d.ts +4 -12
- package/lib/context/AgenticaCancelPrompt.js +0 -17
- package/lib/context/AgenticaCancelPrompt.js.map +1 -1
- package/lib/context/AgenticaOperationSelection.d.ts +4 -11
- package/lib/context/AgenticaOperationSelection.js +0 -14
- package/lib/context/AgenticaOperationSelection.js.map +1 -1
- package/lib/context/AgenticaTokenUsage.js.map +1 -1
- package/lib/context/internal/AgenticaTokenUsageAggregator.js.map +1 -1
- package/lib/events/AgenticaCallEvent.d.ts +23 -13
- package/lib/events/AgenticaCallEvent.js +0 -19
- package/lib/events/AgenticaCallEvent.js.map +1 -1
- package/lib/events/AgenticaCancelEvent.d.ts +4 -10
- package/lib/events/AgenticaCancelEvent.js +0 -15
- package/lib/events/AgenticaCancelEvent.js.map +1 -1
- package/lib/events/AgenticaDescribeEvent.d.ts +8 -27
- package/lib/events/AgenticaDescribeEvent.js +0 -52
- package/lib/events/AgenticaDescribeEvent.js.map +1 -1
- package/lib/events/AgenticaEvent.d.ts +13 -1
- package/lib/events/AgenticaEventBase.d.ts +5 -3
- package/lib/events/AgenticaEventBase.js +0 -7
- package/lib/events/AgenticaEventBase.js.map +1 -1
- package/lib/events/AgenticaExecuteEvent.d.ts +15 -15
- package/lib/events/AgenticaExecuteEvent.js +0 -30
- package/lib/events/AgenticaExecuteEvent.js.map +1 -1
- package/lib/events/AgenticaInitializeEvent.d.ts +3 -4
- package/lib/events/AgenticaInitializeEvent.js +0 -13
- package/lib/events/AgenticaInitializeEvent.js.map +1 -1
- package/lib/events/AgenticaRequestEvent.d.ts +5 -24
- package/lib/events/AgenticaRequestEvent.js +0 -19
- package/lib/events/AgenticaRequestEvent.js.map +1 -1
- package/lib/events/AgenticaResponseEvent.d.ts +22 -32
- package/lib/events/AgenticaResponseEvent.js +0 -13
- package/lib/events/AgenticaResponseEvent.js.map +1 -1
- package/lib/events/AgenticaSelectEvent.d.ts +6 -12
- package/lib/events/AgenticaSelectEvent.js +0 -23
- package/lib/events/AgenticaSelectEvent.js.map +1 -1
- package/lib/events/AgenticaTextEvent.d.ts +8 -27
- package/lib/events/AgenticaTextEvent.js +0 -52
- package/lib/events/AgenticaTextEvent.js.map +1 -1
- package/lib/events/AgenticaValidateEvent.d.ts +25 -0
- package/lib/events/AgenticaValidateEvent.js +3 -0
- package/lib/events/AgenticaValidateEvent.js.map +1 -0
- package/lib/factory/events.d.ts +65 -0
- package/lib/factory/events.js +173 -0
- package/lib/factory/events.js.map +1 -0
- package/lib/factory/index.d.ts +3 -0
- package/lib/factory/index.js +20 -0
- package/lib/factory/index.js.map +1 -0
- package/lib/factory/operations.d.ts +7 -0
- package/lib/factory/operations.js +14 -0
- package/lib/factory/operations.js.map +1 -0
- package/lib/factory/prompts.d.ts +30 -0
- package/lib/factory/prompts.js +76 -0
- package/lib/factory/prompts.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +25 -4
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +328 -347
- package/lib/index.mjs.map +1 -1
- package/lib/json/IAgenticaEventJson.d.ts +4 -2
- package/lib/json/IAgenticaPromptJson.d.ts +1 -1
- package/lib/orchestrate/ChatGptAgent.js.map +1 -0
- package/lib/{chatgpt → orchestrate}/ChatGptCallFunctionAgent.d.ts +2 -1
- package/lib/{chatgpt → orchestrate}/ChatGptCallFunctionAgent.js +33 -28
- package/lib/orchestrate/ChatGptCallFunctionAgent.js.map +1 -0
- package/lib/orchestrate/ChatGptCancelFunctionAgent.d.ts +12 -0
- package/lib/{chatgpt → orchestrate}/ChatGptCancelFunctionAgent.js +7 -9
- package/lib/orchestrate/ChatGptCancelFunctionAgent.js.map +1 -0
- package/lib/orchestrate/ChatGptCompletionMessageUtil.d.ts +14 -0
- package/lib/{chatgpt → orchestrate}/ChatGptCompletionMessageUtil.js +0 -5
- package/lib/orchestrate/ChatGptCompletionMessageUtil.js.map +1 -0
- package/lib/{chatgpt → orchestrate}/ChatGptDescribeFunctionAgent.d.ts +3 -2
- package/lib/{chatgpt → orchestrate}/ChatGptDescribeFunctionAgent.js +4 -5
- package/lib/orchestrate/ChatGptDescribeFunctionAgent.js.map +1 -0
- package/lib/{chatgpt → orchestrate}/ChatGptHistoryDecoder.d.ts +2 -1
- package/lib/{chatgpt → orchestrate}/ChatGptHistoryDecoder.js +0 -1
- package/lib/orchestrate/ChatGptHistoryDecoder.js.map +1 -0
- package/lib/{chatgpt → orchestrate}/ChatGptInitializeFunctionAgent.d.ts +2 -1
- package/lib/{chatgpt → orchestrate}/ChatGptInitializeFunctionAgent.js +4 -5
- package/lib/orchestrate/ChatGptInitializeFunctionAgent.js.map +1 -0
- package/lib/{chatgpt → orchestrate}/ChatGptSelectFunctionAgent.d.ts +1 -1
- package/lib/{chatgpt → orchestrate}/ChatGptSelectFunctionAgent.js +10 -13
- package/lib/orchestrate/ChatGptSelectFunctionAgent.js.map +1 -0
- package/lib/orchestrate/ChatGptUsageAggregator.d.ts +10 -0
- package/lib/{chatgpt → orchestrate}/ChatGptUsageAggregator.js +0 -3
- package/lib/orchestrate/ChatGptUsageAggregator.js.map +1 -0
- package/lib/orchestrate/index.d.ts +8 -0
- package/lib/orchestrate/index.js +25 -0
- package/lib/orchestrate/index.js.map +1 -0
- package/lib/prompts/AgenticaCancelPrompt.d.ts +4 -12
- package/lib/prompts/AgenticaCancelPrompt.js +0 -17
- package/lib/prompts/AgenticaCancelPrompt.js.map +1 -1
- package/lib/prompts/AgenticaDescribePrompt.d.ts +4 -12
- package/lib/prompts/AgenticaDescribePrompt.js +0 -17
- package/lib/prompts/AgenticaDescribePrompt.js.map +1 -1
- package/lib/prompts/AgenticaExecutePrompt.d.ts +42 -13
- package/lib/prompts/AgenticaExecutePrompt.js +0 -21
- package/lib/prompts/AgenticaExecutePrompt.js.map +1 -1
- package/lib/prompts/AgenticaPrompt.d.ts +10 -0
- package/lib/prompts/AgenticaPromptBase.d.ts +5 -6
- package/lib/prompts/AgenticaPromptBase.js +0 -19
- package/lib/prompts/AgenticaPromptBase.js.map +1 -1
- package/lib/prompts/AgenticaSelectPrompt.d.ts +4 -12
- package/lib/prompts/AgenticaSelectPrompt.js +0 -17
- package/lib/prompts/AgenticaSelectPrompt.js.map +1 -1
- package/lib/prompts/AgenticaTextPrompt.d.ts +4 -12
- package/lib/prompts/AgenticaTextPrompt.js +0 -17
- package/lib/prompts/AgenticaTextPrompt.js.map +1 -1
- package/lib/transformers/AgenticaEventTransformer.d.ts +16 -16
- package/lib/transformers/AgenticaEventTransformer.js +12 -30
- package/lib/transformers/AgenticaEventTransformer.js.map +1 -1
- package/lib/transformers/AgenticaPromptTransformer.d.ts +12 -11
- package/lib/transformers/AgenticaPromptTransformer.js +9 -19
- package/lib/transformers/AgenticaPromptTransformer.js.map +1 -1
- package/package.json +3 -3
- package/src/Agentica.ts +11 -11
- package/src/context/AgenticaCancelPrompt.ts +4 -25
- package/src/context/AgenticaContext.ts +0 -1
- package/src/context/AgenticaOperation.ts +0 -1
- package/src/context/AgenticaOperationCollection.ts +0 -1
- package/src/context/AgenticaOperationSelection.ts +4 -22
- package/src/context/AgenticaTokenUsage.ts +2 -2
- package/src/context/internal/AgenticaTokenUsageAggregator.ts +0 -1
- package/src/events/AgenticaCallEvent.ts +26 -29
- package/src/events/AgenticaCancelEvent.ts +4 -21
- package/src/events/AgenticaDescribeEvent.ts +8 -57
- package/src/events/AgenticaEvent.ts +14 -2
- package/src/events/AgenticaEventBase.ts +5 -6
- package/src/events/AgenticaExecuteEvent.ts +33 -41
- package/src/events/AgenticaInitializeEvent.ts +3 -11
- package/src/events/AgenticaRequestEvent.ts +5 -40
- package/src/events/AgenticaResponseEvent.ts +22 -39
- package/src/events/AgenticaSelectEvent.ts +6 -30
- package/src/events/AgenticaTextEvent.ts +11 -60
- package/src/events/AgenticaValidateEvent.ts +31 -0
- package/src/factory/events.ts +229 -0
- package/src/factory/index.ts +3 -0
- package/src/factory/operations.ts +17 -0
- package/src/factory/prompts.ts +104 -0
- package/src/index.ts +5 -6
- package/src/json/IAgenticaEventJson.ts +5 -3
- package/src/json/IAgenticaPromptJson.ts +1 -1
- package/src/{chatgpt → orchestrate}/ChatGptCallFunctionAgent.ts +62 -50
- package/src/{chatgpt → orchestrate}/ChatGptCancelFunctionAgent.ts +18 -16
- package/src/{chatgpt → orchestrate}/ChatGptCompletionMessageUtil.ts +7 -6
- package/src/{chatgpt → orchestrate}/ChatGptDescribeFunctionAgent.ts +7 -6
- package/src/{chatgpt → orchestrate}/ChatGptHistoryDecoder.ts +1 -2
- package/src/{chatgpt → orchestrate}/ChatGptInitializeFunctionAgent.ts +8 -7
- package/src/{chatgpt → orchestrate}/ChatGptSelectFunctionAgent.ts +18 -16
- package/src/{chatgpt → orchestrate}/ChatGptUsageAggregator.ts +3 -3
- package/src/orchestrate/index.ts +8 -0
- package/src/prompts/AgenticaCancelPrompt.ts +4 -25
- package/src/prompts/AgenticaDescribePrompt.ts +4 -25
- package/src/prompts/AgenticaExecutePrompt.ts +52 -44
- package/src/prompts/AgenticaPrompt.ts +10 -1
- package/src/prompts/AgenticaPromptBase.ts +5 -9
- package/src/prompts/AgenticaSelectPrompt.ts +4 -25
- package/src/prompts/AgenticaTextPrompt.ts +4 -26
- package/src/transformers/AgenticaEventTransformer.ts +30 -32
- package/src/transformers/AgenticaPromptTransformer.ts +22 -22
- package/lib/chatgpt/ChatGptAgent.js.map +0 -1
- package/lib/chatgpt/ChatGptCallFunctionAgent.js.map +0 -1
- package/lib/chatgpt/ChatGptCancelFunctionAgent.d.ts +0 -11
- package/lib/chatgpt/ChatGptCancelFunctionAgent.js.map +0 -1
- package/lib/chatgpt/ChatGptCompletionMessageUtil.d.ts +0 -13
- package/lib/chatgpt/ChatGptCompletionMessageUtil.js.map +0 -1
- package/lib/chatgpt/ChatGptDescribeFunctionAgent.js.map +0 -1
- package/lib/chatgpt/ChatGptHistoryDecoder.js.map +0 -1
- package/lib/chatgpt/ChatGptInitializeFunctionAgent.js.map +0 -1
- package/lib/chatgpt/ChatGptSelectFunctionAgent.js.map +0 -1
- package/lib/chatgpt/ChatGptUsageAggregator.d.ts +0 -9
- package/lib/chatgpt/ChatGptUsageAggregator.js.map +0 -1
- package/lib/context/AgenticaClassOperation.d.ts +0 -8
- package/lib/context/AgenticaClassOperation.js +0 -11
- package/lib/context/AgenticaClassOperation.js.map +0 -1
- package/lib/context/AgenticaHttpOperation.d.ts +0 -8
- package/lib/context/AgenticaHttpOperation.js +0 -11
- package/lib/context/AgenticaHttpOperation.js.map +0 -1
- package/lib/context/AgenticaOperationBase.d.ts +0 -29
- package/lib/context/AgenticaOperationBase.js +0 -21
- package/lib/context/AgenticaOperationBase.js.map +0 -1
- package/src/context/AgenticaClassOperation.ts +0 -23
- package/src/context/AgenticaHttpOperation.ts +0 -27
- package/src/context/AgenticaOperationBase.ts +0 -57
- package/lib/{chatgpt → orchestrate}/ChatGptAgent.d.ts +0 -0
- package/lib/{chatgpt → orchestrate}/ChatGptAgent.js +0 -0
- package/src/{chatgpt → orchestrate}/ChatGptAgent.ts +1 -1
package/lib/index.mjs
CHANGED
|
@@ -10,171 +10,6 @@ import * as __typia_transform__assertGuard from "typia/lib/internal/_assertGuard
|
|
|
10
10
|
|
|
11
11
|
import * as __typia_transform__accessExpressionAsString from "typia/lib/internal/_accessExpressionAsString.js";
|
|
12
12
|
|
|
13
|
-
class AgenticaPromptBase {
|
|
14
|
-
constructor(type) {
|
|
15
|
-
this.type = type;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
let AgenticaCancelPrompt$1 = class AgenticaCancelPrompt extends AgenticaPromptBase {
|
|
20
|
-
constructor(props) {
|
|
21
|
-
super("cancel");
|
|
22
|
-
this.id = props.id;
|
|
23
|
-
this.selections = props.selections;
|
|
24
|
-
}
|
|
25
|
-
toJSON() {
|
|
26
|
-
return {
|
|
27
|
-
type: this.type,
|
|
28
|
-
id: this.id,
|
|
29
|
-
selections: this.selections.map((s => s.toJSON()))
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
class AgenticaOperationSelection {
|
|
35
|
-
constructor(props) {
|
|
36
|
-
this.operation = props.operation;
|
|
37
|
-
this.reason = props.reason;
|
|
38
|
-
}
|
|
39
|
-
toJSON() {
|
|
40
|
-
return {
|
|
41
|
-
operation: this.operation.toJSON(),
|
|
42
|
-
reason: this.reason
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
class AgenticaEventBase {
|
|
48
|
-
constructor(type) {
|
|
49
|
-
this.type = type;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
class AgenticaCallEvent extends AgenticaEventBase {
|
|
54
|
-
constructor(props) {
|
|
55
|
-
super("call");
|
|
56
|
-
this.id = props.id;
|
|
57
|
-
this.operation = props.operation;
|
|
58
|
-
this.arguments = props.arguments;
|
|
59
|
-
}
|
|
60
|
-
toJSON() {
|
|
61
|
-
return {
|
|
62
|
-
type: "call",
|
|
63
|
-
id: this.id,
|
|
64
|
-
operation: this.operation.toJSON(),
|
|
65
|
-
arguments: this.arguments
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
class AgenticaCancelEvent extends AgenticaEventBase {
|
|
71
|
-
constructor(props) {
|
|
72
|
-
super("cancel");
|
|
73
|
-
this.selection = props.selection;
|
|
74
|
-
}
|
|
75
|
-
toJSON() {
|
|
76
|
-
return {
|
|
77
|
-
type: "cancel",
|
|
78
|
-
selection: this.selection.toJSON()
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
class AgenticaExecutePrompt extends AgenticaPromptBase {
|
|
84
|
-
constructor(props) {
|
|
85
|
-
super("execute");
|
|
86
|
-
this.id = props.id;
|
|
87
|
-
this.operation = props.operation;
|
|
88
|
-
this.arguments = props.arguments;
|
|
89
|
-
this.value = props.value;
|
|
90
|
-
}
|
|
91
|
-
toJSON() {
|
|
92
|
-
return {
|
|
93
|
-
type: this.type,
|
|
94
|
-
id: this.id,
|
|
95
|
-
operation: this.operation.toJSON(),
|
|
96
|
-
arguments: this.arguments,
|
|
97
|
-
value: this.value
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
class AgenticaExecuteEvent extends AgenticaEventBase {
|
|
103
|
-
constructor(props) {
|
|
104
|
-
super("execute");
|
|
105
|
-
this.id = props.id;
|
|
106
|
-
this.operation = props.operation;
|
|
107
|
-
this.arguments = props.arguments;
|
|
108
|
-
this.value = props.value;
|
|
109
|
-
}
|
|
110
|
-
toJSON() {
|
|
111
|
-
return {
|
|
112
|
-
type: "execute",
|
|
113
|
-
id: this.id,
|
|
114
|
-
operation: this.operation.toJSON(),
|
|
115
|
-
arguments: this.arguments,
|
|
116
|
-
value: this.value
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
toPrompt() {
|
|
120
|
-
return new AgenticaExecutePrompt({
|
|
121
|
-
id: this.id,
|
|
122
|
-
operation: this.operation,
|
|
123
|
-
arguments: this.arguments,
|
|
124
|
-
value: this.value
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
class AgenticaTextPrompt extends AgenticaPromptBase {
|
|
130
|
-
constructor(props) {
|
|
131
|
-
super("text");
|
|
132
|
-
this.role = props.role;
|
|
133
|
-
this.text = props.text;
|
|
134
|
-
}
|
|
135
|
-
toJSON() {
|
|
136
|
-
return {
|
|
137
|
-
type: this.type,
|
|
138
|
-
role: this.role,
|
|
139
|
-
text: this.text
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
class AgenticaTextEvent extends AgenticaEventBase {
|
|
145
|
-
get text() {
|
|
146
|
-
return this.get_();
|
|
147
|
-
}
|
|
148
|
-
get done() {
|
|
149
|
-
return this.done_();
|
|
150
|
-
}
|
|
151
|
-
constructor(props) {
|
|
152
|
-
super("text");
|
|
153
|
-
this.role = props.role;
|
|
154
|
-
this.stream = props.stream;
|
|
155
|
-
this.done_ = props.done;
|
|
156
|
-
this.get_ = props.get;
|
|
157
|
-
this.join_ = props.join;
|
|
158
|
-
}
|
|
159
|
-
async join() {
|
|
160
|
-
return this.join_();
|
|
161
|
-
}
|
|
162
|
-
toJSON() {
|
|
163
|
-
return {
|
|
164
|
-
type: "text",
|
|
165
|
-
role: this.role,
|
|
166
|
-
text: this.text,
|
|
167
|
-
done: this.done
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
toPrompt() {
|
|
171
|
-
return new AgenticaTextPrompt({
|
|
172
|
-
role: this.role,
|
|
173
|
-
text: this.text
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
13
|
var AgenticaConstant;
|
|
179
14
|
|
|
180
15
|
(function(AgenticaConstant) {
|
|
@@ -940,6 +775,243 @@ const ChatGptHistoryDecoder = {
|
|
|
940
775
|
decode
|
|
941
776
|
};
|
|
942
777
|
|
|
778
|
+
function createTextPrompt(props) {
|
|
779
|
+
const prompt = {
|
|
780
|
+
type: "text",
|
|
781
|
+
role: props.role,
|
|
782
|
+
text: props.text
|
|
783
|
+
};
|
|
784
|
+
return {
|
|
785
|
+
...prompt,
|
|
786
|
+
toJSON: () => prompt
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
function createDescribePrompt(props) {
|
|
791
|
+
return {
|
|
792
|
+
type: "describe",
|
|
793
|
+
text: props.text,
|
|
794
|
+
executes: props.executes,
|
|
795
|
+
toJSON: () => ({
|
|
796
|
+
type: "describe",
|
|
797
|
+
text: props.text,
|
|
798
|
+
executes: props.executes.map((execute => execute.toJSON()))
|
|
799
|
+
})
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
function createSelectPrompt(props) {
|
|
804
|
+
return {
|
|
805
|
+
type: "select",
|
|
806
|
+
id: props.id,
|
|
807
|
+
selections: props.selections,
|
|
808
|
+
toJSON: () => ({
|
|
809
|
+
type: "select",
|
|
810
|
+
id: props.id,
|
|
811
|
+
selections: props.selections.map((selection => selection.toJSON()))
|
|
812
|
+
})
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
function createCancelPrompt(props) {
|
|
817
|
+
return {
|
|
818
|
+
type: "cancel",
|
|
819
|
+
id: props.id,
|
|
820
|
+
selections: props.selections,
|
|
821
|
+
toJSON: () => ({
|
|
822
|
+
type: "cancel",
|
|
823
|
+
id: props.id,
|
|
824
|
+
selections: props.selections.map((selection => selection.toJSON()))
|
|
825
|
+
})
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
function createExecutePrompt(props) {
|
|
830
|
+
return {
|
|
831
|
+
type: "execute",
|
|
832
|
+
protocol: props.operation.protocol,
|
|
833
|
+
id: props.id,
|
|
834
|
+
operation: props.operation,
|
|
835
|
+
arguments: props.arguments,
|
|
836
|
+
value: props.value,
|
|
837
|
+
toJSON: () => ({
|
|
838
|
+
type: "execute",
|
|
839
|
+
protocol: props.operation.protocol,
|
|
840
|
+
id: props.id,
|
|
841
|
+
operation: props.operation.toJSON(),
|
|
842
|
+
arguments: props.arguments,
|
|
843
|
+
value: props.value
|
|
844
|
+
})
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
function createInitializeEvent() {
|
|
849
|
+
const event = {
|
|
850
|
+
type: "initialize"
|
|
851
|
+
};
|
|
852
|
+
return {
|
|
853
|
+
type: event.type,
|
|
854
|
+
toJSON: () => event
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
function createSelectEvent(props) {
|
|
859
|
+
return {
|
|
860
|
+
type: "select",
|
|
861
|
+
selection: props.selection,
|
|
862
|
+
toJSON: () => ({
|
|
863
|
+
type: "select",
|
|
864
|
+
selection: props.selection.toJSON()
|
|
865
|
+
}),
|
|
866
|
+
toPrompt: () => createSelectPrompt({
|
|
867
|
+
id: v4(),
|
|
868
|
+
selections: [ props.selection ]
|
|
869
|
+
})
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
function createCancelEvent(props) {
|
|
874
|
+
return {
|
|
875
|
+
type: "cancel",
|
|
876
|
+
selection: props.selection,
|
|
877
|
+
toJSON: () => ({
|
|
878
|
+
type: "cancel",
|
|
879
|
+
selection: props.selection.toJSON()
|
|
880
|
+
})
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
function createCallEvent(props) {
|
|
885
|
+
return {
|
|
886
|
+
type: "call",
|
|
887
|
+
id: props.id,
|
|
888
|
+
operation: props.operation,
|
|
889
|
+
arguments: props.arguments,
|
|
890
|
+
toJSON: () => ({
|
|
891
|
+
type: "call",
|
|
892
|
+
id: props.id,
|
|
893
|
+
operation: props.operation.toJSON(),
|
|
894
|
+
arguments: props.arguments
|
|
895
|
+
})
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
function createValidateEvent(props) {
|
|
900
|
+
return {
|
|
901
|
+
type: "validate",
|
|
902
|
+
id: props.id,
|
|
903
|
+
operation: props.operation,
|
|
904
|
+
result: props.result,
|
|
905
|
+
toJSON: () => ({
|
|
906
|
+
type: "validate",
|
|
907
|
+
id: props.id,
|
|
908
|
+
operation: props.operation.toJSON(),
|
|
909
|
+
result: props.result
|
|
910
|
+
})
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
function createExecuteEvent(props) {
|
|
915
|
+
return {
|
|
916
|
+
type: "execute",
|
|
917
|
+
protocol: props.operation.protocol,
|
|
918
|
+
id: props.id,
|
|
919
|
+
operation: props.operation,
|
|
920
|
+
arguments: props.arguments,
|
|
921
|
+
value: props.value,
|
|
922
|
+
toJSON: () => ({
|
|
923
|
+
type: "execute",
|
|
924
|
+
protocol: props.operation.protocol,
|
|
925
|
+
id: props.id,
|
|
926
|
+
operation: props.operation.toJSON(),
|
|
927
|
+
arguments: props.arguments,
|
|
928
|
+
value: props.value
|
|
929
|
+
}),
|
|
930
|
+
toPrompt: () => createExecutePrompt(props)
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
function createTextEvent(props) {
|
|
935
|
+
return {
|
|
936
|
+
type: "text",
|
|
937
|
+
role: props.role,
|
|
938
|
+
stream: props.stream,
|
|
939
|
+
join: props.join,
|
|
940
|
+
toJSON: () => ({
|
|
941
|
+
type: "text",
|
|
942
|
+
role: props.role,
|
|
943
|
+
done: props.done(),
|
|
944
|
+
text: props.get()
|
|
945
|
+
}),
|
|
946
|
+
toPrompt: () => ({
|
|
947
|
+
type: "text",
|
|
948
|
+
role: props.role,
|
|
949
|
+
text: props.get(),
|
|
950
|
+
toJSON: () => ({
|
|
951
|
+
type: "text",
|
|
952
|
+
role: props.role,
|
|
953
|
+
text: props.get()
|
|
954
|
+
})
|
|
955
|
+
})
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
function createDescribeEvent(props) {
|
|
960
|
+
return {
|
|
961
|
+
type: "describe",
|
|
962
|
+
executes: props.executes,
|
|
963
|
+
stream: props.stream,
|
|
964
|
+
join: props.join,
|
|
965
|
+
toJSON: () => ({
|
|
966
|
+
type: "describe",
|
|
967
|
+
executes: props.executes.map((execute => execute.toJSON())),
|
|
968
|
+
done: props.done(),
|
|
969
|
+
text: props.get()
|
|
970
|
+
}),
|
|
971
|
+
toPrompt: () => ({
|
|
972
|
+
type: "describe",
|
|
973
|
+
executes: props.executes,
|
|
974
|
+
text: props.get(),
|
|
975
|
+
toJSON: () => ({
|
|
976
|
+
type: "describe",
|
|
977
|
+
executes: props.executes.map((execute => execute.toJSON())),
|
|
978
|
+
text: props.get()
|
|
979
|
+
})
|
|
980
|
+
})
|
|
981
|
+
};
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
function createRequestEvent(props) {
|
|
985
|
+
return {
|
|
986
|
+
type: "request",
|
|
987
|
+
source: props.source,
|
|
988
|
+
body: props.body,
|
|
989
|
+
options: props.options
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
function createResponseEvent(props) {
|
|
994
|
+
return {
|
|
995
|
+
type: "response",
|
|
996
|
+
source: props.source,
|
|
997
|
+
body: props.body,
|
|
998
|
+
options: props.options,
|
|
999
|
+
stream: props.stream,
|
|
1000
|
+
join: props.join
|
|
1001
|
+
};
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
function createOperationSelection(props) {
|
|
1005
|
+
return {
|
|
1006
|
+
operation: props.operation,
|
|
1007
|
+
reason: props.reason,
|
|
1008
|
+
toJSON: () => ({
|
|
1009
|
+
operation: props.operation.toJSON(),
|
|
1010
|
+
reason: props.reason
|
|
1011
|
+
})
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
|
|
943
1015
|
const CONTAINER$1 = {
|
|
944
1016
|
functions: [ {
|
|
945
1017
|
name: "cancelFunctions",
|
|
@@ -1057,7 +1129,7 @@ async function execute$4(ctx) {
|
|
|
1057
1129
|
} else if ((ctx.config?.eliticism ?? AgenticaConstant.ELITICISM) === true) {
|
|
1058
1130
|
return step$1(ctx, stacks.flat().map((s => ctx.operations.group.get(s.operation.controller.name).get(s.operation.function.name))), 0);
|
|
1059
1131
|
}
|
|
1060
|
-
const collection =
|
|
1132
|
+
const collection = createCancelPrompt({
|
|
1061
1133
|
id: v4(),
|
|
1062
1134
|
selections: []
|
|
1063
1135
|
});
|
|
@@ -1080,8 +1152,8 @@ async function cancelFunction(ctx, reference) {
|
|
|
1080
1152
|
}
|
|
1081
1153
|
const item = ctx.stack[index];
|
|
1082
1154
|
ctx.stack.splice(index, 1);
|
|
1083
|
-
await ctx.dispatch(
|
|
1084
|
-
selection:
|
|
1155
|
+
await ctx.dispatch(createCancelEvent({
|
|
1156
|
+
selection: createOperationSelection({
|
|
1085
1157
|
operation: item.operation,
|
|
1086
1158
|
reason: reference.reason
|
|
1087
1159
|
})
|
|
@@ -1240,7 +1312,7 @@ async function step$1(ctx, operations, retry, failures) {
|
|
|
1240
1312
|
if (input === null) {
|
|
1241
1313
|
continue;
|
|
1242
1314
|
}
|
|
1243
|
-
const collection =
|
|
1315
|
+
const collection = createCancelPrompt({
|
|
1244
1316
|
id: tc.id,
|
|
1245
1317
|
selections: []
|
|
1246
1318
|
});
|
|
@@ -1325,7 +1397,7 @@ async function execute$3(ctx) {
|
|
|
1325
1397
|
continue;
|
|
1326
1398
|
}
|
|
1327
1399
|
closures.push((async () => {
|
|
1328
|
-
const call =
|
|
1400
|
+
const call = createCallEvent({
|
|
1329
1401
|
id: tc.id,
|
|
1330
1402
|
operation,
|
|
1331
1403
|
arguments: JSON.parse(tc.function.arguments)
|
|
@@ -1338,7 +1410,7 @@ async function execute$3(ctx) {
|
|
|
1338
1410
|
}
|
|
1339
1411
|
await ctx.dispatch(call);
|
|
1340
1412
|
const execute = await propagate(ctx, call, 0);
|
|
1341
|
-
|
|
1413
|
+
void ctx.dispatch(createExecuteEvent({
|
|
1342
1414
|
id: call.id,
|
|
1343
1415
|
operation: call.operation,
|
|
1344
1416
|
arguments: execute.arguments,
|
|
@@ -1348,15 +1420,15 @@ async function execute$3(ctx) {
|
|
|
1348
1420
|
name: call.operation.name,
|
|
1349
1421
|
reason: "completed"
|
|
1350
1422
|
});
|
|
1351
|
-
|
|
1352
|
-
selection:
|
|
1423
|
+
void ctx.dispatch(createCancelEvent({
|
|
1424
|
+
selection: createOperationSelection({
|
|
1353
1425
|
operation: call.operation,
|
|
1354
1426
|
reason: "complete"
|
|
1355
1427
|
})
|
|
1356
1428
|
}));
|
|
1357
|
-
return [ execute,
|
|
1429
|
+
return [ execute, createCancelPrompt({
|
|
1358
1430
|
id: call.id,
|
|
1359
|
-
selections: [
|
|
1431
|
+
selections: [ createOperationSelection({
|
|
1360
1432
|
operation: call.operation,
|
|
1361
1433
|
reason: "complete"
|
|
1362
1434
|
}) ]
|
|
@@ -1366,11 +1438,11 @@ async function execute$3(ctx) {
|
|
|
1366
1438
|
}
|
|
1367
1439
|
if (choice.message.role === "assistant" && choice.message.content !== null && choice.message.content.length > 0) {
|
|
1368
1440
|
closures.push((async () => {
|
|
1369
|
-
const value =
|
|
1441
|
+
const value = createTextPrompt({
|
|
1370
1442
|
role: "assistant",
|
|
1371
1443
|
text: choice.message.content
|
|
1372
1444
|
});
|
|
1373
|
-
|
|
1445
|
+
void ctx.dispatch(createTextEvent({
|
|
1374
1446
|
role: "assistant",
|
|
1375
1447
|
get: () => value.text,
|
|
1376
1448
|
done: () => true,
|
|
@@ -1387,23 +1459,30 @@ async function execute$3(ctx) {
|
|
|
1387
1459
|
async function propagate(ctx, call, retry) {
|
|
1388
1460
|
if (call.operation.protocol === "http") {
|
|
1389
1461
|
const check = call.operation.function.validate(call.arguments);
|
|
1390
|
-
if (check.success === false
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1462
|
+
if (check.success === false) {
|
|
1463
|
+
void ctx.dispatch(createValidateEvent({
|
|
1464
|
+
id: call.id,
|
|
1465
|
+
operation: call.operation,
|
|
1466
|
+
result: check
|
|
1467
|
+
}));
|
|
1468
|
+
if (retry++ < (ctx.config?.retry ?? AgenticaConstant.RETRY)) {
|
|
1469
|
+
const trial = await correct(ctx, call, retry, check.errors);
|
|
1470
|
+
if (trial !== null) {
|
|
1471
|
+
return trial;
|
|
1472
|
+
}
|
|
1394
1473
|
}
|
|
1395
1474
|
}
|
|
1396
1475
|
try {
|
|
1397
1476
|
const response = await executeHttpOperation(call.operation, call.arguments);
|
|
1398
1477
|
const success = ((response.status === 400 || response.status === 404 || response.status === 422) && retry++ < (ctx.config?.retry ?? AgenticaConstant.RETRY) && typeof response.body) === false;
|
|
1399
|
-
return (success === false ? await correct(ctx, call, retry, response.body) : null) ??
|
|
1478
|
+
return (success === false ? await correct(ctx, call, retry, response.body) : null) ?? createExecutePrompt({
|
|
1400
1479
|
operation: call.operation,
|
|
1401
1480
|
id: call.id,
|
|
1402
1481
|
arguments: call.arguments,
|
|
1403
1482
|
value: response
|
|
1404
1483
|
});
|
|
1405
1484
|
} catch (error) {
|
|
1406
|
-
return
|
|
1485
|
+
return createExecutePrompt({
|
|
1407
1486
|
operation: call.operation,
|
|
1408
1487
|
id: call.id,
|
|
1409
1488
|
arguments: call.arguments,
|
|
@@ -1421,7 +1500,12 @@ async function propagate(ctx, call, retry) {
|
|
|
1421
1500
|
} else {
|
|
1422
1501
|
const check = call.operation.function.validate(call.arguments);
|
|
1423
1502
|
if (check.success === false) {
|
|
1424
|
-
|
|
1503
|
+
void ctx.dispatch(createValidateEvent({
|
|
1504
|
+
id: call.id,
|
|
1505
|
+
operation: call.operation,
|
|
1506
|
+
result: check
|
|
1507
|
+
}));
|
|
1508
|
+
return (retry++ < (ctx.config?.retry ?? AgenticaConstant.RETRY) ? await correct(ctx, call, retry, check.errors) : null) ?? createExecutePrompt({
|
|
1425
1509
|
id: call.id,
|
|
1426
1510
|
operation: call.operation,
|
|
1427
1511
|
arguments: call.arguments,
|
|
@@ -1434,14 +1518,14 @@ async function propagate(ctx, call, retry) {
|
|
|
1434
1518
|
}
|
|
1435
1519
|
try {
|
|
1436
1520
|
const value = await executeClassOperation(call.operation, call.arguments);
|
|
1437
|
-
return
|
|
1521
|
+
return createExecutePrompt({
|
|
1438
1522
|
id: call.id,
|
|
1439
1523
|
operation: call.operation,
|
|
1440
1524
|
arguments: call.arguments,
|
|
1441
1525
|
value
|
|
1442
1526
|
});
|
|
1443
1527
|
} catch (error) {
|
|
1444
|
-
return
|
|
1528
|
+
return createExecutePrompt({
|
|
1445
1529
|
id: call.id,
|
|
1446
1530
|
operation: call.operation,
|
|
1447
1531
|
arguments: call.arguments,
|
|
@@ -1534,7 +1618,7 @@ async function correct(ctx, call, retry, error) {
|
|
|
1534
1618
|
if (toolCall === undefined) {
|
|
1535
1619
|
return null;
|
|
1536
1620
|
}
|
|
1537
|
-
return propagate(ctx,
|
|
1621
|
+
return propagate(ctx, createCallEvent({
|
|
1538
1622
|
id: toolCall.id,
|
|
1539
1623
|
operation: call.operation,
|
|
1540
1624
|
arguments: JSON.parse(toolCall.function.arguments)
|
|
@@ -1562,55 +1646,6 @@ const ChatGptCallFunctionAgent = {
|
|
|
1562
1646
|
execute: execute$3
|
|
1563
1647
|
};
|
|
1564
1648
|
|
|
1565
|
-
class AgenticaDescribePrompt extends AgenticaPromptBase {
|
|
1566
|
-
constructor(props) {
|
|
1567
|
-
super("describe");
|
|
1568
|
-
this.executes = props.executes;
|
|
1569
|
-
this.text = props.text;
|
|
1570
|
-
}
|
|
1571
|
-
toJSON() {
|
|
1572
|
-
return {
|
|
1573
|
-
type: this.type,
|
|
1574
|
-
executes: this.executes.map((e => e.toJSON())),
|
|
1575
|
-
text: this.text
|
|
1576
|
-
};
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
|
-
|
|
1580
|
-
class AgenticaDescribeEvent extends AgenticaEventBase {
|
|
1581
|
-
get text() {
|
|
1582
|
-
return this.get_();
|
|
1583
|
-
}
|
|
1584
|
-
get done() {
|
|
1585
|
-
return this.done_();
|
|
1586
|
-
}
|
|
1587
|
-
constructor(props) {
|
|
1588
|
-
super("describe");
|
|
1589
|
-
this.stream = props.stream;
|
|
1590
|
-
this.executes = props.executes;
|
|
1591
|
-
this.done_ = props.done;
|
|
1592
|
-
this.get_ = props.get;
|
|
1593
|
-
this.join_ = props.join;
|
|
1594
|
-
}
|
|
1595
|
-
async join() {
|
|
1596
|
-
return this.join_();
|
|
1597
|
-
}
|
|
1598
|
-
toJSON() {
|
|
1599
|
-
return {
|
|
1600
|
-
type: "describe",
|
|
1601
|
-
executes: this.executes.map((e => e.toJSON())),
|
|
1602
|
-
text: this.text,
|
|
1603
|
-
done: this.done
|
|
1604
|
-
};
|
|
1605
|
-
}
|
|
1606
|
-
toPrompt() {
|
|
1607
|
-
return new AgenticaDescribePrompt({
|
|
1608
|
-
executes: this.executes,
|
|
1609
|
-
text: this.text
|
|
1610
|
-
});
|
|
1611
|
-
}
|
|
1612
|
-
}
|
|
1613
|
-
|
|
1614
1649
|
class AsyncQueue {
|
|
1615
1650
|
constructor() {
|
|
1616
1651
|
this.queue = [];
|
|
@@ -1751,7 +1786,7 @@ async function execute$2(ctx, histories) {
|
|
|
1751
1786
|
mpsc
|
|
1752
1787
|
};
|
|
1753
1788
|
mpsc.produce(choice.delta.content);
|
|
1754
|
-
void ctx.dispatch(
|
|
1789
|
+
void ctx.dispatch(createDescribeEvent({
|
|
1755
1790
|
executes: histories,
|
|
1756
1791
|
stream: mpsc.consumer,
|
|
1757
1792
|
done: () => mpsc.done(),
|
|
@@ -1773,7 +1808,7 @@ async function execute$2(ctx, histories) {
|
|
|
1773
1808
|
if (completion == null) {
|
|
1774
1809
|
throw new Error("No completion received");
|
|
1775
1810
|
}
|
|
1776
|
-
const descriptions = completion.choices.map((choice => choice.message.role === "assistant" ? choice.message.content : null)).filter((str => str !== null)).map((content =>
|
|
1811
|
+
const descriptions = completion.choices.map((choice => choice.message.role === "assistant" ? choice.message.content : null)).filter((str => str !== null)).map((content => createDescribePrompt({
|
|
1777
1812
|
executes: histories,
|
|
1778
1813
|
text: content
|
|
1779
1814
|
})));
|
|
@@ -3468,7 +3503,7 @@ async function execute$1(ctx) {
|
|
|
3468
3503
|
mpsc
|
|
3469
3504
|
};
|
|
3470
3505
|
mpsc.produce(choice.delta.content);
|
|
3471
|
-
void ctx.dispatch(
|
|
3506
|
+
void ctx.dispatch(createTextEvent({
|
|
3472
3507
|
role: "assistant",
|
|
3473
3508
|
stream: mpsc.consumer,
|
|
3474
3509
|
done: () => mpsc.done(),
|
|
@@ -3493,7 +3528,7 @@ async function execute$1(ctx) {
|
|
|
3493
3528
|
const prompts = [];
|
|
3494
3529
|
for (const choice of completion.choices) {
|
|
3495
3530
|
if (choice.message.role === "assistant" && choice.message.content != null) {
|
|
3496
|
-
prompts.push(
|
|
3531
|
+
prompts.push(createTextPrompt({
|
|
3497
3532
|
role: "assistant",
|
|
3498
3533
|
text: choice.message.content
|
|
3499
3534
|
}));
|
|
@@ -3509,40 +3544,6 @@ const ChatGptInitializeFunctionAgent = {
|
|
|
3509
3544
|
execute: execute$1
|
|
3510
3545
|
};
|
|
3511
3546
|
|
|
3512
|
-
class AgenticaSelectPrompt extends AgenticaPromptBase {
|
|
3513
|
-
constructor(props) {
|
|
3514
|
-
super("select");
|
|
3515
|
-
this.id = props.id;
|
|
3516
|
-
this.selections = props.selections;
|
|
3517
|
-
}
|
|
3518
|
-
toJSON() {
|
|
3519
|
-
return {
|
|
3520
|
-
type: this.type,
|
|
3521
|
-
id: this.id,
|
|
3522
|
-
selections: this.selections.map((s => s.toJSON()))
|
|
3523
|
-
};
|
|
3524
|
-
}
|
|
3525
|
-
}
|
|
3526
|
-
|
|
3527
|
-
class AgenticaSelectEvent extends AgenticaEventBase {
|
|
3528
|
-
constructor(props) {
|
|
3529
|
-
super("select");
|
|
3530
|
-
this.selection = props.selection;
|
|
3531
|
-
}
|
|
3532
|
-
toJSON() {
|
|
3533
|
-
return {
|
|
3534
|
-
type: "select",
|
|
3535
|
-
selection: this.selection.toJSON()
|
|
3536
|
-
};
|
|
3537
|
-
}
|
|
3538
|
-
toPrompt() {
|
|
3539
|
-
return new AgenticaSelectPrompt({
|
|
3540
|
-
id: v4(),
|
|
3541
|
-
selections: [ this.selection ]
|
|
3542
|
-
});
|
|
3543
|
-
}
|
|
3544
|
-
}
|
|
3545
|
-
|
|
3546
3547
|
const CONTAINER = {
|
|
3547
3548
|
functions: [ {
|
|
3548
3549
|
name: "selectFunctions",
|
|
@@ -3660,7 +3661,7 @@ async function execute(ctx) {
|
|
|
3660
3661
|
} else if ((ctx.config?.eliticism ?? AgenticaConstant.ELITICISM) === true) {
|
|
3661
3662
|
return step(ctx, stacks.flat().map((s => ctx.operations.group.get(s.operation.controller.name).get(s.operation.function.name))), 0);
|
|
3662
3663
|
}
|
|
3663
|
-
const collection =
|
|
3664
|
+
const collection = createSelectPrompt({
|
|
3664
3665
|
id: v4(),
|
|
3665
3666
|
selections: []
|
|
3666
3667
|
});
|
|
@@ -3827,7 +3828,7 @@ async function step(ctx, operations, retry, failures) {
|
|
|
3827
3828
|
if (input === null) {
|
|
3828
3829
|
continue;
|
|
3829
3830
|
}
|
|
3830
|
-
const collection =
|
|
3831
|
+
const collection = createSelectPrompt({
|
|
3831
3832
|
id: tc.id,
|
|
3832
3833
|
selections: []
|
|
3833
3834
|
});
|
|
@@ -3836,7 +3837,7 @@ async function step(ctx, operations, retry, failures) {
|
|
|
3836
3837
|
if (operation === null) {
|
|
3837
3838
|
continue;
|
|
3838
3839
|
}
|
|
3839
|
-
collection.selections.push(
|
|
3840
|
+
collection.selections.push(createOperationSelection({
|
|
3840
3841
|
operation,
|
|
3841
3842
|
reason: reference.reason
|
|
3842
3843
|
}));
|
|
@@ -3847,12 +3848,12 @@ async function step(ctx, operations, retry, failures) {
|
|
|
3847
3848
|
}
|
|
3848
3849
|
}
|
|
3849
3850
|
if (choice.message.role === "assistant" && choice.message.content != null) {
|
|
3850
|
-
const text =
|
|
3851
|
+
const text = createTextPrompt({
|
|
3851
3852
|
role: "assistant",
|
|
3852
3853
|
text: choice.message.content
|
|
3853
3854
|
});
|
|
3854
3855
|
prompts.push(text);
|
|
3855
|
-
await ctx.dispatch(
|
|
3856
|
+
await ctx.dispatch(createTextEvent({
|
|
3856
3857
|
role: "assistant",
|
|
3857
3858
|
stream: StreamUtil.to(text.text),
|
|
3858
3859
|
join: async () => Promise.resolve(text.text),
|
|
@@ -3869,12 +3870,12 @@ async function selectFunction(ctx, reference) {
|
|
|
3869
3870
|
if (operation === undefined) {
|
|
3870
3871
|
return null;
|
|
3871
3872
|
}
|
|
3872
|
-
const selection =
|
|
3873
|
+
const selection = createOperationSelection({
|
|
3873
3874
|
operation,
|
|
3874
3875
|
reason: reference.reason
|
|
3875
3876
|
});
|
|
3876
3877
|
ctx.stack.push(selection);
|
|
3877
|
-
void ctx.dispatch(
|
|
3878
|
+
void ctx.dispatch(createSelectEvent({
|
|
3878
3879
|
selection
|
|
3879
3880
|
}));
|
|
3880
3881
|
return operation;
|
|
@@ -3902,7 +3903,9 @@ function emendMessages(failures) {
|
|
|
3902
3903
|
}
|
|
3903
3904
|
|
|
3904
3905
|
const ChatGptSelectFunctionAgent = {
|
|
3905
|
-
execute
|
|
3906
|
+
execute,
|
|
3907
|
+
selectFunction,
|
|
3908
|
+
emendMessages
|
|
3906
3909
|
};
|
|
3907
3910
|
|
|
3908
3911
|
const ChatGptAgent = {
|
|
@@ -4063,34 +4066,6 @@ const AgenticaTokenUsageAggregator = {
|
|
|
4063
4066
|
aggregate
|
|
4064
4067
|
};
|
|
4065
4068
|
|
|
4066
|
-
class AgenticaInitializeEvent extends AgenticaEventBase {
|
|
4067
|
-
constructor() {
|
|
4068
|
-
super("initialize");
|
|
4069
|
-
}
|
|
4070
|
-
toJSON() {
|
|
4071
|
-
return {
|
|
4072
|
-
type: "initialize"
|
|
4073
|
-
};
|
|
4074
|
-
}
|
|
4075
|
-
}
|
|
4076
|
-
|
|
4077
|
-
class AgenticaRequestEvent extends AgenticaEventBase {
|
|
4078
|
-
constructor(props) {
|
|
4079
|
-
super("request");
|
|
4080
|
-
this.source = props.source;
|
|
4081
|
-
this.body = props.body;
|
|
4082
|
-
this.options = props.options;
|
|
4083
|
-
}
|
|
4084
|
-
toJSON() {
|
|
4085
|
-
return {
|
|
4086
|
-
type: "request",
|
|
4087
|
-
source: this.source,
|
|
4088
|
-
body: this.body,
|
|
4089
|
-
options: this.options
|
|
4090
|
-
};
|
|
4091
|
-
}
|
|
4092
|
-
}
|
|
4093
|
-
|
|
4094
4069
|
function __map_take(dict, key, generator) {
|
|
4095
4070
|
const oldbie = dict.get(key);
|
|
4096
4071
|
if (oldbie !== undefined) {
|
|
@@ -4161,21 +4136,6 @@ const AgenticaOperationComposer = {
|
|
|
4161
4136
|
compose
|
|
4162
4137
|
};
|
|
4163
4138
|
|
|
4164
|
-
class AgenticaCancelPrompt extends AgenticaPromptBase {
|
|
4165
|
-
constructor(props) {
|
|
4166
|
-
super("cancel");
|
|
4167
|
-
this.id = props.id;
|
|
4168
|
-
this.selections = props.selections;
|
|
4169
|
-
}
|
|
4170
|
-
toJSON() {
|
|
4171
|
-
return {
|
|
4172
|
-
type: this.type,
|
|
4173
|
-
id: this.id,
|
|
4174
|
-
selections: this.selections.map((s => s.toJSON()))
|
|
4175
|
-
};
|
|
4176
|
-
}
|
|
4177
|
-
}
|
|
4178
|
-
|
|
4179
4139
|
function transform(props) {
|
|
4180
4140
|
if (props.prompt.type === "text") {
|
|
4181
4141
|
return transformText({
|
|
@@ -4206,13 +4166,13 @@ function transform(props) {
|
|
|
4206
4166
|
}
|
|
4207
4167
|
|
|
4208
4168
|
function transformText(props) {
|
|
4209
|
-
return
|
|
4169
|
+
return createTextPrompt(props.prompt);
|
|
4210
4170
|
}
|
|
4211
4171
|
|
|
4212
4172
|
function transformSelect(props) {
|
|
4213
|
-
return
|
|
4173
|
+
return createSelectPrompt({
|
|
4214
4174
|
id: props.prompt.id,
|
|
4215
|
-
selections: props.prompt.selections.map((select =>
|
|
4175
|
+
selections: props.prompt.selections.map((select => createOperationSelection({
|
|
4216
4176
|
operation: findOperation({
|
|
4217
4177
|
operations: props.operations,
|
|
4218
4178
|
input: select.operation
|
|
@@ -4223,9 +4183,9 @@ function transformSelect(props) {
|
|
|
4223
4183
|
}
|
|
4224
4184
|
|
|
4225
4185
|
function transformCancel(props) {
|
|
4226
|
-
return
|
|
4186
|
+
return createCancelPrompt({
|
|
4227
4187
|
id: props.prompt.id,
|
|
4228
|
-
selections: props.prompt.selections.map((select =>
|
|
4188
|
+
selections: props.prompt.selections.map((select => createOperationSelection({
|
|
4229
4189
|
operation: findOperation({
|
|
4230
4190
|
operations: props.operations,
|
|
4231
4191
|
input: select.operation
|
|
@@ -4236,7 +4196,7 @@ function transformCancel(props) {
|
|
|
4236
4196
|
}
|
|
4237
4197
|
|
|
4238
4198
|
function transformExecute(props) {
|
|
4239
|
-
return
|
|
4199
|
+
return createExecutePrompt({
|
|
4240
4200
|
id: props.prompt.id,
|
|
4241
4201
|
operation: findOperation({
|
|
4242
4202
|
operations: props.operations,
|
|
@@ -4248,7 +4208,7 @@ function transformExecute(props) {
|
|
|
4248
4208
|
}
|
|
4249
4209
|
|
|
4250
4210
|
function transformDescribe(props) {
|
|
4251
|
-
return
|
|
4211
|
+
return createDescribePrompt({
|
|
4252
4212
|
text: props.prompt.text,
|
|
4253
4213
|
executes: props.prompt.executes.map((next => transformExecute({
|
|
4254
4214
|
operations: props.operations,
|
|
@@ -4298,11 +4258,11 @@ class Agentica {
|
|
|
4298
4258
|
});
|
|
4299
4259
|
}
|
|
4300
4260
|
async conversate(content) {
|
|
4301
|
-
const prompt =
|
|
4261
|
+
const prompt = createTextPrompt({
|
|
4302
4262
|
role: "user",
|
|
4303
4263
|
text: content
|
|
4304
4264
|
});
|
|
4305
|
-
await this.dispatch(
|
|
4265
|
+
await this.dispatch(createTextEvent({
|
|
4306
4266
|
role: "user",
|
|
4307
4267
|
stream: StreamUtil.to(content),
|
|
4308
4268
|
done: () => true,
|
|
@@ -4345,7 +4305,7 @@ class Agentica {
|
|
|
4345
4305
|
prompt: props.prompt,
|
|
4346
4306
|
dispatch: async event => this.dispatch(event),
|
|
4347
4307
|
request: async (source, body) => {
|
|
4348
|
-
const event =
|
|
4308
|
+
const event = createRequestEvent({
|
|
4349
4309
|
source,
|
|
4350
4310
|
body: {
|
|
4351
4311
|
...body,
|
|
@@ -4393,7 +4353,7 @@ class Agentica {
|
|
|
4393
4353
|
},
|
|
4394
4354
|
initialize: async () => {
|
|
4395
4355
|
this.ready_ = true;
|
|
4396
|
-
await dispatch(
|
|
4356
|
+
await dispatch(createInitializeEvent());
|
|
4397
4357
|
}
|
|
4398
4358
|
};
|
|
4399
4359
|
}
|
|
@@ -4423,16 +4383,25 @@ class Agentica {
|
|
|
4423
4383
|
}
|
|
4424
4384
|
}
|
|
4425
4385
|
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4386
|
+
var index$1 = Object.freeze({
|
|
4387
|
+
__proto__: null,
|
|
4388
|
+
createCallEvent,
|
|
4389
|
+
createCancelEvent,
|
|
4390
|
+
createCancelPrompt,
|
|
4391
|
+
createDescribeEvent,
|
|
4392
|
+
createDescribePrompt,
|
|
4393
|
+
createExecuteEvent,
|
|
4394
|
+
createExecutePrompt,
|
|
4395
|
+
createInitializeEvent,
|
|
4396
|
+
createOperationSelection,
|
|
4397
|
+
createRequestEvent,
|
|
4398
|
+
createResponseEvent,
|
|
4399
|
+
createSelectEvent,
|
|
4400
|
+
createSelectPrompt,
|
|
4401
|
+
createTextEvent,
|
|
4402
|
+
createTextPrompt,
|
|
4403
|
+
createValidateEvent
|
|
4404
|
+
});
|
|
4436
4405
|
|
|
4437
4406
|
function assertHttpLlmApplication(props) {
|
|
4438
4407
|
return HttpLlm.application({
|
|
@@ -21150,5 +21119,17 @@ function validateHttpLlmApplication(props) {
|
|
|
21150
21119
|
};
|
|
21151
21120
|
}
|
|
21152
21121
|
|
|
21153
|
-
|
|
21122
|
+
var index = Object.freeze({
|
|
21123
|
+
__proto__: null,
|
|
21124
|
+
ChatGptAgent,
|
|
21125
|
+
ChatGptCallFunctionAgent,
|
|
21126
|
+
ChatGptCancelFunctionAgent,
|
|
21127
|
+
ChatGptCompletionMessageUtil,
|
|
21128
|
+
ChatGptDescribeFunctionAgent,
|
|
21129
|
+
ChatGptHistoryDecoder,
|
|
21130
|
+
ChatGptInitializeFunctionAgent,
|
|
21131
|
+
ChatGptSelectFunctionAgent
|
|
21132
|
+
});
|
|
21133
|
+
|
|
21134
|
+
export { Agentica, AgenticaTokenUsage, assertHttpLlmApplication, index$1 as factory, index as orchestrate, validateHttpLlmApplication };
|
|
21154
21135
|
//# sourceMappingURL=index.mjs.map
|