@agentica/core 0.10.3 → 0.11.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.
Files changed (265) hide show
  1. package/README.md +2 -2
  2. package/lib/Agentica.d.ts +14 -14
  3. package/lib/Agentica.js +54 -29
  4. package/lib/Agentica.js.map +1 -1
  5. package/lib/chatgpt/ChatGptAgent.d.ts +3 -3
  6. package/lib/chatgpt/ChatGptAgent.js +1 -1
  7. package/lib/chatgpt/ChatGptAgent.js.map +1 -1
  8. package/lib/chatgpt/ChatGptCallFunctionAgent.d.ts +3 -3
  9. package/lib/chatgpt/ChatGptCallFunctionAgent.js +61 -63
  10. package/lib/chatgpt/ChatGptCallFunctionAgent.js.map +1 -1
  11. package/lib/chatgpt/ChatGptCancelFunctionAgent.d.ts +6 -6
  12. package/lib/chatgpt/ChatGptCancelFunctionAgent.js +28 -30
  13. package/lib/chatgpt/ChatGptCancelFunctionAgent.js.map +1 -1
  14. package/lib/chatgpt/ChatGptCompletionMessageUtil.d.ts +8 -0
  15. package/lib/chatgpt/ChatGptCompletionMessageUtil.js +536 -0
  16. package/lib/chatgpt/ChatGptCompletionMessageUtil.js.map +1 -0
  17. package/lib/chatgpt/ChatGptDescribeFunctionAgent.d.ts +4 -3
  18. package/lib/chatgpt/ChatGptDescribeFunctionAgent.js +56 -6
  19. package/lib/chatgpt/ChatGptDescribeFunctionAgent.js.map +1 -1
  20. package/lib/chatgpt/ChatGptHistoryDecoder.d.ts +2 -2
  21. package/lib/chatgpt/ChatGptHistoryDecoder.js +8 -8
  22. package/lib/chatgpt/ChatGptHistoryDecoder.js.map +1 -1
  23. package/lib/chatgpt/ChatGptInitializeFunctionAgent.d.ts +3 -3
  24. package/lib/chatgpt/ChatGptInitializeFunctionAgent.js +11 -5
  25. package/lib/chatgpt/ChatGptInitializeFunctionAgent.js.map +1 -1
  26. package/lib/chatgpt/ChatGptSelectFunctionAgent.d.ts +3 -3
  27. package/lib/chatgpt/ChatGptSelectFunctionAgent.js +39 -42
  28. package/lib/chatgpt/ChatGptSelectFunctionAgent.js.map +1 -1
  29. package/lib/chatgpt/ChatGptUsageAggregator.d.ts +6 -0
  30. package/lib/chatgpt/ChatGptUsageAggregator.js +48 -0
  31. package/lib/chatgpt/ChatGptUsageAggregator.js.map +1 -0
  32. package/lib/context/AgenticaCancelPrompt.d.ts +16 -0
  33. package/lib/context/AgenticaCancelPrompt.js +20 -0
  34. package/lib/context/AgenticaCancelPrompt.js.map +1 -0
  35. package/lib/context/AgenticaClassOperation.d.ts +8 -0
  36. package/lib/context/AgenticaClassOperation.js +11 -0
  37. package/lib/context/AgenticaClassOperation.js.map +1 -0
  38. package/lib/{structures/IAgenticaContext.d.ts → context/AgenticaContext.d.ts} +15 -14
  39. package/lib/{structures/IAgenticaPrompt.js → context/AgenticaContext.js} +1 -1
  40. package/lib/context/AgenticaContext.js.map +1 -0
  41. package/lib/context/AgenticaHttpOperation.d.ts +8 -0
  42. package/lib/context/AgenticaHttpOperation.js +11 -0
  43. package/lib/context/AgenticaHttpOperation.js.map +1 -0
  44. package/lib/context/AgenticaOperation.d.ts +46 -0
  45. package/lib/{structures/IAgenticaContext.js → context/AgenticaOperation.js} +1 -1
  46. package/lib/context/AgenticaOperation.js.map +1 -0
  47. package/lib/context/AgenticaOperationBase.d.ts +29 -0
  48. package/lib/context/AgenticaOperationBase.js +21 -0
  49. package/lib/context/AgenticaOperationBase.js.map +1 -0
  50. package/lib/{structures/IAgenticaOperationCollection.d.ts → context/AgenticaOperationCollection.d.ts} +6 -6
  51. package/lib/{structures/IAgenticaOperationSelection.js → context/AgenticaOperationCollection.js} +1 -1
  52. package/lib/context/AgenticaOperationCollection.js.map +1 -0
  53. package/lib/context/AgenticaOperationSelection.d.ts +15 -0
  54. package/lib/context/AgenticaOperationSelection.js +17 -0
  55. package/lib/context/AgenticaOperationSelection.js.map +1 -0
  56. package/lib/context/AgenticaTokenUsage.d.ts +82 -0
  57. package/lib/context/AgenticaTokenUsage.js +97 -0
  58. package/lib/context/AgenticaTokenUsage.js.map +1 -0
  59. package/lib/context/internal/AgenticaTokenUsageAggregator.d.ts +10 -0
  60. package/lib/context/internal/AgenticaTokenUsageAggregator.js +47 -0
  61. package/lib/context/internal/AgenticaTokenUsageAggregator.js.map +1 -0
  62. package/lib/context/internal/__IChatCancelFunctionsApplication.js.map +1 -0
  63. package/lib/context/internal/__IChatFunctionReference.js.map +1 -0
  64. package/lib/context/internal/__IChatInitialApplication.js.map +1 -0
  65. package/lib/context/internal/__IChatSelectFunctionsApplication.js.map +1 -0
  66. package/lib/events/AgenticaCallEvent.d.ts +18 -0
  67. package/lib/events/AgenticaCallEvent.js +22 -0
  68. package/lib/events/AgenticaCallEvent.js.map +1 -0
  69. package/lib/events/AgenticaCancelEvent.d.ts +14 -0
  70. package/lib/events/AgenticaCancelEvent.js +18 -0
  71. package/lib/events/AgenticaCancelEvent.js.map +1 -0
  72. package/lib/events/AgenticaDescribeEvent.d.ts +27 -0
  73. package/lib/events/AgenticaDescribeEvent.js +40 -0
  74. package/lib/events/AgenticaDescribeEvent.js.map +1 -0
  75. package/lib/events/AgenticaEvent.d.ts +25 -0
  76. package/lib/{structures/IAgenticaEvent.js → events/AgenticaEvent.js} +1 -1
  77. package/lib/events/AgenticaEvent.js.map +1 -0
  78. package/lib/events/AgenticaEventBase.d.ts +4 -0
  79. package/lib/events/AgenticaEventBase.js +10 -0
  80. package/lib/events/AgenticaEventBase.js.map +1 -0
  81. package/lib/events/AgenticaEventSource.d.ts +1 -0
  82. package/lib/events/AgenticaEventSource.js +3 -0
  83. package/lib/events/AgenticaEventSource.js.map +1 -0
  84. package/lib/events/AgenticaExecuteEvent.d.ts +22 -0
  85. package/lib/events/AgenticaExecuteEvent.js +33 -0
  86. package/lib/events/AgenticaExecuteEvent.js.map +1 -0
  87. package/lib/events/AgenticaInitializeEvent.d.ts +6 -0
  88. package/lib/events/AgenticaInitializeEvent.js +16 -0
  89. package/lib/events/AgenticaInitializeEvent.js.map +1 -0
  90. package/lib/events/AgenticaRequestEvent.d.ts +27 -0
  91. package/lib/events/AgenticaRequestEvent.js +22 -0
  92. package/lib/events/AgenticaRequestEvent.js.map +1 -0
  93. package/lib/events/AgenticaResponseEvent.d.ts +35 -0
  94. package/lib/events/AgenticaResponseEvent.js +16 -0
  95. package/lib/events/AgenticaResponseEvent.js.map +1 -0
  96. package/lib/events/AgenticaSelectEvent.d.ts +16 -0
  97. package/lib/events/AgenticaSelectEvent.js +26 -0
  98. package/lib/events/AgenticaSelectEvent.js.map +1 -0
  99. package/lib/events/AgenticaTextEvent.d.ts +25 -0
  100. package/lib/events/AgenticaTextEvent.js +40 -0
  101. package/lib/events/AgenticaTextEvent.js.map +1 -0
  102. package/lib/index.d.ts +26 -8
  103. package/lib/index.js +29 -9
  104. package/lib/index.js.map +1 -1
  105. package/lib/index.mjs +1391 -304
  106. package/lib/index.mjs.map +1 -1
  107. package/lib/internal/AgenticaOperationComposer.d.ts +2 -2
  108. package/lib/internal/AgenticaOperationComposer.js +12 -0
  109. package/lib/internal/AgenticaOperationComposer.js.map +1 -1
  110. package/lib/internal/ByteArrayUtil.d.ts +3 -0
  111. package/lib/internal/ByteArrayUtil.js +10 -0
  112. package/lib/internal/ByteArrayUtil.js.map +1 -0
  113. package/lib/internal/MPSCUtil.d.ts +21 -0
  114. package/lib/internal/MPSCUtil.js +84 -0
  115. package/lib/internal/MPSCUtil.js.map +1 -0
  116. package/lib/internal/StreamUtil.d.ts +6 -0
  117. package/lib/internal/StreamUtil.js +65 -0
  118. package/lib/internal/StreamUtil.js.map +1 -0
  119. package/lib/json/IAgenticaEventJson.d.ts +149 -0
  120. package/lib/{structures/IAgenticaOperation.js → json/IAgenticaEventJson.js} +1 -1
  121. package/lib/json/IAgenticaEventJson.js.map +1 -0
  122. package/lib/json/IAgenticaOperationJson.d.ts +33 -0
  123. package/lib/json/IAgenticaOperationJson.js +3 -0
  124. package/lib/json/IAgenticaOperationJson.js.map +1 -0
  125. package/lib/json/IAgenticaOperationSelectionJson.d.ts +18 -0
  126. package/lib/{structures/IAgenticaOperationCollection.js → json/IAgenticaOperationSelectionJson.js} +1 -1
  127. package/lib/json/IAgenticaOperationSelectionJson.js.map +1 -0
  128. package/lib/json/IAgenticaPromptJson.d.ts +111 -0
  129. package/lib/json/IAgenticaPromptJson.js +3 -0
  130. package/lib/json/IAgenticaPromptJson.js.map +1 -0
  131. package/lib/{structures/IAgenticaTokenUsage.d.ts → json/IAgenticaTokenUsageJson.d.ts} +10 -10
  132. package/lib/json/IAgenticaTokenUsageJson.js +3 -0
  133. package/lib/json/IAgenticaTokenUsageJson.js.map +1 -0
  134. package/lib/prompts/AgenticaCancelPrompt.d.ts +16 -0
  135. package/lib/prompts/AgenticaCancelPrompt.js +20 -0
  136. package/lib/prompts/AgenticaCancelPrompt.js.map +1 -0
  137. package/lib/prompts/AgenticaDescribePrompt.d.ts +24 -0
  138. package/lib/prompts/AgenticaDescribePrompt.js +20 -0
  139. package/lib/prompts/AgenticaDescribePrompt.js.map +1 -0
  140. package/lib/prompts/AgenticaExecutePrompt.d.ts +20 -0
  141. package/lib/prompts/AgenticaExecutePrompt.js +24 -0
  142. package/lib/prompts/AgenticaExecutePrompt.js.map +1 -0
  143. package/lib/prompts/AgenticaPrompt.d.ts +7 -0
  144. package/lib/{typings/AgenticaSource.js → prompts/AgenticaPrompt.js} +1 -1
  145. package/lib/prompts/AgenticaPrompt.js.map +1 -0
  146. package/lib/prompts/AgenticaPromptBase.d.ts +22 -0
  147. package/lib/prompts/AgenticaPromptBase.js +22 -0
  148. package/lib/prompts/AgenticaPromptBase.js.map +1 -0
  149. package/lib/prompts/AgenticaSelectPrompt.d.ts +16 -0
  150. package/lib/prompts/AgenticaSelectPrompt.js +20 -0
  151. package/lib/prompts/AgenticaSelectPrompt.js.map +1 -0
  152. package/lib/prompts/AgenticaTextPrompt.d.ts +14 -0
  153. package/lib/prompts/AgenticaTextPrompt.js +20 -0
  154. package/lib/prompts/AgenticaTextPrompt.js.map +1 -0
  155. package/lib/structures/IAgenticaConfig.d.ts +3 -3
  156. package/lib/structures/IAgenticaExecutor.d.ts +12 -11
  157. package/lib/structures/IAgenticaProps.d.ts +2 -3
  158. package/lib/structures/IAgenticaSystemPrompt.d.ts +12 -11
  159. package/lib/transformers/AgenticaEventTransformer.d.ts +45 -0
  160. package/lib/transformers/AgenticaEventTransformer.js +127 -0
  161. package/lib/transformers/AgenticaEventTransformer.js.map +1 -0
  162. package/lib/transformers/AgenticaPromptTransformer.d.ts +34 -0
  163. package/lib/transformers/AgenticaPromptTransformer.js +90 -0
  164. package/lib/transformers/AgenticaPromptTransformer.js.map +1 -0
  165. package/package.json +1 -1
  166. package/src/Agentica.ts +94 -61
  167. package/src/chatgpt/ChatGptAgent.ts +8 -7
  168. package/src/chatgpt/ChatGptCallFunctionAgent.ts +90 -88
  169. package/src/chatgpt/ChatGptCancelFunctionAgent.ts +51 -58
  170. package/src/chatgpt/ChatGptCompletionMessageUtil.ts +166 -0
  171. package/src/chatgpt/ChatGptDescribeFunctionAgent.ts +81 -12
  172. package/src/chatgpt/ChatGptHistoryDecoder.ts +14 -14
  173. package/src/chatgpt/ChatGptInitializeFunctionAgent.ts +21 -13
  174. package/src/chatgpt/ChatGptSelectFunctionAgent.ts +66 -74
  175. package/src/chatgpt/ChatGptUsageAggregator.ts +62 -0
  176. package/src/context/AgenticaCancelPrompt.ts +32 -0
  177. package/src/context/AgenticaClassOperation.ts +23 -0
  178. package/src/{structures/IAgenticaContext.ts → context/AgenticaContext.ts} +17 -16
  179. package/src/context/AgenticaHttpOperation.ts +27 -0
  180. package/src/{structures/IAgenticaOperation.ts → context/AgenticaOperation.ts} +25 -22
  181. package/src/context/AgenticaOperationBase.ts +57 -0
  182. package/src/{structures/IAgenticaOperationCollection.ts → context/AgenticaOperationCollection.ts} +6 -6
  183. package/src/context/AgenticaOperationSelection.ts +27 -0
  184. package/src/context/AgenticaTokenUsage.ts +170 -0
  185. package/src/context/internal/AgenticaTokenUsageAggregator.ts +66 -0
  186. package/src/events/AgenticaCallEvent.ts +36 -0
  187. package/src/events/AgenticaCancelEvent.ts +28 -0
  188. package/src/events/AgenticaDescribeEvent.ts +61 -0
  189. package/src/events/AgenticaEvent.ts +36 -0
  190. package/src/events/AgenticaEventBase.ts +7 -0
  191. package/src/{typings/AgenticaSource.ts → events/AgenticaEventSource.ts} +1 -1
  192. package/src/events/AgenticaExecuteEvent.ts +50 -0
  193. package/src/events/AgenticaInitializeEvent.ts +14 -0
  194. package/src/events/AgenticaRequestEvent.ts +45 -0
  195. package/src/events/AgenticaResponseEvent.ts +48 -0
  196. package/src/events/AgenticaSelectEvent.ts +37 -0
  197. package/src/events/AgenticaTextEvent.ts +57 -0
  198. package/src/index.ts +33 -9
  199. package/src/internal/AgenticaOperationComposer.ts +24 -15
  200. package/src/internal/ByteArrayUtil.ts +5 -0
  201. package/src/internal/MPSCUtil.ts +75 -0
  202. package/src/internal/StreamUtil.ts +64 -0
  203. package/src/json/IAgenticaEventJson.ts +178 -0
  204. package/src/json/IAgenticaOperationJson.ts +36 -0
  205. package/src/json/IAgenticaOperationSelectionJson.ts +19 -0
  206. package/src/json/IAgenticaPromptJson.ts +130 -0
  207. package/src/{structures/IAgenticaTokenUsage.ts → json/IAgenticaTokenUsageJson.ts} +10 -10
  208. package/src/prompts/AgenticaCancelPrompt.ts +32 -0
  209. package/src/prompts/AgenticaDescribePrompt.ts +41 -0
  210. package/src/prompts/AgenticaExecutePrompt.ts +52 -0
  211. package/src/prompts/AgenticaPrompt.ts +14 -0
  212. package/src/prompts/AgenticaPromptBase.ts +27 -0
  213. package/src/prompts/AgenticaSelectPrompt.ts +32 -0
  214. package/src/prompts/AgenticaTextPrompt.ts +31 -0
  215. package/src/structures/IAgenticaConfig.ts +3 -3
  216. package/src/structures/IAgenticaExecutor.ts +14 -13
  217. package/src/structures/IAgenticaProps.ts +2 -3
  218. package/src/structures/IAgenticaSystemPrompt.ts +12 -11
  219. package/src/transformers/AgenticaEventTransformer.ts +165 -0
  220. package/src/transformers/AgenticaPromptTransformer.ts +134 -0
  221. package/lib/internal/AgenticaPromptFactory.d.ts +0 -7
  222. package/lib/internal/AgenticaPromptFactory.js +0 -9
  223. package/lib/internal/AgenticaPromptFactory.js.map +0 -1
  224. package/lib/internal/AgenticaPromptTransformer.d.ts +0 -10
  225. package/lib/internal/AgenticaPromptTransformer.js +0 -58
  226. package/lib/internal/AgenticaPromptTransformer.js.map +0 -1
  227. package/lib/internal/AgenticaTokenUsageAggregator.d.ts +0 -11
  228. package/lib/internal/AgenticaTokenUsageAggregator.js +0 -92
  229. package/lib/internal/AgenticaTokenUsageAggregator.js.map +0 -1
  230. package/lib/structures/IAgenticaContext.js.map +0 -1
  231. package/lib/structures/IAgenticaEvent.d.ts +0 -192
  232. package/lib/structures/IAgenticaEvent.js.map +0 -1
  233. package/lib/structures/IAgenticaOperation.d.ts +0 -47
  234. package/lib/structures/IAgenticaOperation.js.map +0 -1
  235. package/lib/structures/IAgenticaOperationCollection.js.map +0 -1
  236. package/lib/structures/IAgenticaOperationSelection.d.ts +0 -50
  237. package/lib/structures/IAgenticaOperationSelection.js.map +0 -1
  238. package/lib/structures/IAgenticaPrompt.d.ts +0 -138
  239. package/lib/structures/IAgenticaPrompt.js.map +0 -1
  240. package/lib/structures/IAgenticaTokenUsage.js +0 -3
  241. package/lib/structures/IAgenticaTokenUsage.js.map +0 -1
  242. package/lib/structures/internal/__IChatCancelFunctionsApplication.js.map +0 -1
  243. package/lib/structures/internal/__IChatFunctionReference.js.map +0 -1
  244. package/lib/structures/internal/__IChatInitialApplication.js.map +0 -1
  245. package/lib/structures/internal/__IChatSelectFunctionsApplication.js.map +0 -1
  246. package/lib/typings/AgenticaSource.d.ts +0 -1
  247. package/lib/typings/AgenticaSource.js.map +0 -1
  248. package/src/internal/AgenticaPromptFactory.ts +0 -32
  249. package/src/internal/AgenticaPromptTransformer.ts +0 -86
  250. package/src/internal/AgenticaTokenUsageAggregator.ts +0 -115
  251. package/src/structures/IAgenticaEvent.ts +0 -229
  252. package/src/structures/IAgenticaOperationSelection.ts +0 -68
  253. package/src/structures/IAgenticaPrompt.ts +0 -182
  254. /package/lib/{structures → context}/internal/__IChatCancelFunctionsApplication.d.ts +0 -0
  255. /package/lib/{structures → context}/internal/__IChatCancelFunctionsApplication.js +0 -0
  256. /package/lib/{structures → context}/internal/__IChatFunctionReference.d.ts +0 -0
  257. /package/lib/{structures → context}/internal/__IChatFunctionReference.js +0 -0
  258. /package/lib/{structures → context}/internal/__IChatInitialApplication.d.ts +0 -0
  259. /package/lib/{structures → context}/internal/__IChatInitialApplication.js +0 -0
  260. /package/lib/{structures → context}/internal/__IChatSelectFunctionsApplication.d.ts +0 -0
  261. /package/lib/{structures → context}/internal/__IChatSelectFunctionsApplication.js +0 -0
  262. /package/src/{structures → context}/internal/__IChatCancelFunctionsApplication.ts +0 -0
  263. /package/src/{structures → context}/internal/__IChatFunctionReference.ts +0 -0
  264. /package/src/{structures → context}/internal/__IChatInitialApplication.ts +0 -0
  265. /package/src/{structures → context}/internal/__IChatSelectFunctionsApplication.ts +0 -0
