@agentica/core 0.15.7 → 0.16.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.
Files changed (195) hide show
  1. package/lib/Agentica.d.ts +21 -21
  2. package/lib/Agentica.js +29 -29
  3. package/lib/Agentica.js.map +1 -1
  4. package/lib/MicroAgentica.d.ts +115 -0
  5. package/lib/MicroAgentica.js +279 -0
  6. package/lib/MicroAgentica.js.map +1 -0
  7. package/lib/constants/AgenticaDefaultPrompt.d.ts +2 -1
  8. package/lib/constants/AgenticaDefaultPrompt.js +4 -4
  9. package/lib/constants/AgenticaDefaultPrompt.js.map +1 -1
  10. package/lib/context/AgenticaCancelPrompt.d.ts +3 -3
  11. package/lib/context/AgenticaContext.d.ts +12 -12
  12. package/lib/context/AgenticaOperationCollection.d.ts +1 -1
  13. package/lib/context/MicroAgenticaContext.d.ts +75 -0
  14. package/lib/{prompts/AgenticaCancelPrompt.js → context/MicroAgenticaContext.js} +1 -1
  15. package/lib/context/MicroAgenticaContext.js.map +1 -0
  16. package/lib/context/internal/AgenticaOperationComposer.d.ts +2 -1
  17. package/lib/context/internal/AgenticaOperationComposer.js +3 -2
  18. package/lib/context/internal/AgenticaOperationComposer.js.map +1 -1
  19. package/lib/context/internal/isAgenticaContext.d.ts +1 -0
  20. package/lib/context/internal/isAgenticaContext.js +10 -0
  21. package/lib/context/internal/isAgenticaContext.js.map +1 -0
  22. package/lib/events/AgenticaDescribeEvent.d.ts +4 -4
  23. package/lib/events/AgenticaEvent.d.ts +1 -0
  24. package/lib/events/AgenticaExecuteEvent.d.ts +5 -5
  25. package/lib/events/AgenticaSelectEvent.d.ts +2 -2
  26. package/lib/events/AgenticaTextEvent.d.ts +2 -2
  27. package/lib/events/MicroAgenticaEvent.d.ts +32 -0
  28. package/lib/{prompts/AgenticaTextPrompt.js → events/MicroAgenticaEvent.js} +1 -1
  29. package/lib/events/MicroAgenticaEvent.js.map +1 -0
  30. package/lib/factory/events.d.ts +2 -2
  31. package/lib/factory/events.js +5 -5
  32. package/lib/factory/events.js.map +1 -1
  33. package/lib/factory/histories.d.ts +33 -0
  34. package/lib/factory/{prompts.js → histories.js} +13 -13
  35. package/lib/factory/histories.js.map +1 -0
  36. package/lib/factory/index.d.ts +1 -1
  37. package/lib/factory/index.js +1 -1
  38. package/lib/factory/index.js.map +1 -1
  39. package/lib/functional/assertHttpLlmApplication.js +577 -387
  40. package/lib/functional/assertHttpLlmApplication.js.map +1 -1
  41. package/lib/functional/validateHttpLlmApplication.js +500 -348
  42. package/lib/functional/validateHttpLlmApplication.js.map +1 -1
  43. package/lib/histories/AgenticaCancelHistory.d.ts +8 -0
  44. package/lib/{prompts/AgenticaExecutePrompt.js → histories/AgenticaCancelHistory.js} +1 -1
  45. package/lib/histories/AgenticaCancelHistory.js.map +1 -0
  46. package/lib/histories/AgenticaDescribeHistory.d.ts +16 -0
  47. package/lib/histories/AgenticaDescribeHistory.js +3 -0
  48. package/lib/histories/AgenticaDescribeHistory.js.map +1 -0
  49. package/lib/{prompts/AgenticaExecutePrompt.d.ts → histories/AgenticaExecuteHistory.d.ts} +5 -5
  50. package/lib/{prompts/AgenticaDescribePrompt.js → histories/AgenticaExecuteHistory.js} +1 -1
  51. package/lib/histories/AgenticaExecuteHistory.js.map +1 -0
  52. package/lib/histories/AgenticaHistory.d.ts +17 -0
  53. package/lib/{prompts/AgenticaPrompt.js → histories/AgenticaHistory.js} +1 -1
  54. package/lib/histories/AgenticaHistory.js.map +1 -0
  55. package/lib/{prompts/AgenticaPromptBase.d.ts → histories/AgenticaHistoryBase.d.ts} +4 -4
  56. package/lib/{json/IAgenticaPromptJson.js → histories/AgenticaHistoryBase.js} +1 -1
  57. package/lib/histories/AgenticaHistoryBase.js.map +1 -0
  58. package/lib/histories/AgenticaSelectHistory.d.ts +8 -0
  59. package/lib/histories/AgenticaSelectHistory.js +3 -0
  60. package/lib/histories/AgenticaSelectHistory.js.map +1 -0
  61. package/lib/histories/AgenticaTextHistory.d.ts +6 -0
  62. package/lib/{prompts/AgenticaPromptBase.js → histories/AgenticaTextHistory.js} +1 -1
  63. package/lib/histories/AgenticaTextHistory.js.map +1 -0
  64. package/lib/histories/MicroAgenticaHistory.d.ts +13 -0
  65. package/lib/histories/MicroAgenticaHistory.js +3 -0
  66. package/lib/histories/MicroAgenticaHistory.js.map +1 -0
  67. package/lib/index.d.ts +12 -7
  68. package/lib/index.js +12 -7
  69. package/lib/index.js.map +1 -1
  70. package/lib/index.mjs +1408 -917
  71. package/lib/index.mjs.map +1 -1
  72. package/lib/json/IAgenticaEventJson.d.ts +6 -5
  73. package/lib/json/{IAgenticaPromptJson.d.ts → IAgenticaHistoryJson.d.ts} +8 -8
  74. package/lib/json/IAgenticaHistoryJson.js +3 -0
  75. package/lib/json/IAgenticaHistoryJson.js.map +1 -0
  76. package/lib/json/IAgenticaOperationSelectionJson.d.ts +7 -1
  77. package/lib/json/IMicroAgenticaEventJson.d.ts +13 -0
  78. package/lib/json/IMicroAgenticaEventJson.js +3 -0
  79. package/lib/json/IMicroAgenticaEventJson.js.map +1 -0
  80. package/lib/json/IMicroAgenticaHistoryJson.d.ts +19 -0
  81. package/lib/json/IMicroAgenticaHistoryJson.js +3 -0
  82. package/lib/json/IMicroAgenticaHistoryJson.js.map +1 -0
  83. package/lib/orchestrate/call.d.ts +4 -2
  84. package/lib/orchestrate/call.js +58 -49
  85. package/lib/orchestrate/call.js.map +1 -1
  86. package/lib/orchestrate/cancel.js +4 -4
  87. package/lib/orchestrate/cancel.js.map +1 -1
  88. package/lib/orchestrate/describe.d.ts +4 -3
  89. package/lib/orchestrate/describe.js +5 -5
  90. package/lib/orchestrate/describe.js.map +1 -1
  91. package/lib/orchestrate/execute.d.ts +2 -2
  92. package/lib/orchestrate/execute.js +1 -1
  93. package/lib/orchestrate/execute.js.map +1 -1
  94. package/lib/orchestrate/initialize.d.ts +2 -2
  95. package/lib/orchestrate/initialize.js +5 -5
  96. package/lib/orchestrate/initialize.js.map +1 -1
  97. package/lib/orchestrate/internal/selectFunction.d.ts +1 -5
  98. package/lib/orchestrate/internal/selectFunction.js +5 -2
  99. package/lib/orchestrate/internal/selectFunction.js.map +1 -1
  100. package/lib/orchestrate/select.d.ts +2 -2
  101. package/lib/orchestrate/select.js +5 -5
  102. package/lib/orchestrate/select.js.map +1 -1
  103. package/lib/structures/IAgenticaConfig.d.ts +6 -5
  104. package/lib/structures/IAgenticaController.d.ts +1 -1
  105. package/lib/structures/IAgenticaExecutor.d.ts +11 -9
  106. package/lib/structures/IAgenticaProps.d.ts +3 -3
  107. package/lib/structures/IAgenticaSystemPrompt.d.ts +13 -13
  108. package/lib/structures/IAgenticaVendor.d.ts +1 -1
  109. package/lib/structures/IMicroAgenticaConfig.d.ts +74 -0
  110. package/lib/structures/IMicroAgenticaConfig.js +3 -0
  111. package/lib/structures/IMicroAgenticaConfig.js.map +1 -0
  112. package/lib/structures/IMicroAgenticaExecutor.d.ts +57 -0
  113. package/lib/structures/IMicroAgenticaExecutor.js +3 -0
  114. package/lib/structures/IMicroAgenticaExecutor.js.map +1 -0
  115. package/lib/structures/IMicroAgenticaProps.d.ts +63 -0
  116. package/lib/structures/IMicroAgenticaProps.js +3 -0
  117. package/lib/structures/IMicroAgenticaProps.js.map +1 -0
  118. package/lib/structures/IMicroAgenticaSystemPrompt.d.ts +66 -0
  119. package/lib/structures/IMicroAgenticaSystemPrompt.js +3 -0
  120. package/lib/structures/IMicroAgenticaSystemPrompt.js.map +1 -0
  121. package/lib/transformers/AgenticaPromptTransformer.d.ts +19 -19
  122. package/lib/transformers/AgenticaPromptTransformer.js +27 -27
  123. package/lib/transformers/AgenticaPromptTransformer.js.map +1 -1
  124. package/package.json +7 -7
  125. package/src/Agentica.ts +36 -36
  126. package/src/MicroAgentica.ts +337 -0
  127. package/src/constants/AgenticaDefaultPrompt.ts +4 -2
  128. package/src/context/AgenticaCancelPrompt.ts +3 -3
  129. package/src/context/AgenticaContext.ts +12 -12
  130. package/src/context/AgenticaOperationCollection.ts +1 -1
  131. package/src/context/MicroAgenticaContext.ts +95 -0
  132. package/src/context/internal/AgenticaOperationComposer.ts +6 -3
  133. package/src/context/internal/isAgenticaContext.ts +13 -0
  134. package/src/events/AgenticaDescribeEvent.ts +4 -4
  135. package/src/events/AgenticaEvent.ts +6 -0
  136. package/src/events/AgenticaExecuteEvent.ts +5 -5
  137. package/src/events/AgenticaSelectEvent.ts +2 -2
  138. package/src/events/AgenticaTextEvent.ts +2 -2
  139. package/src/events/MicroAgenticaEvent.ts +41 -0
  140. package/src/factory/events.ts +8 -8
  141. package/src/factory/{prompts.ts → histories.ts} +18 -18
  142. package/src/factory/index.ts +1 -1
  143. package/src/histories/AgenticaCancelHistory.ts +13 -0
  144. package/src/histories/AgenticaDescribeHistory.ts +22 -0
  145. package/src/{prompts/AgenticaExecutePrompt.ts → histories/AgenticaExecuteHistory.ts} +7 -7
  146. package/src/histories/AgenticaHistory.ts +25 -0
  147. package/src/{prompts/AgenticaPromptBase.ts → histories/AgenticaHistoryBase.ts} +4 -4
  148. package/src/histories/AgenticaSelectHistory.ts +13 -0
  149. package/src/histories/AgenticaTextHistory.ts +10 -0
  150. package/src/histories/MicroAgenticaHistory.ts +18 -0
  151. package/src/index.ts +18 -15
  152. package/src/json/IAgenticaEventJson.ts +6 -5
  153. package/src/json/{IAgenticaPromptJson.ts → IAgenticaHistoryJson.ts} +13 -13
  154. package/src/json/IAgenticaOperationSelectionJson.ts +8 -1
  155. package/src/json/IMicroAgenticaEventJson.ts +21 -0
  156. package/src/json/IMicroAgenticaHistoryJson.ts +23 -0
  157. package/src/orchestrate/call.ts +91 -67
  158. package/src/orchestrate/cancel.ts +4 -4
  159. package/src/orchestrate/describe.ts +13 -9
  160. package/src/orchestrate/execute.ts +7 -7
  161. package/src/orchestrate/initialize.ts +8 -8
  162. package/src/orchestrate/internal/selectFunction.ts +5 -2
  163. package/src/orchestrate/select.ts +13 -13
  164. package/src/structures/IAgenticaConfig.ts +6 -5
  165. package/src/structures/IAgenticaController.ts +1 -1
  166. package/src/structures/IAgenticaExecutor.ts +12 -10
  167. package/src/structures/IAgenticaProps.ts +3 -3
  168. package/src/structures/IAgenticaSystemPrompt.ts +13 -13
  169. package/src/structures/IAgenticaVendor.ts +1 -1
  170. package/src/structures/IMicroAgenticaConfig.ts +82 -0
  171. package/src/structures/IMicroAgenticaExecutor.ts +63 -0
  172. package/src/structures/IMicroAgenticaProps.ts +70 -0
  173. package/src/structures/IMicroAgenticaSystemPrompt.ts +71 -0
  174. package/src/transformers/AgenticaPromptTransformer.ts +46 -46
  175. package/lib/factory/prompts.d.ts +0 -33
  176. package/lib/factory/prompts.js.map +0 -1
  177. package/lib/json/IAgenticaPromptJson.js.map +0 -1
  178. package/lib/prompts/AgenticaCancelPrompt.d.ts +0 -8
  179. package/lib/prompts/AgenticaCancelPrompt.js.map +0 -1
  180. package/lib/prompts/AgenticaDescribePrompt.d.ts +0 -16
  181. package/lib/prompts/AgenticaDescribePrompt.js.map +0 -1
  182. package/lib/prompts/AgenticaExecutePrompt.js.map +0 -1
  183. package/lib/prompts/AgenticaPrompt.d.ts +0 -17
  184. package/lib/prompts/AgenticaPrompt.js.map +0 -1
  185. package/lib/prompts/AgenticaPromptBase.js.map +0 -1
  186. package/lib/prompts/AgenticaSelectPrompt.d.ts +0 -8
  187. package/lib/prompts/AgenticaSelectPrompt.js +0 -3
  188. package/lib/prompts/AgenticaSelectPrompt.js.map +0 -1
  189. package/lib/prompts/AgenticaTextPrompt.d.ts +0 -6
  190. package/lib/prompts/AgenticaTextPrompt.js.map +0 -1
  191. package/src/prompts/AgenticaCancelPrompt.ts +0 -13
  192. package/src/prompts/AgenticaDescribePrompt.ts +0 -22
  193. package/src/prompts/AgenticaPrompt.ts +0 -25
  194. package/src/prompts/AgenticaSelectPrompt.ts +0 -13
  195. package/src/prompts/AgenticaTextPrompt.ts +0 -10
