@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
@@ -1,192 +0,0 @@
1
- import { ILlmSchema } from "@samchon/openapi";
2
- import OpenAI from "openai";
3
- import { AgenticaSource } from "../typings/AgenticaSource";
4
- import { IAgenticaOperation } from "./IAgenticaOperation";
5
- import { IAgenticaPrompt } from "./IAgenticaPrompt";
6
- /**
7
- * Nestia A.I. chatbot event.
8
- *
9
- * `IAgenticaEvent` is an union type of all possible events that can
10
- * be emitted by the A.I. chatbot of the {@link Agentica} class. You
11
- * can discriminate the subtype by checking the {@link type} property.
12
- *
13
- * @author Samchon
14
- */
15
- export type IAgenticaEvent<Model extends ILlmSchema.Model> = IAgenticaEvent.IInitialize | IAgenticaEvent.ISelect<Model> | IAgenticaEvent.ICancel<Model> | IAgenticaEvent.ICall<Model> | IAgenticaEvent.IExecute<Model> | IAgenticaEvent.IDescribe<Model> | IAgenticaEvent.IText | IAgenticaEvent.IRequest | IAgenticaEvent.IResponse;
16
- export declare namespace IAgenticaEvent {
17
- export type Type = IAgenticaEvent<any>["type"];
18
- export type Mapper<Model extends ILlmSchema.Model> = {
19
- initialize: IInitialize;
20
- select: ISelect<Model>;
21
- cancel: ICancel<Model>;
22
- call: ICall<Model>;
23
- execute: IExecute<Model>;
24
- describe: IDescribe<Model>;
25
- text: IText;
26
- request: IRequest;
27
- response: IResponse;
28
- };
29
- /**
30
- * Event of initializing the chatbot.
31
- */
32
- export interface IInitialize extends IBase<"initialize"> {
33
- }
34
- /**
35
- * Event of selecting a function to call.
36
- */
37
- export interface ISelect<Model extends ILlmSchema.Model> extends IBase<"select"> {
38
- /**
39
- * Selected operation.
40
- *
41
- * Operation that has been selected to prepare LLM function calling.
42
- */
43
- operation: IAgenticaOperation<Model>;
44
- /**
45
- * Reason of selecting the function.
46
- *
47
- * The A.I. chatbot will fill this property describing why the function
48
- * has been selected.
49
- */
50
- reason: string;
51
- }
52
- /**
53
- * Event of canceling a function calling.
54
- */
55
- export interface ICancel<Model extends ILlmSchema.Model> extends IBase<"cancel"> {
56
- /**
57
- * Selected operation to cancel.
58
- *
59
- * Operation that has been selected to prepare LLM function calling,
60
- * but canceled due to no more required.
61
- */
62
- operation: IAgenticaOperation<Model>;
63
- /**
64
- * Reason of selecting the function.
65
- *
66
- * The A.I. chatbot will fill this property describing why the function
67
- * has been cancelled.
68
- *
69
- * For reference, if the A.I. chatbot successfully completes the LLM
70
- * function calling, the reason of the function cancellation will be
71
- * "complete".
72
- */
73
- reason: string;
74
- }
75
- /**
76
- * Event of calling a function.
77
- */
78
- export interface ICall<Model extends ILlmSchema.Model> extends IBase<"call"> {
79
- /**
80
- * ID of the tool calling.
81
- */
82
- id: string;
83
- /**
84
- * Target operation to call.
85
- */
86
- operation: IAgenticaOperation<Model>;
87
- /**
88
- * Arguments of the function calling.
89
- *
90
- * If you modify this {@link arguments} property, it actually modifies
91
- * the backend server's request. Therefore, be careful when you're
92
- * trying to modify this property.
93
- */
94
- arguments: object;
95
- }
96
- /**
97
- * Event of function calling execution.
98
- */
99
- export interface IExecute<Model extends ILlmSchema.Model> extends IBase<"execute"> {
100
- /**
101
- * ID of the tool calling.
102
- */
103
- id: string;
104
- /**
105
- * Target operation had called.
106
- */
107
- operation: IAgenticaOperation<Model>;
108
- /**
109
- * Arguments of the function calling.
110
- */
111
- arguments: object;
112
- /**
113
- * Return value.
114
- */
115
- value: any;
116
- }
117
- /**
118
- * Event of description.
119
- *
120
- * Event describing return values of LLM function callings.
121
- */
122
- export interface IDescribe<Model extends ILlmSchema.Model> extends IBase<"describe"> {
123
- /**
124
- * Executions of the LLM function calling.
125
- *
126
- * This prompt describes the return value of them.
127
- */
128
- executions: IAgenticaPrompt.IExecute<Model>[];
129
- /**
130
- * Description text.
131
- */
132
- text: string;
133
- }
134
- /**
135
- * Event of text message.
136
- */
137
- export interface IText extends IBase<"text"> {
138
- /**
139
- * Role of the orator.
140
- */
141
- role: "assistant" | "user";
142
- /**
143
- * The text content.
144
- */
145
- text: string;
146
- }
147
- /**
148
- * Request event of LLM vendor API.
149
- */
150
- export interface IRequest extends IBase<"request"> {
151
- /**
152
- * The source agent of the request.
153
- */
154
- source: AgenticaSource;
155
- /**
156
- * Request body.
157
- */
158
- body: OpenAI.ChatCompletionCreateParamsNonStreaming;
159
- /**
160
- * Options for the request.
161
- */
162
- options?: OpenAI.RequestOptions | undefined;
163
- }
164
- /**
165
- * Response event of LLM vendor API.
166
- */
167
- export interface IResponse extends IBase<"response"> {
168
- /**
169
- * The source agent of the response.
170
- */
171
- source: AgenticaSource;
172
- /**
173
- * Request body.
174
- */
175
- body: OpenAI.ChatCompletionCreateParamsNonStreaming;
176
- /**
177
- * Options for the request.
178
- */
179
- options?: OpenAI.RequestOptions | undefined;
180
- /**
181
- * Return value from the LLM vendor API.
182
- */
183
- value: OpenAI.ChatCompletion;
184
- }
185
- interface IBase<Type extends string> {
186
- /**
187
- * Discriminator type.
188
- */
189
- type: Type;
190
- }
191
- export {};
192
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"IAgenticaEvent.js","sourceRoot":"","sources":["../../src/structures/IAgenticaEvent.ts"],"names":[],"mappings":""}
@@ -1,47 +0,0 @@
1
- import { IHttpLlmFunction, ILlmFunction, ILlmSchema } from "@samchon/openapi";
2
- import { IAgenticaController } from "./IAgenticaController";
3
- /**
4
- * Operation information in the Nestia Agent.
5
- *
6
- * `IAgenticaOperation` is a type represents an operation that would
7
- * be selected by the A.I. chatbot of {@link Agentica} class to
8
- * perform the LLM (Large Language Model) function calling.
9
- *
10
- * Also, it is an union type that is discriminated by the {@link protocol}
11
- * property. If the protocol value is `http`, it means that the HTTP API
12
- * operation would be called by the A.I. chatbot. Otherwise, if the protocol
13
- * value is `class`, it means that the operation has come from a
14
- * TypeScript class.
15
- *
16
- * @author Samchon
17
- */
18
- export type IAgenticaOperation<Model extends ILlmSchema.Model> = IAgenticaOperation.IHttp<Model> | IAgenticaOperation.IClass<Model>;
19
- export declare namespace IAgenticaOperation {
20
- /**
21
- * HTTP API operation.
22
- */
23
- export type IHttp<Model extends ILlmSchema.Model> = IBase<"http", IAgenticaController.IHttp<Model>, IHttpLlmFunction<Model>>;
24
- /**
25
- * TypeScript class operation.
26
- */
27
- export type IClass<Model extends ILlmSchema.Model> = IBase<"class", IAgenticaController.IClass<Model>, ILlmFunction<Model>>;
28
- interface IBase<Protocol, Application, Function> {
29
- /**
30
- * Protocol discriminator.
31
- */
32
- protocol: Protocol;
33
- /**
34
- * Belonged controller of the target function.
35
- */
36
- controller: Application;
37
- /**
38
- * Target function to call.
39
- */
40
- function: Function;
41
- /**
42
- * Identifier name.
43
- */
44
- name: string;
45
- }
46
- export {};
47
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"IAgenticaOperation.js","sourceRoot":"","sources":["../../src/structures/IAgenticaOperation.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IAgenticaOperationCollection.js","sourceRoot":"","sources":["../../src/structures/IAgenticaOperationCollection.ts"],"names":[],"mappings":""}
@@ -1,50 +0,0 @@
1
- import { IHttpLlmFunction, ILlmFunction, ILlmSchema } from "@samchon/openapi";
2
- import { IAgenticaController } from "./IAgenticaController";
3
- /**
4
- * Nestia agent operation selection.
5
- *
6
- * `IAgenticaOperationSelection` is a type represents an operation
7
- * which has been selected by the A.I. chatbot of {@link Agentica}
8
- * class for the LLM (Large Language Model) function calling with
9
- * detailed {@link reason} of the selection (or cancellation).
10
- *
11
- * Also, `IAgenticaOperationSelection` is an union type that can
12
- * specify a subtype by checking the {@link protocol} property.
13
- *
14
- * @author Samchon
15
- */
16
- export type IAgenticaOperationSelection<Model extends ILlmSchema.Model> = IAgenticaOperationSelection.IHttp<Model> | IAgenticaOperationSelection.IClass<Model>;
17
- export declare namespace IAgenticaOperationSelection {
18
- export type IHttp<Model extends ILlmSchema.Model> = IBase<"http", IAgenticaController.IHttp<Model>, IHttpLlmFunction<Model>>;
19
- export type IClass<Model extends ILlmSchema.Model> = IBase<"class", IAgenticaController.IClass<Model>, ILlmFunction<Model>>;
20
- interface IBase<Protocol, Controller, Function> {
21
- /**
22
- * Discriminator protocol.
23
- */
24
- protocol: Protocol;
25
- /**
26
- * Belonged controller of the target function.
27
- */
28
- controller: Controller;
29
- /**
30
- * Target function.
31
- *
32
- * Function that has been selected to prepare LLM function calling,
33
- * or canceled due to no more required.
34
- */
35
- function: Function;
36
- /**
37
- * Identifier name of the target function.
38
- *
39
- * If {@link Agentica} has multiple {@link IAgenticaController}s,
40
- * the `name` can be different from target function's name.
41
- */
42
- name: string;
43
- /**
44
- * The reason of the function selection or cancellation.
45
- */
46
- reason: string;
47
- toJSON(): Omit<IBase<Protocol, string, string>, "toJSON">;
48
- }
49
- export {};
50
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"IAgenticaOperationSelection.js","sourceRoot":"","sources":["../../src/structures/IAgenticaOperationSelection.ts"],"names":[],"mappings":""}
@@ -1,138 +0,0 @@
1
- import { IHttpLlmFunction, IHttpResponse, ILlmFunction, ILlmSchema } from "@samchon/openapi";
2
- import { IAgenticaController } from "./IAgenticaController";
3
- import { IAgenticaOperationSelection } from "./IAgenticaOperationSelection";
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 IAgenticaPrompt<Model extends ILlmSchema.Model> = IAgenticaPrompt.IText | IAgenticaPrompt.ISelect<Model> | IAgenticaPrompt.ICancel<Model> | IAgenticaPrompt.IExecute<Model> | IAgenticaPrompt.IDescribe<Model>;
21
- export declare namespace IAgenticaPrompt {
22
- /**
23
- * Select prompt.
24
- *
25
- * Selection prompt about candidate functions to call.
26
- */
27
- export interface ISelect<Model extends ILlmSchema.Model> extends IBase<"select"> {
28
- /**
29
- * ID of the LLM tool call result.
30
- */
31
- id: string;
32
- /**
33
- * Operations that have been selected.
34
- */
35
- operations: IAgenticaOperationSelection<Model>[];
36
- }
37
- /**
38
- * Cancel prompt.
39
- *
40
- * Cancellation prompt about the candidate functions to be discarded.
41
- */
42
- export interface ICancel<Model extends ILlmSchema.Model> extends IBase<"cancel"> {
43
- /**
44
- * ID of the LLM tool call result.
45
- */
46
- id: string;
47
- /**
48
- * Operations that have been cancelled.
49
- */
50
- operations: IAgenticaOperationSelection<Model>[];
51
- }
52
- /**
53
- * Execute prompt.
54
- *
55
- * Execution prompt about the LLM function calling.
56
- */
57
- export type IExecute<Model extends ILlmSchema.Model> = IExecute.IHttp<Model> | IExecute.IClass<Model>;
58
- export namespace IExecute {
59
- export type IHttp<Model extends ILlmSchema.Model> = IBase<"http", IAgenticaController.IHttp<Model>, IHttpLlmFunction<Model>, IHttpResponse>;
60
- export type IClass<Model extends ILlmSchema.Model> = IBase<"class", IAgenticaController.IClass<Model>, ILlmFunction<Model>, any>;
61
- interface IBase<Protocol, Controller, Function, Value> {
62
- /**
63
- * Discriminator type.
64
- */
65
- type: "execute";
66
- /**
67
- * Protocol discriminator.
68
- */
69
- protocol: Protocol;
70
- /**
71
- * Belonged controller of the target function.
72
- */
73
- controller: Controller;
74
- /**
75
- * Target function to call.
76
- */
77
- function: Function;
78
- /**
79
- * ID of the LLM tool call result.
80
- */
81
- id: string;
82
- /**
83
- * Identifier name of the function.
84
- *
85
- * If {@link Agentica} has multiple {@link IAgenticaController}s,
86
- * the `name` can be different from target function's name.
87
- */
88
- name: string;
89
- /**
90
- * Arguments of the LLM function calling.
91
- */
92
- arguments: object;
93
- /**
94
- * Return value.
95
- */
96
- value: Value;
97
- toJSON(): Omit<IBase<Protocol, string, string, Value>, "toJSON">;
98
- }
99
- export {};
100
- }
101
- /**
102
- * Description prompt.
103
- *
104
- * Description prompt about the return value of the LLM function calling.
105
- */
106
- export interface IDescribe<Model extends ILlmSchema.Model> extends IBase<"describe"> {
107
- /**
108
- * Executions of the LLM function calling.
109
- *
110
- * This prompt describes the return value of them.
111
- */
112
- executions: IExecute<Model>[];
113
- /**
114
- * Description text.
115
- */
116
- text: string;
117
- }
118
- /**
119
- * Text prompt.
120
- */
121
- export interface IText<Role extends "assistant" | "user" = "assistant" | "user"> extends IBase<"text"> {
122
- /**
123
- * Role of the orator.
124
- */
125
- role: Role;
126
- /**
127
- * The text content.
128
- */
129
- text: string;
130
- }
131
- interface IBase<Type extends string> {
132
- /**
133
- * Discriminator type.
134
- */
135
- type: Type;
136
- }
137
- export {};
138
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"IAgenticaPrompt.js","sourceRoot":"","sources":["../../src/structures/IAgenticaPrompt.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=IAgenticaTokenUsage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IAgenticaTokenUsage.js","sourceRoot":"","sources":["../../src/structures/IAgenticaTokenUsage.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"__IChatCancelFunctionsApplication.js","sourceRoot":"","sources":["../../../src/structures/internal/__IChatCancelFunctionsApplication.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"__IChatFunctionReference.js","sourceRoot":"","sources":["../../../src/structures/internal/__IChatFunctionReference.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"__IChatInitialApplication.js","sourceRoot":"","sources":["../../../src/structures/internal/__IChatInitialApplication.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"__IChatSelectFunctionsApplication.js","sourceRoot":"","sources":["../../../src/structures/internal/__IChatSelectFunctionsApplication.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- export type AgenticaSource = "initialize" | "select" | "cancel" | "call" | "describe";
@@ -1 +0,0 @@
1
- {"version":3,"file":"AgenticaSource.js","sourceRoot":"","sources":["../../src/typings/AgenticaSource.ts"],"names":[],"mappings":""}
@@ -1,32 +0,0 @@
1
- import { ILlmSchema } from "@samchon/openapi";
2
-
3
- import { IAgenticaOperationSelection } from "../structures/IAgenticaOperationSelection";
4
- import { IAgenticaPrompt } from "../structures/IAgenticaPrompt";
5
-
6
- export namespace AgenticaPromptFactory {
7
- export const execute = <Model extends ILlmSchema.Model>(
8
- props: Omit<IAgenticaPrompt.IExecute<Model>, "toJSON">,
9
- ): IAgenticaPrompt.IExecute<Model> =>
10
- ({
11
- ...props,
12
- toJSON: () =>
13
- ({
14
- ...props,
15
- controller: props.controller.name,
16
- function: props.function.name,
17
- }) as any,
18
- }) as IAgenticaPrompt.IExecute<Model>;
19
-
20
- export const selection = <Model extends ILlmSchema.Model>(
21
- props: Omit<IAgenticaOperationSelection<Model>, "toJSON">,
22
- ): IAgenticaOperationSelection<Model> =>
23
- ({
24
- ...props,
25
- toJSON: () =>
26
- ({
27
- ...props,
28
- controller: props.controller.name,
29
- function: props.function.name,
30
- }) as any,
31
- }) as IAgenticaOperationSelection<Model>;
32
- }
@@ -1,86 +0,0 @@
1
- import { ILlmSchema } from "@samchon/openapi";
2
- import { Primitive } from "typia";
3
-
4
- import { IAgenticaOperation } from "../structures/IAgenticaOperation";
5
- import { IAgenticaPrompt } from "../structures/IAgenticaPrompt";
6
- import { AgenticaPromptFactory } from "./AgenticaPromptFactory";
7
-
8
- export namespace AgenticaPromptTransformer {
9
- export const transform = <Model extends ILlmSchema.Model>(props: {
10
- operations: Map<string, Map<string, IAgenticaOperation<Model>>>;
11
- input: Primitive<IAgenticaPrompt<Model>>;
12
- }): IAgenticaPrompt<Model> => {
13
- // TEXT
14
- if (props.input.type === "text") return props.input;
15
- // SELECT & CANCEL
16
- else if (props.input.type === "select" || props.input.type === "cancel")
17
- return {
18
- ...props.input,
19
- operations: props.input.operations.map((func) =>
20
- AgenticaPromptFactory.selection({
21
- ...findOperation({
22
- operations: props.operations,
23
- input: func,
24
- }),
25
- reason: func.reason,
26
- }),
27
- ),
28
- } satisfies
29
- | IAgenticaPrompt.ISelect<Model>
30
- | IAgenticaPrompt.ICancel<Model>;
31
- // EXECUTE
32
- else if (props.input.type === "execute")
33
- return transformExecute({
34
- operations: props.operations,
35
- input: props.input,
36
- }) satisfies IAgenticaPrompt.IExecute<Model>;
37
- // DESCRIBE
38
- return {
39
- type: "describe",
40
- text: props.input.text,
41
- executions: props.input.executions.map((next) =>
42
- transformExecute({
43
- operations: props.operations,
44
- input: next,
45
- }),
46
- ),
47
- } satisfies IAgenticaPrompt.IDescribe<Model>;
48
- };
49
-
50
- const transformExecute = <Model extends ILlmSchema.Model>(props: {
51
- operations: Map<string, Map<string, IAgenticaOperation<Model>>>;
52
- input: Primitive<IAgenticaPrompt.IExecute<Model>>;
53
- }): IAgenticaPrompt.IExecute<Model> => {
54
- const operation = findOperation({
55
- operations: props.operations,
56
- input: props.input,
57
- });
58
- return AgenticaPromptFactory.execute({
59
- type: "execute",
60
- protocol: operation.protocol as "http",
61
- controller: operation.controller,
62
- function: operation.function,
63
- id: props.input.id,
64
- name: props.input.name,
65
- arguments: props.input.arguments,
66
- value: props.input.value,
67
- });
68
- };
69
-
70
- const findOperation = <Model extends ILlmSchema.Model>(props: {
71
- operations: Map<string, Map<string, IAgenticaOperation<Model>>>;
72
- input: {
73
- controller: string;
74
- function: string;
75
- };
76
- }): IAgenticaOperation.IHttp<Model> => {
77
- const found: IAgenticaOperation<Model> | undefined = props.operations
78
- .get(props.input.controller)
79
- ?.get(props.input.function);
80
- if (found === undefined)
81
- throw new Error(
82
- `No operation found: (controller: ${props.input.controller}, function: ${props.input.function})`,
83
- );
84
- return found as IAgenticaOperation.IHttp<Model>;
85
- };
86
- }