@@ -0,0 +1,130 @@
1
+ import { IAgenticaOperationJson } from "./IAgenticaOperationJson";
2
+ import { IAgenticaOperationSelectionJson } from "./IAgenticaOperationSelectionJson";
3
+
4
+ /**
5
+ * Nestia A.I. chatbot prompt.
6
+ *
7
+ * `IWrtnChatPrompt` is an union type of all possible prompts that can
8
+ * be generated by the A.I. chatbot of the {@link Agentica} class.
9
+ *
10
+ * In other words, `IWrtnChatPrompt` is a type of chat history that
11
+ * is occurred during the conversation between the user and the A.I. chatbot
12
+ * in the {@link Agentica} class.
13
+ *
14
+ * If you want to continue the previous A.I. chatbot session, you can
15
+ * accomplish it by assigning the {@link IAgenticaProps.histories}
16
+ * property when creating a new {@link Agentica} instance.
17
+ *
18
+ * @author Samchon
19
+ */
20
+ export type IAgenticaPromptJson =
21
+ | IAgenticaPromptJson.IText
22
+ | IAgenticaPromptJson.ISelect
23
+ | IAgenticaPromptJson.ICancel
24
+ | IAgenticaPromptJson.IExecute
25
+ | IAgenticaPromptJson.IDescribe;
26
+ export namespace IAgenticaPromptJson {
27
+ /**
28
+ * Select prompt.
29
+ *
30
+ * Selection prompt about candidate functions to call.
31
+ */
32
+ export interface ISelect extends IBase<"select"> {
33
+ /**
34
+ * ID of the LLM tool call result.
35
+ */
36
+ id: string;
37
+
38
+ /**
39
+ * Operations that have been selected.
40
+ */
41
+ selections: IAgenticaOperationSelectionJson[];
42
+ }
43
+
44
+ /**
45
+ * Cancel prompt.
46
+ *
47
+ * Cancellation prompt about the candidate functions to be discarded.
48
+ */
49
+ export interface ICancel extends IBase<"cancel"> {
50
+ /**
51
+ * ID of the LLM tool call result.
52
+ */
53
+ id: string;
54
+
55
+ /**
56
+ * Operations that have been cancelled.
57
+ */
58
+ selections: IAgenticaOperationSelectionJson[];
59
+ }
60
+
61
+ /**
62
+ * Execute prompt.
63
+ *
64
+ * Execution prompt about the LLM function calling.
65
+ */
66
+ export interface IExecute extends IBase<"execute"> {
67
+ /**
68
+ * ID of the LLM tool call result.
69
+ */
70
+ id: string;
71
+
72
+ /**
73
+ * Target operation to call.
74
+ */
75
+ operation: IAgenticaOperationJson;
76
+
77
+ /**
78
+ * Arguments of the LLM function calling.
79
+ */
80
+ arguments: Record<string, any>;
81
+
82
+ /**
83
+ * Return value.
84
+ */
85
+ value: any;
86
+ }
87
+
88
+ /**
89
+ * Description prompt.
90
+ *
91
+ * Description prompt about the return value of the LLM function calling.
92
+ */
93
+ export interface IDescribe extends IBase<"describe"> {
94
+ /**
95
+ * Executions of the LLM function calling.
96
+ *
97
+ * This prompt describes the return value of them.
98
+ */
99
+ executions: IExecute[];
100
+
101
+ /**
102
+ * Description text.
103
+ */
104
+ text: string;
105
+ }
106
+
107
+ /**
108
+ * Text prompt.
109
+ */
110
+ export interface IText<
111
+ Role extends "assistant" | "user" = "assistant" | "user",
112
+ > extends IBase<"text"> {
113
+ /**
114
+ * Role of the orator.
115
+ */
116
+ role: Role;
117
+
118
+ /**
119
+ * The text content.
120
+ */
121
+ text: string;
122
+ }
123
+
124
+ interface IBase<Type extends string> {
125
+ /**
126
+ * Discriminator type.
127
+ */
128
+ type: Type;
129
+ }
130
+ }
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Token usage information from the A.I. chatbot.
3
3
  *