@@ -11,16 +11,16 @@ import type { AgenticaOperationSelection } from "../context/AgenticaOperationSel
11
11
  import type { __IChatFunctionReference } from "../context/internal/__IChatFunctionReference";
12
12
  import type { __IChatSelectFunctionsApplication } from "../context/internal/__IChatSelectFunctionsApplication";
13
13
  import type { AgenticaEvent } from "../events/AgenticaEvent";
14
- import type { AgenticaPrompt } from "../prompts/AgenticaPrompt";
15
- import type { AgenticaSelectPrompt } from "../prompts/AgenticaSelectPrompt";
16
- import type { AgenticaTextPrompt } from "../prompts/AgenticaTextPrompt";
14
+ import type { AgenticaHistory } from "../histories/AgenticaHistory";
15
+ import type { AgenticaSelectHistory } from "../histories/AgenticaSelectHistory";
16
+ import type { AgenticaTextHistory } from "../histories/AgenticaTextHistory";
17
17
 
18
18
  import { AgenticaConstant } from "../constants/AgenticaConstant";
19
19
  import { AgenticaDefaultPrompt } from "../constants/AgenticaDefaultPrompt";
20
20
  import { AgenticaSystemPrompt } from "../constants/AgenticaSystemPrompt";
21
21
  import { createTextEvent } from "../factory/events";