4
- * `IAgenticaTokenUsage` is a structure representing the token usage
4
+ * `IAgenticaTokenUsageJson` is a structure representing the token usage
5
5
  * information from the {@link Agentica} class. And you can get the
6
6
  * token usage information by calling the {@link Agentica.getTokenUsage}
7
7
  * method.
8
8
  *
9
- * For reference, `IAgenticaTokenUsage` provides only the token usage
9
+ * For reference, `IAgenticaTokenUsageJson` provides only the token usage
10
10
  * information, and does not contain any price or cost information. It is
11
11
  * because the price or cost can be changed by below reasons.
12
12
  *
@@ -16,38 +16,38 @@
16
16
  *
17
17
  * @author Samchon
18
18
  */
19
- export interface IAgenticaTokenUsage {
19
+ export interface IAgenticaTokenUsageJson {
20
20
  /**
21
21
  * Aggregated token usage.
22
22
  */
23
- aggregate: IAgenticaTokenUsage.IComponent;
23
+ aggregate: IAgenticaTokenUsageJson.IComponent;
24
24
 
25
25
  /**
26
26
  * Token uasge of initializer agent.
27
27
  */
28
- initialize: IAgenticaTokenUsage.IComponent;
28
+ initialize: IAgenticaTokenUsageJson.IComponent;
29
29
 
30
30
  /**
31
31
  * Token usage of function selector agent.
32
32
  */
33
- select: IAgenticaTokenUsage.IComponent;
33
+ select: IAgenticaTokenUsageJson.IComponent;
34
34
 
35
35
  /**
36
36
  * Token usage of function canceler agent.
37
37
  */
38
- cancel: IAgenticaTokenUsage.IComponent;
38
+ cancel: IAgenticaTokenUsageJson.IComponent;
39
39
 
40
40
  /**
41
41
  * Token usage of function caller agent.
42
42
  */
43
- call: IAgenticaTokenUsage.IComponent;
43
+ call: IAgenticaTokenUsageJson.IComponent;
44
44
 
45
45
  /**
46
46
  * Token usage of function calling describer agent.
47
47
  */
48
- describe: IAgenticaTokenUsage.IComponent;
48
+ describe: IAgenticaTokenUsageJson.IComponent;
49
49
  }
50
- export namespace IAgenticaTokenUsage {
50
+ export namespace IAgenticaTokenUsageJson {
51
51
  export interface IComponent {
52
52
  /**
53
53
  * Total token usage.
@@ -0,0 +1,32 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import { AgenticaOperationSelection } from "../context/AgenticaOperationSelection";
4
+ import { IAgenticaPromptJson } from "../json/IAgenticaPromptJson";
5
+ import { AgenticaPromptBase } from "./AgenticaPromptBase";
6
+
7
+ export class AgenticaCancelPrompt<
8
+ Model extends ILlmSchema.Model,
9
+ > extends AgenticaPromptBase<"cancel", IAgenticaPromptJson.ICancel> {
10
+ public readonly id: string;
11
+ public readonly selections: AgenticaOperationSelection<Model>[];
12
+
13
+ public constructor(props: AgenticaCancelPrompt.IProps<Model>) {
14
+ super("cancel");
15
+ this.id = props.id;
16
+ this.selections = props.selections;
17
+ }
18
+
19
+ public toJSON(): IAgenticaPromptJson.ICancel {
20
+ return {
21
+ type: this.type,
22
+ id: this.id,
23
+ selections: this.selections.map((s) => s.toJSON()),
24
+ };
25
+ }
26
+ }
27
+ export namespace AgenticaCancelPrompt {
28
+ export interface IProps<Model extends ILlmSchema.Model> {
29
+ id: string;
30
+ selections: AgenticaOperationSelection<Model>[];
31
+ }
32
+ }
@@ -0,0 +1,41 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import { IAgenticaPromptJson } from "../json/IAgenticaPromptJson";
4
+ import { AgenticaExecutePrompt } from "./AgenticaExecutePrompt";
5
+ import { AgenticaPromptBase } from "./AgenticaPromptBase";
6
+
7
+ export class AgenticaDescribePrompt<
8
+ Model extends ILlmSchema.Model,
9
+ > extends AgenticaPromptBase<"describe", IAgenticaPromptJson.IDescribe> {
10
+ /**
11
+ * Executions of the LLM function calling.
12
+ *
13
+ * This prompt describes the return value of them.
14
+ */
15
+ public readonly executes: AgenticaExecutePrompt<Model>[];
16
+
17
+ /**
18
+ * Description text.
19
+ */
20
+ public readonly text: string;
21
+
22
+ public constructor(props: AgenticaDescribePrompt.IProps<Model>) {
23
+ super("describe");
24
+ this.executes = props.executes;
25
+ this.text = props.text;
26
+ }
27
+
28
+ public toJSON(): IAgenticaPromptJson.IDescribe {
29
+ return {
30
+ type: this.type,
31
+ executions: this.executes.map((e) => e.toJSON()),
32
+ text: this.text,
33
+ };
34
+ }
35
+ }
36
+ export namespace AgenticaDescribePrompt {
37
+ export interface IProps<Model extends ILlmSchema.Model> {
38
+ executes: AgenticaExecutePrompt<Model>[];
39
+ text: string;
40
+ }
41
+ }
@@ -0,0 +1,52 @@
1
+ import { IHttpResponse, ILlmSchema } from "@samchon/openapi";
2
+
3
+ import { AgenticaOperation } from "../context/AgenticaOperation";
4
+ import { IAgenticaPromptJson } from "../json/IAgenticaPromptJson";
5
+ import { AgenticaPromptBase } from "./AgenticaPromptBase";
6
+
7
+ export class AgenticaExecutePrompt<
8
+ Model extends ILlmSchema.Model,
9
+ Protocol extends "http" | "class" = any,
10
+ > extends AgenticaPromptBase<"execute", IAgenticaPromptJson.IExecute> {
11
+ public readonly id: string;
12
+ public readonly operation: Protocol extends "http"
13
+ ? AgenticaOperation.Http<Model>
14
+ : Protocol extends "class"
15
+ ? AgenticaOperation.Class<Model>
16
+ : AgenticaOperation<Model>;
17
+ public readonly arguments: Record<string, any>;
18
+ public readonly value: Protocol extends "http" ? IHttpResponse : any;
19
+
20
+ public constructor(props: AgenticaExecutePrompt.IProps<Model, Protocol>) {
21
+ super("execute");
22
+ this.id = props.id;
23
+ this.operation = props.operation;
24
+ this.arguments = props.arguments;
25
+ this.value = props.value;
26
+ }
27
+
28
+ public toJSON(): IAgenticaPromptJson.IExecute {
29
+ return {
30
+ type: this.type,
31
+ id: this.id,
32
+ operation: this.operation.toJSON(),
33
+ arguments: this.arguments,
34
+ value: this.value,
35
+ };
36
+ }
37
+ }
38
+ export namespace AgenticaExecutePrompt {
39
+ export interface IProps<
40
+ Model extends ILlmSchema.Model,
41
+ Protocol extends "http" | "class" = any,
42
+ > {
43
+ id: string;
44
+ operation: Protocol extends "http"
45
+ ? AgenticaOperation.Http<Model>
46
+ : Protocol extends "class"
47
+ ? AgenticaOperation.Class<Model>
48
+ : AgenticaOperation<Model>;
49
+ arguments: Record<string, any>;
50
+ value: Protocol extends "http" ? IHttpResponse : any;
51
+ }
52
+ }
@@ -0,0 +1,14 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import { AgenticaCancelPrompt } from "../context/AgenticaCancelPrompt";
4
+ import { AgenticaDescribePrompt } from "./AgenticaDescribePrompt";
5
+ import { AgenticaExecutePrompt } from "./AgenticaExecutePrompt";
6
+ import { AgenticaSelectPrompt } from "./AgenticaSelectPrompt";
7
+ import { AgenticaTextPrompt } from "./AgenticaTextPrompt";
8
+
9
+ export type AgenticaPrompt<Model extends ILlmSchema.Model> =
10
+ | AgenticaCancelPrompt<Model>
11
+ | AgenticaDescribePrompt<Model>
12
+ | AgenticaExecutePrompt<Model>
13
+ | AgenticaSelectPrompt<Model>
14
+ | AgenticaTextPrompt;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Base class for all prompts in Agentica.
3
+ *
4
+ * `AgenticaPromptBase` is a base class for every prompt classes
5
+ * in Agentica. It is generated by {@link Agentica.conversate} function,
6
+ * and used for restoring the previous conversation history when
7
+ * constructing the {@link Agentica} instance.
8
+ *
9
+ * @template Type Discriminator type
10
+ * @template Json Primitive type of the prompt
11
+ * @author Samchon
12
+ */
13
+ export abstract class AgenticaPromptBase<
14
+ Type extends string,
15
+ Json extends { type: Type },
16
+ > {
17
+ /**
18
+ * Discriminator type.
19
+ */
20
+ public readonly type: Type;
21
+
22
+ protected constructor(type: Type) {
23
+ this.type = type;
24
+ }
25
+
26
+ public abstract toJSON(): Json;
27
+ }
@@ -0,0 +1,32 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import { AgenticaOperationSelection } from "../context/AgenticaOperationSelection";
4
+ import { IAgenticaPromptJson } from "../json/IAgenticaPromptJson";
5
+ import { AgenticaPromptBase } from "./AgenticaPromptBase";
6
+
7
+ export class AgenticaSelectPrompt<
8
+ Model extends ILlmSchema.Model,
9
+ > extends AgenticaPromptBase<"select", IAgenticaPromptJson.ISelect> {
10
+ public readonly id: string;
11
+ public readonly selections: AgenticaOperationSelection<Model>[];
12
+
13
+ public constructor(props: AgenticaSelectPrompt.IProps<Model>) {
14
+ super("select");
15
+ this.id = props.id;
16
+ this.selections = props.selections;
17
+ }
18
+
19
+ public toJSON(): IAgenticaPromptJson.ISelect {
20
+ return {
21
+ type: this.type,
22
+ id: this.id,
23
+ selections: this.selections.map((s) => s.toJSON()),
24
+ };
25
+ }
26
+ }
27
+ export namespace AgenticaSelectPrompt {
28
+ export interface IProps<Model extends ILlmSchema.Model> {
29
+ id: string;
30
+ selections: AgenticaOperationSelection<Model>[];
31
+ }
32
+ }
@@ -0,0 +1,31 @@
1
+ import { IAgenticaPromptJson } from "../json/IAgenticaPromptJson";
2
+ import { AgenticaPromptBase } from "./AgenticaPromptBase";
3
+
4
+ export class AgenticaTextPrompt<
5
+ Role extends "assistant" | "user" = "assistant" | "user",
6
+ > extends AgenticaPromptBase<"text", IAgenticaPromptJson.IText> {
7
+ public readonly role: Role;
8
+ public readonly text: string;
9
+
10
+ public constructor(props: AgenticaTextPrompt.IProps<Role>) {
11
+ super("text");
12
+ this.role = props.role;
13
+ this.text = props.text;
14
+ }
15
+
16
+ public toJSON(): IAgenticaPromptJson.IText<Role> {
17
+ return {
18
+ type: this.type,
19
+ role: this.role,
20
+ text: this.text,
21
+ };
22
+ }
23
+ }
24
+ export namespace AgenticaTextPrompt {
25
+ export interface IProps<
26
+ Role extends "assistant" | "user" = "assistant" | "user",
27
+ > {
28
+ role: Role;
29
+ text: string;
30
+ }
31
+ }
@@ -1,8 +1,8 @@
1
1
  import { ILlmSchema } from "@samchon/openapi";
2
2
 
3
- import { IAgenticaContext } from "./IAgenticaContext";
3
+ import { AgenticaContext } from "../context/AgenticaContext";
4
+ import { AgenticaPrompt } from "../prompts/AgenticaPrompt";
4
5
  import { IAgenticaExecutor } from "./IAgenticaExecutor";
5
- import { IAgenticaPrompt } from "./IAgenticaPrompt";
6
6
  import { IAgenticaSystemPrompt } from "./IAgenticaSystemPrompt";
7
7
 
8
8
  /**
@@ -119,5 +119,5 @@ export interface IAgenticaConfig<Model extends ILlmSchema.Model> {
119
119
  */
120
120
  executor?:
121
121
  | Partial<IAgenticaExecutor<Model>>
122
- | ((ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>);
122
+ | ((ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>);
123
123
  }
@@ -1,7 +1,8 @@
1
1
  import { ILlmSchema } from "@samchon/openapi";
2
2
 
3
- import { IAgenticaContext } from "./IAgenticaContext";
4
- import { IAgenticaPrompt } from "./IAgenticaPrompt";
3
+ import { AgenticaContext } from "../context/AgenticaContext";
4
+ import { AgenticaExecutePrompt } from "../prompts/AgenticaExecutePrompt";
5
+ import { AgenticaPrompt } from "../prompts/AgenticaPrompt";
5
6
 
6
7
  /**
7
8
  * Executor of the Agentic AI.
@@ -36,7 +37,7 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
36
37
  *
37
38
  * And if the `initialize` agent judges the user's conversation
38
39
  * implies to call some function, the `initialize` agent will
39
- * call the {@link IAgenticaContext.initialize} function, and
40
+ * call the {@link AgenticaContext.initialize} function, and
40
41
  * inform every functions enrolled in the {@link IAgenticaController}
41
42
  * to the AI agent. And then, the `initialize` agent will not never
42
43
  * be called again, and let {@link Agentica} to go to the next
@@ -57,14 +58,14 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
57
58
  */
58
59
  initialize:
59
60
  | null
60
- | ((ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>);
61
+ | ((ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>);
61
62
 
62
63
  /**
63
64
  * Function selector agent.
64
65
  *
65
66
  * `Select` agent finds candidate functions to call from the
66
67
  * conversation context with the user. And the candidate functions
67
- * would be enrolled to the {@link IAgenticaContext.stack}, and the
68
+ * would be enrolled to the {@link AgenticaContext.stack}, and the
68
69
  * next {@link call} agent will perform the LLM (Large Language Model)
69
70
  * function calling.
70
71
  *
@@ -86,14 +87,14 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
86
87
  * @param ctx Context of the agent
87
88
  * @returns List of prompts generated by the selector
88
89
  */
89
- select: (ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>;
90
+ select: (ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>;
90
91
 
91
92
  /**
92
93
  * Function caller agent.
93
94
  *
94
95
  * `Call` agent performs the LLM (Large Language Model) function
95
96
  * calling from the candidate functions enrolled in the
96
- * {@link IAgenticaContext.stack}. And the scope of function calling
97
+ * {@link AgenticaContext.stack}. And the scope of function calling
97
98
  * is, not only just arguments filling, but also actual executing
98
99
  * the function and returning the result.
99
100
  *
@@ -113,7 +114,7 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
113
114
  * agent is the most general topic which can be universally
114
115
  * applied to all domain fields.
115
116
  */
116
- call: (ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>;
117
+ call: (ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>;
117
118
 
118
119
  /**
119
120
  * Describer agent of the function calling result.
@@ -126,15 +127,15 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
126
127
  * @returns List of prompts generated by the describer
127
128
  */
128
129
  describe: (
129
- ctx: IAgenticaContext<Model>,
130
- executes: IAgenticaPrompt.IExecute<Model>[],
131
- ) => Promise<IAgenticaPrompt<Model>[]>;
130
+ ctx: AgenticaContext<Model>,
131
+ executes: AgenticaExecutePrompt<Model>[],
132
+ ) => Promise<AgenticaPrompt<Model>[]>;
132
133
 
133
134
  /**
134
135
  * Function canceler agent.
135
136
  *
136
137
  * `Cancel` agent erases the candidate functions from the
137
- * {@link IAgenticaContext.stack} by analyzing the conversation
138
+ * {@link AgenticaContext.stack} by analyzing the conversation
138
139
  * context with the user.
139
140
  *
140
141
  * For reference, the first reason of the cancelation is explicit
@@ -152,5 +153,5 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
152
153
  * @param ctx Context of the agent
153
154
  * @returns List of prompts generated by the canceler
154
155
  */
155
- cancel: (ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>;
156
+ cancel: (ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>;
156
157
  }
@@ -1,9 +1,8 @@
1
1
  import { ILlmSchema } from "@samchon/openapi";
2
- import { Primitive } from "typia";
3
2
 
3
+ import { IAgenticaPromptJson } from "../json/IAgenticaPromptJson";
4
4
  import { IAgenticaConfig } from "./IAgenticaConfig";
5
5
  import { IAgenticaController } from "./IAgenticaController";
6
- import { IAgenticaPrompt } from "./IAgenticaPrompt";
7
6
  import { IAgenticaVendor } from "./IAgenticaVendor";
8
7
 
9
8
  /**
@@ -66,5 +65,5 @@ export interface IAgenticaProps<Model extends ILlmSchema.Model> {
66
65
  * If you're starting the conversation from an existing session,
67
66
  * assign the previouis prompt histories to this property.
68
67
  */
69
- histories?: Primitive<IAgenticaPrompt<Model>>[];
68
+ histories?: IAgenticaPromptJson[];
70
69
  }
@@ -1,7 +1,8 @@
1
1
  import { ILlmSchema } from "@samchon/openapi";
2
2
 
3
+ import { AgenticaExecutePrompt } from "../prompts/AgenticaExecutePrompt";
4
+ import { AgenticaPrompt } from "../prompts/AgenticaPrompt";
3
5
  import { IAgenticaConfig } from "./IAgenticaConfig";
4
- import { IAgenticaPrompt } from "./IAgenticaPrompt";
5
6
 
6
7
  /**
7
8
  * System prompt collection of the A.I. chatbot.
@@ -41,13 +42,13 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
41
42
  *
42
43
  * In that case, the `initialize` system prompt would be used. You can
43
44
  * customize the `initialize` system prompt by assigning this function
44
- * with the given {@link IAgenticaPrompt histories} parameter.
45
+ * with the given {@link AgenticaPrompt histories} parameter.
45
46
  *
46
47
  * @param histories Histories of the previous prompts
47
48
  * @returns initialize system prompt
48
49
  * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/initialize.md
49
50
  */
50
- initialize?: (histories: IAgenticaPrompt<Model>[]) => string;
51
+ initialize?: (histories: AgenticaPrompt<Model>[]) => string;
51
52
 
52
53
  /**
53
54
  * Select system prompt.
@@ -58,7 +59,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
58
59
  *
59
60
  * In that case, this `select` system prompt would be used. You can
60
61
  * customize it by assigning this function with the given
61
- * {@link IAgenticaPrompt histories} parameter.
62
+ * {@link AgenticaPrompt histories} parameter.
62
63
  *
63
64
  * Note that, the `"select"` means only the function selection. It does
64
65
  * not contain the filling argument or executing the function. It
@@ -68,7 +69,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
68
69
  * @returns select system promopt
69
70
  * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/select.md
70
71
  */
71
- select?: (histories: IAgenticaPrompt<Model>[]) => string;
72
+ select?: (histories: AgenticaPrompt<Model>[]) => string;
72
73
 
73
74
  /**
74
75
  * Cancel system prompt.
@@ -79,13 +80,13 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
79
80
  *
80
81
  * In that case, this `cancel` system prompt would be used. You can
81
82
  * customize it by assigning this function with the given
82
- * {@link IAgenticaPrompt histories} parameter.
83
+ * {@link AgenticaPrompt histories} parameter.
83
84
  *
84
85
  * @param histories Histories of the previous prompts
85
86
  * @returns cancel system prompt
86
87
  * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/cancel.md
87
88
  */
88
- cancel?: (histories: IAgenticaPrompt<Model>[]) => string;
89
+ cancel?: (histories: AgenticaPrompt<Model>[]) => string;
89
90
 
90
91
  /**
91
92
  * Execute system prompt.
@@ -97,13 +98,13 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
97
98
  *
98
99
  * In that case, this `execute` system prompt would be used. You can
99
100
  * customize it by assigning this function with the given
100
- * {@link IAgenticaPrompt histories} parameter.
101
+ * {@link AgenticaPrompt histories} parameter.
101
102
  *
102
103
  * @param histories Histories of the previous prompts
103
104
  * @returns execute system prompt
104
105
  * https://github.com/samchon/nestia/blob/master/packages/agent/prompts/execute.md
105
106
  */
106
- execute?: (histories: IAgenticaPrompt<Model>[]) => string;
107
+ execute?: (histories: AgenticaPrompt<Model>[]) => string;
107
108
 
108
109
  /**
109
110
  * Describe system prompt.
@@ -114,11 +115,11 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
114
115
  *
115
116
  * In that case, this `describe` system prompt would be used. You can
116
117
  * customize it by assigning this function with the given
117
- * {@link IAgenticaPrompt histories} parameter.
118
+ * {@link AgenticaPrompt histories} parameter.
118
119
  *
119
120
  * @param histories Histories of the previous prompts
120
121
  * @returns describe system prompt
121
122
  * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/describe.md
122
123
  */
123
- describe?: (histories: IAgenticaPrompt.IExecute<Model>[]) => string;
124
+ describe?: (histories: AgenticaExecutePrompt<Model>[]) => string;
124
125
  }