22
+ import { createSelectHistory, createTextHistory, decodeHistory } from "../factory/histories";
22
23
  import { createOperationSelection } from "../factory/operations";
23
- import { createSelectPrompt, createTextPrompt, decodePrompt } from "../factory/prompts";
24
24
  import { ChatGptCompletionMessageUtil } from "../utils/ChatGptCompletionMessageUtil";
25
25
  import { StreamUtil } from "../utils/StreamUtil";
26
26
 
@@ -37,7 +37,7 @@ interface IFailure {
37
37
  validation: IValidation.IFailure;
38
38
  }
39
39
 
40
- export async function select<Model extends ILlmSchema.Model>(ctx: AgenticaContext<Model>): Promise<AgenticaPrompt<Model>[]> {
40
+ export async function select<Model extends ILlmSchema.Model>(ctx: AgenticaContext<Model>): Promise<AgenticaHistory<Model>[]> {
41
41
  if (ctx.operations.divided === undefined) {
42
42
  return step(ctx, ctx.operations.array, 0);
43
43
  }
@@ -45,7 +45,7 @@ export async function select<Model extends ILlmSchema.Model>(ctx: AgenticaContex
45
45
  const stacks: AgenticaOperationSelection<Model>[][]
46
46
  = ctx.operations.divided.map(() => []);
47
47
  const events: AgenticaEvent<Model>[] = [];
48
- const prompts: AgenticaPrompt<Model>[][] = await Promise.all(
48
+ const prompts: AgenticaHistory<Model>[][] = await Promise.all(
49
49
  ctx.operations.divided.map(async (operations, i) =>
50
50
  step(
51
51
  {
@@ -82,7 +82,7 @@ export async function select<Model extends ILlmSchema.Model>(ctx: AgenticaContex
82
82
  }
83
83
 
84
84
  // RE-COLLECT SELECT FUNCTION EVENTS
85
- const collection: AgenticaSelectPrompt<Model> = createSelectPrompt({
85
+ const collection: AgenticaSelectHistory<Model> = createSelectHistory({
86
86
  id: v4(),
87
87
  selections: [],
88
88
  });
@@ -98,7 +98,7 @@ export async function select<Model extends ILlmSchema.Model>(ctx: AgenticaContex
98
98
  return [collection];
99
99
  }
100
100
 
101
- async function step<Model extends ILlmSchema.Model>(ctx: AgenticaContext<Model>, operations: AgenticaOperation<Model>[], retry: number, failures?: IFailure[]): Promise<AgenticaPrompt<Model>[]> {
101
+ async function step<Model extends ILlmSchema.Model>(ctx: AgenticaContext<Model>, operations: AgenticaOperation<Model>[], retry: number, failures?: IFailure[]): Promise<AgenticaHistory<Model>[]> {
102
102
  // ----
103
103
  // EXECUTE CHATGPT API
104
104
  // ----
@@ -141,7 +141,7 @@ async function step<Model extends ILlmSchema.Model>(ctx: AgenticaContext<Model>,
141
141
  ),
142
142
  },
143
143
  // PREVIOUS HISTORIES
144
- ...ctx.histories.map(decodePrompt).flat(),
144
+ ...ctx.histories.map(decodeHistory).flat(),
145
145
  // USER INPUT
146
146
  {
147
147
  role: "user",
@@ -209,7 +209,7 @@ async function step<Model extends ILlmSchema.Model>(ctx: AgenticaContext<Model>,
209
209
  // ----
210
210
  // PROCESS COMPLETION
211
211
  // ----
212
- const prompts: AgenticaPrompt<Model>[] = [];
212
+ const prompts: AgenticaHistory<Model>[] = [];
213
213
  for (const choice of completion.choices) {
214
214
  // TOOL CALLING HANDLER
215
215
  if (choice.message.tool_calls != null) {
@@ -227,8 +227,8 @@ async function step<Model extends ILlmSchema.Model>(ctx: AgenticaContext<Model>,
227
227
  continue;
228
228
  }
229
229
 
230
- const collection: AgenticaSelectPrompt<Model>
231
- = createSelectPrompt({
230
+ const collection: AgenticaSelectHistory<Model>
231
+ = createSelectHistory({
232
232
  id: tc.id,
233
233
  selections: [],
234
234
  });
@@ -259,7 +259,7 @@ async function step<Model extends ILlmSchema.Model>(ctx: AgenticaContext<Model>,
259
259
  choice.message.role === "assistant"
260
260
  && choice.message.content != null
261
261
  ) {
262
- const text: AgenticaTextPrompt = createTextPrompt({
262
+ const text: AgenticaTextHistory = createTextHistory({
263
263
  role: "assistant",
264
264
  text: choice.message.content,
265
265
  });
@@ -1,21 +1,22 @@
1
1
  import type { ILlmSchema } from "@samchon/openapi";
2
2
 
3
3
  import type { AgenticaContext } from "../context/AgenticaContext";
4
- import type { AgenticaPrompt } from "../prompts/AgenticaPrompt";
4
+ import type { AgenticaHistory } from "../histories/AgenticaHistory";
5
5
 
6
6
  import type { IAgenticaExecutor } from "./IAgenticaExecutor";
7
7
  import type { IAgenticaSystemPrompt } from "./IAgenticaSystemPrompt";
8
8
 
9
9
  /**
10
- * Configuration for Nestia Agent.
10
+ * Configuration for Agentic Agent.
11
11
  *
12
12
  * `IAgenticaConfig` is an interface that defines the configuration
13
13
  * properties of the {@link Agentica}. With this configuration, you
14
- * can set the user's locale, timezone, and some of system prompts.
14
+ * can set the user's {@link locale}, {@link timezone}, and some of
15
+ * {@link systemPrompt system prompts}.
15
16
  *
16
17
  * Also, you can affect to the LLM function selecing/calling logic by
17
18
  * configuring additional properties. For an example, if you configure the
18
- * {@link capacity} property, the A.I. chatbot will divide the functions
19
+ * {@link capacity} property, the AI chatbot will divide the functions
19
20
  * into the several groups with the configured capacity and select proper
20
21
  * functions to call by operating the multiple LLM function selecting
21
22
  * agents parallelly.
@@ -40,7 +41,7 @@ export interface IAgenticaConfig<Model extends ILlmSchema.Model> {
40
41
  */
41
42
  executor?:
42
43
  | Partial<IAgenticaExecutor<Model>>
43
- | ((ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>);
44
+ | ((ctx: AgenticaContext<Model>) => Promise<AgenticaHistory<Model>[]>);
44
45
 
45
46
  /**
46
47
  * System prompt messages.
@@ -9,7 +9,7 @@ import type {
9
9
  } from "@samchon/openapi";
10
10
 
11
11
  /**
12
- * Controller of the Nestia Agent.
12
+ * Controller of the Agentica Agent.
13
13
  *
14
14
  * `IAgenticaController` is a type represents a controller of the
15
15
  * {@link Agentica}, which serves a set of functions to be called
@@ -1,8 +1,9 @@
1
1
  import type { ILlmSchema } from "@samchon/openapi";
2
2
 
3
3
  import type { AgenticaContext } from "../context/AgenticaContext";
4
- import type { AgenticaExecutePrompt } from "../prompts/AgenticaExecutePrompt";
5
- import type { AgenticaPrompt } from "../prompts/AgenticaPrompt";
4
+ import type { AgenticaOperation } from "../context/AgenticaOperation";
5
+ import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory";
6
+ import type { AgenticaHistory } from "../histories/AgenticaHistory";
6
7
 
7
8
  /**
8
9
  * Executor of the Agentic AI.
@@ -23,8 +24,8 @@ import type { AgenticaPrompt } from "../prompts/AgenticaPrompt";
23
24
  * the executor logic, it can entirely break the {@link Agentica}'s
24
25
  * operation.
25
26
  *
26
- * @reference https://github.com/wrtnlabs/agentica?tab=readme-ov-file#principles
27
- * @reference https://github.com/wrtnlabs/agentica/blob/main/packages/agent/src/chatgpt/ChatGptAgent.ts
27
+ * @reference https://wrtnlabs.io/agentica/docs/concepts/function-calling/#orchestration-strategy
28
+ * @reference https://github.com/wrtnlabs/agentica/blob/main/packages/core/src/orchestrate/execute.ts
28
29
  * @author Samchon
29
30
  */
30
31
  export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
@@ -58,7 +59,7 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
58
59
  */
59
60
  initialize:
60
61
  | null
61
- | ((ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>);
62
+ | ((ctx: AgenticaContext<Model>) => Promise<AgenticaHistory<Model>[]>);
62
63
 
63
64
  /**
64
65
  * Function selector agent.
@@ -87,7 +88,7 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
87
88
  * @param ctx Context of the agent
88
89
  * @returns List of prompts generated by the selector
89
90
  */
90
- select: (ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>;
91
+ select: (ctx: AgenticaContext<Model>) => Promise<AgenticaHistory<Model>[]>;
91
92
 
92
93
  /**
93
94
  * Function caller agent.
@@ -108,13 +109,14 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
108
109
  * calling to the user as markdown content.
109
110
  *
110
111
  * @param ctx Context of the agent
112
+ * @param operation Lit of candidate operations to call
111
113
  * @returns List of prompts generated by the caller
112
114
  * @warning Recommend not to customize, due to its validation
113
115
  * feedback strategy is working very well, and the `call`
114
116
  * agent is the most general topic which can be universally
115
117
  * applied to all domain fields.
116
118
  */
117
- call: (ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>;
119
+ call: (ctx: AgenticaContext<Model>, operations: AgenticaOperation<Model>[]) => Promise<AgenticaHistory<Model>[]>;
118
120
 
119
121
  /**
120
122
  * Describer agent of the function calling result.
@@ -128,8 +130,8 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
128
130
  */
129
131
  describe: (
130
132
  ctx: AgenticaContext<Model>,
131
- executes: AgenticaExecutePrompt<Model>[],
132
- ) => Promise<AgenticaPrompt<Model>[]>;
133
+ executes: AgenticaExecuteHistory<Model>[],
134
+ ) => Promise<AgenticaHistory<Model>[]>;
133
135
 
134
136
  /**
135
137
  * Function canceler agent.
@@ -153,5 +155,5 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
153
155
  * @param ctx Context of the agent
154
156
  * @returns List of prompts generated by the canceler
155
157
  */
156
- cancel: (ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>;
158
+ cancel: (ctx: AgenticaContext<Model>) => Promise<AgenticaHistory<Model>[]>;
157
159
  }
@@ -1,13 +1,13 @@
1
1
  import type { ILlmSchema } from "@samchon/openapi";
2
2
 
3
- import type { IAgenticaPromptJson } from "../json/IAgenticaPromptJson";
3
+ import type { IAgenticaHistoryJson } from "../json/IAgenticaHistoryJson";
4
4
 
5
5
  import type { IAgenticaConfig } from "./IAgenticaConfig";
6
6
  import type { IAgenticaController } from "./IAgenticaController";
7
7
  import type { IAgenticaVendor } from "./IAgenticaVendor";
8
8
 
9
9
  /**
10
- * Properties of the Nestia Agent.
10
+ * Properties of the Agentica Agent.
11
11
  *
12
12
  * `IAgenticaProps` is an interface that defines the properties
13
13
  * of the {@link Agentica.constructor}. In the `IAgenticaProps`,
@@ -66,5 +66,5 @@ export interface IAgenticaProps<Model extends ILlmSchema.Model> {
66
66
  * If you're starting the conversation from an existing session,
67
67
  * assign the previouis prompt histories to this property.
68
68
  */
69
- histories?: IAgenticaPromptJson[];
69
+ histories?: IAgenticaHistoryJson[];
70
70
  }
@@ -1,12 +1,12 @@
1
1
  import type { ILlmSchema } from "@samchon/openapi";
2
2
 
3
- import type { AgenticaExecutePrompt } from "../prompts/AgenticaExecutePrompt";
4
- import type { AgenticaPrompt } from "../prompts/AgenticaPrompt";
3
+ import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory";
4
+ import type { AgenticaHistory } from "../histories/AgenticaHistory";
5
5
 
6
6
  import type { IAgenticaConfig } from "./IAgenticaConfig";
7
7
 
8
8
  /**
9
- * System prompt collection of the A.I. chatbot.
9
+ * System prompt collection of the Agentic AI.
10
10
  *
11
11
  * `IAgenticaSystemPrompt` is a type represents a collection of system
12
12
  * prompts that would be used by the A.I. chatbot of {@link Agentica}.
@@ -43,13 +43,13 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
43
43
  *
44
44
  * In that case, the `initialize` system prompt would be used. You can
45
45
  * customize the `initialize` system prompt by assigning this function
46
- * with the given {@link AgenticaPrompt histories} parameter.
46
+ * with the given {@link AgenticaHistory histories} parameter.
47
47
  *
48
48
  * @param histories Histories of the previous prompts
49
49
  * @returns initialize system prompt
50
50
  * @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/initialize.md
51
51
  */
52
- initialize?: (histories: AgenticaPrompt<Model>[]) => string;
52
+ initialize?: (histories: AgenticaHistory<Model>[]) => string;
53
53
 
54
54
  /**
55
55
  * Select system prompt.
@@ -60,7 +60,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
60
60
  *
61
61
  * In that case, this `select` system prompt would be used. You can
62
62
  * customize it by assigning this function with the given
63
- * {@link AgenticaPrompt histories} parameter.
63
+ * {@link AgenticaHistory histories} parameter.
64
64
  *
65
65
  * Note that, the `"select"` means only the function selection. It does
66
66
  * not contain the filling argument or executing the function. It
@@ -70,7 +70,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
70
70
  * @returns select system promopt
71
71
  * @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/select.md
72
72
  */
73
- select?: (histories: AgenticaPrompt<Model>[]) => string;
73
+ select?: (histories: AgenticaHistory<Model>[]) => string;
74
74
 
75
75
  /**
76
76
  * Cancel system prompt.
@@ -81,13 +81,13 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
81
81
  *
82
82
  * In that case, this `cancel` system prompt would be used. You can
83
83
  * customize it by assigning this function with the given
84
- * {@link AgenticaPrompt histories} parameter.
84
+ * {@link AgenticaHistory histories} parameter.
85
85
  *
86
86
  * @param histories Histories of the previous prompts
87
87
  * @returns cancel system prompt
88
88
  * @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/cancel.md
89
89
  */
90
- cancel?: (histories: AgenticaPrompt<Model>[]) => string;
90
+ cancel?: (histories: AgenticaHistory<Model>[]) => string;
91
91
 
92
92
  /**
93
93
  * Execute system prompt.
@@ -99,13 +99,13 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
99
99
  *
100
100
  * In that case, this `execute` system prompt would be used. You can
101
101
  * customize it by assigning this function with the given
102
- * {@link AgenticaPrompt histories} parameter.
102
+ * {@link AgenticaHistory histories} parameter.
103
103
  *
104
104
  * @param histories Histories of the previous prompts
105
105
  * @returns execute system prompt
106
106
  * https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/execute.md
107
107
  */
108
- execute?: (histories: AgenticaPrompt<Model>[]) => string;
108
+ execute?: (histories: AgenticaHistory<Model>[]) => string;
109
109
 
110
110
  /**
111
111
  * Describe system prompt.
@@ -116,11 +116,11 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
116
116
  *
117
117
  * In that case, this `describe` system prompt would be used. You can
118
118
  * customize it by assigning this function with the given
119
- * {@link AgenticaPrompt histories} parameter.
119
+ * {@link AgenticaHistory histories} parameter.
120
120
  *
121
121
  * @param histories Histories of the previous prompts
122
122
  * @returns describe system prompt
123
123
  * @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/describe.md
124
124
  */
125
- describe?: (histories: AgenticaExecutePrompt<Model>[]) => string;
125
+ describe?: (histories: AgenticaExecuteHistory<Model>[]) => string;
126
126
  }
@@ -1,7 +1,7 @@
1
1
  import type OpenAI from "openai";
2
2
 
3
3
  /**
4
- * LLM service vendor for Nestia Chat.
4
+ * LLM service vendor for Agentica Chat.
5
5
  *
6
6
  * `IAgenticaVendor` is a type represents an LLM
7
7
  * (Large Language Model) vendor of the {@link Agentica}.
@@ -0,0 +1,82 @@
1
+ import type { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import type { IMicroAgenticaExecutor } from "./IMicroAgenticaExecutor";
4
+ import type { IMicroAgenticaSystemPrompt } from "./IMicroAgenticaSystemPrompt";
5
+
6
+ /**
7
+ * Configuration for Micro Agentic Agent.
8
+ *
9
+ * `INicroAgenticaConfig` is an interface that defines the configuration
10
+ * properties of the {@link MicroAgentica}. With this configuration, you
11
+ * can set the user's {@link locale}, {@link timezone}, and some of
12
+ * {@link systemPrompt system prompts}.
13
+ *
14
+ * @author Samchon
15
+ */
16
+ export interface IMicroAgenticaConfig<Model extends ILlmSchema.Model> {
17
+ /**
18
+ * Agent executor.
19
+ *
20
+ * Executor function of Agentic AI's iteration plan to internal agents
21
+ * running by the {@link Agentica.conversate} function.
22
+ *
23
+ * If you want to customize the agent execution plan, you can do it
24
+ * by assigning you logic function of entire or partial to this property.
25
+ * When customizing it, it would better to reference the
26
+ * {@link ChatGptAgent.execute} function.
27
+ *
28
+ * @param ctx Context of the agent
29
+ * @returns Lit of prompts generated by the executor
30
+ * @default ChatGptAgent.execute
31
+ */
32
+ executor?:
33
+ | undefined
34
+ | Partial<IMicroAgenticaExecutor<Model>>;
35
+
36
+ /**
37
+ * System prompt messages.
38
+ *
39
+ * System prompt messages if you want to customize the system prompt
40
+ * messages for each situation.
41
+ */
42
+ systemPrompt?: IMicroAgenticaSystemPrompt<Model>;
43
+
44
+ /**
45
+ * Locale of the A.I. chatbot.
46
+ *
47
+ * If you configure this property, the A.I. chatbot will conversate with
48
+ * the given locale. You can get the locale value by
49
+ *
50
+ * - Browser: `navigator.language`
51
+ * - NodeJS: `process.env.LANG.split(".")[0]`
52
+ *
53
+ * @default your_locale
54
+ */
55
+ locale?: string;
56
+
57
+ /**
58
+ * Timezone of the A.I. chatbot.
59
+ *
60
+ * If you configure this property, the A.I. chatbot will consider the
61
+ * given timezone. You can get the timezone value by
62
+ * `Intl.DateTimeFormat().resolvedOptions().timeZone`.
63
+ *
64
+ * @default your_timezone
65
+ */
66
+ timezone?: string;
67
+
68
+ /**
69
+ * Retry count.
70
+ *
71
+ * If LLM function calling composed arguments are invalid,
72
+ * the A.I. chatbot will retry to call the function with
73
+ * the modified arguments.
74
+ *
75
+ * By the way, if you configure it to 0 or 1, the A.I. chatbot
76
+ * will not retry the LLM function calling for correcting the
77
+ * arguments.
78
+ *
79
+ * @default 3
80
+ */
81
+ retry?: number;
82
+ }
@@ -0,0 +1,63 @@
1
+ import type { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import type { MicroAgenticaContext } from "../context/MicroAgenticaContext";
4
+ import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory";
5
+ import type { MicroAgenticaHistory } from "../histories/MicroAgenticaHistory";
6
+
7
+ /**
8
+ * Executor of the Micro Agentic AI.
9
+ *
10
+ * `IMicroAgenticaExecutor` represents an executor of the
11
+ * {@link MicroAgentica}, composing its internal agents to accomplish
12
+ * the Agentic AI through the LLM (Large Language Model) function
13
+ * calling.
14
+ *
15
+ * You can customize one of these intnernal agents by configuring
16
+ * properties of the `IMicroAgenticaExecutor` type, and assigning
17
+ * it to the {@link IMicroAgenticaConfig.executor} property.
18
+ *
19
+ * @author Samchon
20
+ */
21
+ export interface IMicroAgenticaExecutor<Model extends ILlmSchema.Model> {
22
+ /**
23
+ * Function caller agent.
24
+ *
25
+ * `Call` agent performs the LLM (Large Language Model) function
26
+ * calling from the candidate functions enrolled in the
27
+ * {@link AgenticaContext.stack}. And the scope of function calling
28
+ * is, not only just arguments filling, but also actual executing
29
+ * the function and returning the result.
30
+ *
31
+ * By the way, conversation context with user can be not enough to
32
+ * filling the arguments of the candidate functions. In that case,
33
+ * the `call` agent will ask the user to fill the missing arguments.
34
+ *
35
+ * Otherwise the cpnversation context is enough, so that succeeded
36
+ * to call some candidate functions, the `call` agent will step to
37
+ * the {@link describe} agent to explain the result of the function
38
+ * calling to the user as markdown content.
39
+ *
40
+ * @param ctx Context of the agent
41
+ * @returns List of prompts generated by the caller
42
+ * @warning Recommend not to customize, due to its validation
43
+ * feedback strategy is working very well, and the `call`
44
+ * agent is the most general topic which can be universally
45
+ * applied to all domain fields.
46
+ */
47
+ call: (ctx: MicroAgenticaContext<Model>) => Promise<MicroAgenticaHistory<Model>[]>;
48
+
49
+ /**
50
+ * Describer agent of the function calling result.
51
+ *
52
+ * `Describe` agent explains the results of the function callings
53
+ * to the user as markdown content.
54
+ *
55
+ * @param ctx Context of the agent
56
+ * @param executes List of function calling results
57
+ * @returns List of prompts generated by the describer
58
+ */
59
+ describe: (
60
+ ctx: MicroAgenticaContext<Model>,
61
+ executes: AgenticaExecuteHistory<Model>[],
62
+ ) => Promise<MicroAgenticaHistory<Model>[]>;
63
+ }
@@ -0,0 +1,70 @@
1
+ import type { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import type { IMicroAgenticaHistoryJson } from "../json/IMicroAgenticaHistoryJson";
4
+
5
+ import type { IAgenticaController } from "./IAgenticaController";
6
+ import type { IAgenticaVendor } from "./IAgenticaVendor";
7
+ import type { IMicroAgenticaConfig } from "./IMicroAgenticaConfig";
8
+
9
+ /**
10
+ * Properties of the Micro Agentica Agent.
11
+ *
12
+ * `IMicroAgenticaProps` is an interface that defines the properties
13
+ * of the {@link MicroAgentica.constructor}. In the `IMicroAgenticaProps`,
14
+ * there're everything to prepare to create a Micro A.I. chatbot
15
+ * performing the LLM (Large Language Model) function calling.
16
+ *
17
+ * At first, you have to specify the LLM service {@link vendor} like
18
+ * OpenAI with its API key and client API. And then, you have to define
19
+ * the {@link controllers} serving the functions to call. The controllers
20
+ * are separated by two protocols; HTTP API and TypeScript class. At last,
21
+ * you can {@link config configure} the agent by setting the locale,
22
+ * timezone, and some of system prompts.
23
+ *
24
+ * Additionally, if you want to start from the previous A.I. chatbot
25
+ * session, you can accomplish it by assigning the previous prompt
26
+ * histories to the {@link histories} property.
27
+ *
28
+ * @author Samchon
29
+ */
30
+ export interface IMicroAgenticaProps<Model extends ILlmSchema.Model> {
31
+ /**
32
+ * LLM schema model.
33
+ */
34
+ model: Model;
35
+
36
+ /**
37
+ * LLM service vendor.
38
+ */
39
+ vendor: IAgenticaVendor;
40
+
41
+ /**
42
+ * Controllers serving functions to call.
43
+ */
44
+ controllers: IAgenticaController<Model>[];
45
+
46
+ /**
47
+ * Configuration of agent.
48
+ *
49
+ * Configuration of A.I. chatbot agent including the user's locale,
50
+ * timezone, and some of system prompts. Also, you can affect to the
51
+ * LLM function selecting/calling logic by configuring additional
52
+ * properties.
53
+ *
54
+ * If you don't configure this property, these values would be default.
55
+ *
56
+ * - `locale`: your system's locale and timezone
57
+ * - `timezone`: your system's timezone
58
+ * - `systemPrompt`: default prompts written in markdown
59
+ * - https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts
60
+ */
61
+ config?: IMicroAgenticaConfig<Model>;
62
+
63
+ /**
64
+ * Prompt histories.
65
+ *
66
+ * If you're starting the conversation from an existing session,
67
+ * assign the previouis prompt histories to this property.
68
+ */
69
+ histories?: IMicroAgenticaHistoryJson[];
70
+ }
@@ -0,0 +1,71 @@
1
+ import type { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory";
4
+ import type { MicroAgenticaHistory } from "../histories/MicroAgenticaHistory";
5
+
6
+ import type { IMicroAgenticaConfig } from "./IMicroAgenticaConfig";
7
+
8
+ /**
9
+ * System prompt collection of the Micro Agentic AI.
10
+ *
11
+ * `IMicroAgenticaSystemPrompt` is a type represents a collection of
12
+ * system prompts that would be used by the A.I. chatbot of
13
+ * {@link MicroAgentica}.
14
+ *
15
+ * You can customize the system prompt by configuring the
16
+ * {@link IAgenticaConfig.systemPrompt} property when creating a new
17
+ * {@link Agentica} instance.
18
+ *
19
+ * If you don't configure any system prompts, the default system prompts
20
+ * would be used which are written in the below directory as markdown
21
+ * documents.
22
+ *
23
+ * - https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts
24
+ *
25
+ * @author Samchon
26
+ */
27
+ export interface IMicroAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
28
+ /**
29
+ * Common system prompt that would be used in every situation.
30
+ *
31
+ * @param config Configuration of the agent
32
+ * @returns The common system prompt
33
+ * @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/common.md
34
+ */
35
+ common?: (config?: IMicroAgenticaConfig<Model> | undefined) => string;
36
+
37
+ /**
38
+ * Execute system prompt.
39
+ *
40
+ * The {@link Agentica} has a process filling the arguments of some
41
+ * selected candidate functions by the LLM (Large Language Model)
42
+ * function calling feature with the previous prompt histories, and
43
+ * executing the arguments filled function with validation feedback.
44
+ *
45
+ * In that case, this `execute` system prompt would be used. You can
46
+ * customize it by assigning this function with the given
47
+ * {@link AgenticaHistory histories} parameter.
48
+ *
49
+ * @param histories Histories of the previous prompts
50
+ * @returns execute system prompt
51
+ * https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/execute.md
52
+ */
53
+ execute?: null | ((histories: MicroAgenticaHistory<Model>[]) => string);
54
+
55
+ /**
56
+ * Describe system prompt.
57
+ *
58
+ * The {@link Agentica} has a process describing the return values of
59
+ * the executed functions by requesting to the A.I. agent with the
60
+ * previous prompt histories.
61
+ *
62
+ * In that case, this `describe` system prompt would be used. You can
63
+ * customize it by assigning this function with the given
64
+ * {@link AgenticaHistory histories} parameter.
65
+ *
66
+ * @param histories Histories of the previous prompts
67
+ * @returns describe system prompt
68
+ * @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/describe.md
69
+ */
70
+ describe?: (histories: AgenticaExecuteHistory<Model>[]) => string;
71
+ }