@agentica/core 0.34.2 → 0.35.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 (145) hide show
  1. package/lib/Agentica.d.ts +9 -10
  2. package/lib/Agentica.js.map +1 -1
  3. package/lib/MicroAgentica.d.ts +9 -10
  4. package/lib/MicroAgentica.js.map +1 -1
  5. package/lib/constants/AgenticaDefaultPrompt.d.ts +1 -2
  6. package/lib/constants/AgenticaDefaultPrompt.js.map +1 -1
  7. package/lib/context/AgenticaContext.d.ts +6 -7
  8. package/lib/context/AgenticaOperation.d.ts +5 -5
  9. package/lib/context/AgenticaOperationCollection.d.ts +5 -6
  10. package/lib/context/AgenticaOperationSelection.d.ts +2 -3
  11. package/lib/context/MicroAgenticaContext.d.ts +5 -6
  12. package/lib/context/internal/AgenticaOperationComposer.js.map +1 -1
  13. package/lib/context/internal/AgenticaOperationComposer.spec.js +41 -9
  14. package/lib/context/internal/AgenticaOperationComposer.spec.js.map +1 -1
  15. package/lib/context/internal/__IChatInitialApplication.d.ts +1 -1
  16. package/lib/context/internal/isAgenticaContext.js.map +1 -1
  17. package/lib/events/AgenticaCallEvent.d.ts +2 -3
  18. package/lib/events/AgenticaCancelEvent.d.ts +2 -3
  19. package/lib/events/AgenticaDescribeEvent.d.ts +3 -4
  20. package/lib/events/AgenticaEvent.d.ts +10 -11
  21. package/lib/events/AgenticaExecuteEvent.d.ts +5 -5
  22. package/lib/events/AgenticaJsonParseErrorEvent.d.ts +2 -3
  23. package/lib/events/AgenticaSelectEvent.d.ts +3 -4
  24. package/lib/events/AgenticaValidateEvent.d.ts +2 -3
  25. package/lib/events/MicroAgenticaEvent.d.ts +8 -9
  26. package/lib/factory/events.d.ts +22 -22
  27. package/lib/factory/events.js.map +1 -1
  28. package/lib/factory/histories.js.map +1 -1
  29. package/lib/factory/operations.d.ts +3 -4
  30. package/lib/factory/operations.js.map +1 -1
  31. package/lib/functional/assertHttpController.d.ts +6 -10
  32. package/lib/functional/assertHttpController.js +775 -91
  33. package/lib/functional/assertHttpController.js.map +1 -1
  34. package/lib/functional/assertHttpLlmApplication.d.ts +4 -8
  35. package/lib/functional/assertHttpLlmApplication.js +775 -91
  36. package/lib/functional/assertHttpLlmApplication.js.map +1 -1
  37. package/lib/functional/assertMcpController.d.ts +5 -6
  38. package/lib/functional/assertMcpController.js +201 -32
  39. package/lib/functional/assertMcpController.js.map +1 -1
  40. package/lib/functional/validateHttpController.d.ts +6 -10
  41. package/lib/functional/validateHttpController.js +636 -89
  42. package/lib/functional/validateHttpController.js.map +1 -1
  43. package/lib/functional/validateHttpLlmApplication.d.ts +4 -8
  44. package/lib/functional/validateHttpLlmApplication.js +636 -89
  45. package/lib/functional/validateHttpLlmApplication.js.map +1 -1
  46. package/lib/functional/validateMcpController.d.ts +5 -6
  47. package/lib/functional/validateMcpController.js +366 -61
  48. package/lib/functional/validateMcpController.js.map +1 -1
  49. package/lib/histories/AgenticaCancelHistory.d.ts +2 -3
  50. package/lib/histories/AgenticaDescribeHistory.d.ts +2 -3
  51. package/lib/histories/AgenticaExecuteHistory.d.ts +5 -5
  52. package/lib/histories/AgenticaHistory.d.ts +7 -8
  53. package/lib/histories/AgenticaSelectHistory.d.ts +2 -3
  54. package/lib/histories/MicroAgenticaHistory.d.ts +5 -6
  55. package/lib/index.mjs +3964 -849
  56. package/lib/index.mjs.map +1 -1
  57. package/lib/orchestrate/call.d.ts +1 -2
  58. package/lib/orchestrate/call.js.map +1 -1
  59. package/lib/orchestrate/cancel.d.ts +1 -2
  60. package/lib/orchestrate/cancel.js +4 -4
  61. package/lib/orchestrate/cancel.js.map +1 -1
  62. package/lib/orchestrate/describe.d.ts +1 -2
  63. package/lib/orchestrate/describe.js.map +1 -1
  64. package/lib/orchestrate/execute.d.ts +1 -2
  65. package/lib/orchestrate/execute.js.map +1 -1
  66. package/lib/orchestrate/initialize.d.ts +1 -2
  67. package/lib/orchestrate/initialize.js +262 -83
  68. package/lib/orchestrate/initialize.js.map +1 -1
  69. package/lib/orchestrate/internal/cancelFunctionFromContext.js.map +1 -1
  70. package/lib/orchestrate/internal/selectFunctionFromContext.js.map +1 -1
  71. package/lib/orchestrate/select.d.ts +1 -2
  72. package/lib/orchestrate/select.js +4 -4
  73. package/lib/orchestrate/select.js.map +1 -1
  74. package/lib/structures/IAgenticaConfig.d.ts +3 -4
  75. package/lib/structures/IAgenticaController.d.ts +11 -14
  76. package/lib/structures/IAgenticaExecutor.d.ts +6 -7
  77. package/lib/structures/IAgenticaProps.d.ts +3 -8
  78. package/lib/structures/IAgenticaSystemPrompt.d.ts +9 -10
  79. package/lib/structures/IMicroAgenticaConfig.d.ts +3 -4
  80. package/lib/structures/IMicroAgenticaExecutor.d.ts +3 -4
  81. package/lib/structures/IMicroAgenticaProps.d.ts +3 -8
  82. package/lib/structures/IMicroAgenticaSystemPrompt.d.ts +6 -7
  83. package/lib/transformers/transformHistory.js.map +1 -1
  84. package/lib/utils/ChatGptCompletionStreamingUtil.spec.js +2 -2
  85. package/lib/utils/ChatGptCompletionStreamingUtil.spec.js.map +1 -1
  86. package/lib/utils/request.d.ts +2 -3
  87. package/lib/utils/request.js.map +1 -1
  88. package/package.json +8 -8
  89. package/src/Agentica.ts +24 -26
  90. package/src/MicroAgentica.ts +27 -29
  91. package/src/constants/AgenticaDefaultPrompt.ts +2 -4
  92. package/src/context/AgenticaContext.ts +6 -7
  93. package/src/context/AgenticaOperation.ts +14 -14
  94. package/src/context/AgenticaOperationCollection.ts +5 -8
  95. package/src/context/AgenticaOperationSelection.ts +2 -4
  96. package/src/context/MicroAgenticaContext.ts +5 -6
  97. package/src/context/internal/AgenticaOperationComposer.spec.ts +50 -18
  98. package/src/context/internal/AgenticaOperationComposer.ts +21 -23
  99. package/src/context/internal/__IChatInitialApplication.ts +1 -1
  100. package/src/context/internal/isAgenticaContext.ts +4 -6
  101. package/src/events/AgenticaCallEvent.ts +2 -5
  102. package/src/events/AgenticaCancelEvent.ts +2 -6
  103. package/src/events/AgenticaDescribeEvent.ts +3 -7
  104. package/src/events/AgenticaEvent.ts +17 -19
  105. package/src/events/AgenticaEvent.type.ts +1 -1
  106. package/src/events/AgenticaExecuteEvent.ts +12 -12
  107. package/src/events/AgenticaJsonParseErrorEvent.ts +2 -4
  108. package/src/events/AgenticaSelectEvent.ts +3 -7
  109. package/src/events/AgenticaValidateEvent.ts +2 -5
  110. package/src/events/MicroAgenticaEvent.ts +13 -15
  111. package/src/factory/events.ts +24 -24
  112. package/src/factory/histories.ts +15 -17
  113. package/src/factory/operations.ts +3 -5
  114. package/src/functional/assertHttpController.ts +7 -15
  115. package/src/functional/assertHttpLlmApplication.ts +4 -13
  116. package/src/functional/assertMcpController.ts +6 -8
  117. package/src/functional/validateHttpController.ts +7 -15
  118. package/src/functional/validateHttpLlmApplication.ts +4 -13
  119. package/src/functional/validateMcpController.ts +6 -11
  120. package/src/histories/AgenticaCancelHistory.ts +2 -6
  121. package/src/histories/AgenticaDescribeHistory.ts +2 -6
  122. package/src/histories/AgenticaExecuteHistory.ts +7 -9
  123. package/src/histories/AgenticaHistory.ts +11 -13
  124. package/src/histories/AgenticaSelectHistory.ts +2 -6
  125. package/src/histories/MicroAgenticaHistory.ts +7 -9
  126. package/src/orchestrate/call.ts +55 -56
  127. package/src/orchestrate/cancel.ts +11 -12
  128. package/src/orchestrate/describe.ts +4 -5
  129. package/src/orchestrate/execute.ts +3 -5
  130. package/src/orchestrate/initialize.ts +4 -5
  131. package/src/orchestrate/internal/cancelFunctionFromContext.ts +4 -6
  132. package/src/orchestrate/internal/selectFunctionFromContext.ts +5 -9
  133. package/src/orchestrate/select.ts +11 -12
  134. package/src/structures/IAgenticaConfig.ts +4 -6
  135. package/src/structures/IAgenticaController.ts +11 -14
  136. package/src/structures/IAgenticaExecutor.ts +9 -11
  137. package/src/structures/IAgenticaProps.ts +3 -10
  138. package/src/structures/IAgenticaSystemPrompt.ts +9 -11
  139. package/src/structures/IMicroAgenticaConfig.ts +3 -5
  140. package/src/structures/IMicroAgenticaExecutor.ts +4 -6
  141. package/src/structures/IMicroAgenticaProps.ts +3 -10
  142. package/src/structures/IMicroAgenticaSystemPrompt.ts +6 -8
  143. package/src/transformers/transformHistory.ts +19 -21
  144. package/src/utils/ChatGptCompletionStreamingUtil.spec.ts +4 -5
  145. package/src/utils/request.ts +2 -3
@@ -1,5 +1,3 @@
1
- import type { ILlmSchema } from "@samchon/openapi";
2
-
3
1
  import type { AgenticaAssistantMessageHistory } from "./AgenticaAssistantMessageHistory";
4
2
  import type { AgenticaCancelHistory } from "./AgenticaCancelHistory";
5
3
  import type { AgenticaDescribeHistory } from "./AgenticaDescribeHistory";
@@ -8,21 +6,21 @@ import type { AgenticaSelectHistory } from "./AgenticaSelectHistory";
8
6
  import type { AgenticaSystemMessageHistory } from "./AgenticaSystemMessageHistory";
9
7
  import type { AgenticaUserMessageHistory } from "./AgenticaUserMessageHistory";
10
8
 
11
- export type AgenticaHistory<Model extends ILlmSchema.Model> =
12
- | AgenticaCancelHistory<Model>
13
- | AgenticaDescribeHistory<Model>
14
- | AgenticaExecuteHistory<Model>
15
- | AgenticaSelectHistory<Model>
9
+ export type AgenticaHistory =
10
+ | AgenticaCancelHistory
11
+ | AgenticaDescribeHistory
12
+ | AgenticaExecuteHistory
13
+ | AgenticaSelectHistory
16
14
  | AgenticaAssistantMessageHistory
17
15
  | AgenticaUserMessageHistory
18
16
  | AgenticaSystemMessageHistory;
19
17
  export namespace AgenticaHistory {
20
- export type Type = AgenticaHistory<any>["type"];
21
- export interface Mapper<Model extends ILlmSchema.Model> {
22
- select: AgenticaSelectHistory<Model>;
23
- cancel: AgenticaCancelHistory<Model>;
24
- execute: AgenticaExecuteHistory<Model>;
25
- describe: AgenticaDescribeHistory<Model>;
18
+ export type Type = AgenticaHistory["type"];
19
+ export interface Mapper {
20
+ select: AgenticaSelectHistory;
21
+ cancel: AgenticaCancelHistory;
22
+ execute: AgenticaExecuteHistory;
23
+ describe: AgenticaDescribeHistory;
26
24
  assistantMessage: AgenticaAssistantMessageHistory;
27
25
  systemMessage: AgenticaSystemMessageHistory;
28
26
  userMessage: AgenticaUserMessageHistory;
@@ -1,12 +1,8 @@
1
- import type { ILlmSchema } from "@samchon/openapi";
2
-
3
1
  import type { AgenticaOperationSelection } from "../context/AgenticaOperationSelection";
4
2
  import type { IAgenticaHistoryJson } from "../json/IAgenticaHistoryJson";
5
3
 
6
4
  import type { AgenticaHistoryBase } from "./AgenticaHistoryBase";
7
5
 
8
- export interface AgenticaSelectHistory<
9
- Model extends ILlmSchema.Model,
10
- > extends AgenticaHistoryBase<"select", IAgenticaHistoryJson.ISelect> {
11
- selection: AgenticaOperationSelection<Model>;
6
+ export interface AgenticaSelectHistory extends AgenticaHistoryBase<"select", IAgenticaHistoryJson.ISelect> {
7
+ selection: AgenticaOperationSelection;
12
8
  }
@@ -1,20 +1,18 @@
1
- import type { ILlmSchema } from "@samchon/openapi";
2
-
3
1
  import type { AgenticaAssistantMessageHistory } from "./AgenticaAssistantMessageHistory";
4
2
  import type { AgenticaDescribeHistory } from "./AgenticaDescribeHistory";
5
3
  import type { AgenticaExecuteHistory } from "./AgenticaExecuteHistory";
6
4
  import type { AgenticaUserMessageHistory } from "./AgenticaUserMessageHistory";
7
5
 
8
- export type MicroAgenticaHistory<Model extends ILlmSchema.Model> =
9
- | AgenticaDescribeHistory<Model>
10
- | AgenticaExecuteHistory<Model>
6
+ export type MicroAgenticaHistory =
7
+ | AgenticaDescribeHistory
8
+ | AgenticaExecuteHistory
11
9
  | AgenticaAssistantMessageHistory
12
10
  | AgenticaUserMessageHistory;
13
11
  export namespace MicroAgenticaHistory {
14
- export type Type = MicroAgenticaHistory<any>["type"];
15
- export interface Mapper<Model extends ILlmSchema.Model> {
16
- describe: AgenticaDescribeHistory<Model>;
17
- execute: AgenticaExecuteHistory<Model>;
12
+ export type Type = MicroAgenticaHistory["type"];
13
+ export interface Mapper {
14
+ describe: AgenticaDescribeHistory;
15
+ execute: AgenticaExecuteHistory;
18
16
  userMessage: AgenticaUserMessageHistory;
19
17
  assistantMessage: AgenticaAssistantMessageHistory;
20
18
  }
@@ -1,5 +1,4 @@
1
1
  import type {
2
- IChatGptSchema,
3
2
  IHttpResponse,
4
3
  ILlmSchema,
5
4
  IValidation,
@@ -32,10 +31,10 @@ import { StreamUtil, toAsyncGenerator } from "../utils/StreamUtil";
32
31
 
33
32
  import { cancelFunctionFromContext } from "./internal/cancelFunctionFromContext";
34
33
 
35
- export async function call<Model extends ILlmSchema.Model>(
36
- ctx: AgenticaContext<Model> | MicroAgenticaContext<Model>,
37
- operations: AgenticaOperation<Model>[],
38
- ): Promise<AgenticaExecuteEvent<Model>[]> {
34
+ export async function call(
35
+ ctx: AgenticaContext | MicroAgenticaContext,
36
+ operations: AgenticaOperation[],
37
+ ): Promise<AgenticaExecuteEvent[]> {
39
38
  const _retryFn = __get_retry(1);
40
39
  const retryFn = async (fn: (prevError?: unknown) => Promise<OpenAI.ChatCompletion>) => {
41
40
  return _retryFn(fn).catch((e) => {
@@ -74,7 +73,7 @@ export async function call<Model extends ILlmSchema.Model>(
74
73
  ? []
75
74
  : [{
76
75
  role: "system",
77
- content: ctx.config?.systemPrompt?.execute?.(ctx.histories as MicroAgenticaHistory<Model>[])
76
+ content: ctx.config?.systemPrompt?.execute?.(ctx.histories as MicroAgenticaHistory[])
78
77
  ?? AgenticaSystemPrompt.EXECUTE,
79
78
  } satisfies OpenAI.ChatCompletionSystemMessageParam]),
80
79
  ],
@@ -96,7 +95,7 @@ export async function call<Model extends ILlmSchema.Model>(
96
95
  required: [],
97
96
  additionalProperties: false,
98
97
  $defs: {},
99
- } satisfies IChatGptSchema.IParameters))
98
+ } satisfies ILlmSchema.IParameters))
100
99
  : s.function.parameters) as Record<string, any>,
101
100
  },
102
101
  }) as OpenAI.ChatCompletionTool,
@@ -134,19 +133,19 @@ export async function call<Model extends ILlmSchema.Model>(
134
133
  return [];
135
134
  }
136
135
 
137
- const executes: AgenticaExecuteEvent<Model>[] = [];
136
+ const executes: AgenticaExecuteEvent[] = [];
138
137
 
139
138
  const retry: number = ctx.config?.retry ?? AgenticaConstant.RETRY;
140
139
  for (const choice of completion.choices) {
141
140
  for (const tc of choice.message.tool_calls ?? []) {
142
141
  if (tc.type === "function") {
143
- const operation: AgenticaOperation<Model> | undefined = operations.find(
142
+ const operation: AgenticaOperation | undefined = operations.find(
144
143
  s => s.name === tc.function.name,
145
144
  );
146
145
  if (operation === undefined) {
147
146
  continue; // Ignore unknown tool calls
148
147
  }
149
- const event: AgenticaExecuteEvent<Model> = await predicate(
148
+ const event: AgenticaExecuteEvent = await predicate(
150
149
  ctx,
151
150
  operation,
152
151
  tc,
@@ -156,7 +155,7 @@ export async function call<Model extends ILlmSchema.Model>(
156
155
  await ctx.dispatch(event);
157
156
  executes.push(event);
158
157
  if (isAgenticaContext(ctx)) {
159
- cancelFunctionFromContext(ctx, {
158
+ cancelFunctionFromContext(ctx as unknown as AgenticaContext, {
160
159
  name: event.operation.name,
161
160
  reason: "completed",
162
161
  });
@@ -167,15 +166,15 @@ export async function call<Model extends ILlmSchema.Model>(
167
166
  return executes;
168
167
  }
169
168
 
170
- async function predicate<Model extends ILlmSchema.Model>(
171
- ctx: AgenticaContext<Model> | MicroAgenticaContext<Model>,
172
- operation: AgenticaOperation<Model>,
169
+ async function predicate(
170
+ ctx: AgenticaContext | MicroAgenticaContext,
171
+ operation: AgenticaOperation,
173
172
  toolCall: OpenAI.ChatCompletionMessageFunctionToolCall,
174
- previousValidationErrors: AgenticaValidateEvent<Model>[],
173
+ previousValidationErrors: AgenticaValidateEvent[],
175
174
  life: number,
176
- ): Promise<AgenticaExecuteEvent<Model>> {
175
+ ): Promise<AgenticaExecuteEvent> {
177
176
  // CHECK INPUT ARGUMENT
178
- const call: AgenticaCallEvent<Model> | AgenticaJsonParseErrorEvent<Model>
177
+ const call: AgenticaCallEvent | AgenticaJsonParseErrorEvent
179
178
  = parseArguments(
180
179
  operation,
181
180
  toolCall,
@@ -189,7 +188,7 @@ async function predicate<Model extends ILlmSchema.Model>(
189
188
  // CHECK TYPE VALIDATION
190
189
  const check: IValidation<unknown> = operation.function.validate(call.arguments);
191
190
  if (check.success === false) {
192
- const event: AgenticaValidateEvent<Model> = createValidateEvent({
191
+ const event: AgenticaValidateEvent = createValidateEvent({
193
192
  call_id: toolCall.id,
194
193
  operation,
195
194
  result: check,
@@ -212,14 +211,14 @@ async function predicate<Model extends ILlmSchema.Model>(
212
211
  /* -----------------------------------------------------------
213
212
  ERROR CORRECTORS
214
213
  ----------------------------------------------------------- */
215
- async function correctTypeError<Model extends ILlmSchema.Model>(
216
- ctx: AgenticaContext<Model> | MicroAgenticaContext<Model>,
217
- callEvent: AgenticaCallEvent<Model>,
218
- validateEvent: AgenticaValidateEvent<Model>,
219
- previousValidationErrors: AgenticaValidateEvent<Model>[],
214
+ async function correctTypeError(
215
+ ctx: AgenticaContext | MicroAgenticaContext,
216
+ callEvent: AgenticaCallEvent,
217
+ validateEvent: AgenticaValidateEvent,
218
+ previousValidationErrors: AgenticaValidateEvent[],
220
219
  life: number,
221
- ): Promise<AgenticaExecuteEvent<Model>> {
222
- return correctError<Model>(ctx, {
220
+ ): Promise<AgenticaExecuteEvent> {
221
+ return correctError(ctx, {
223
222
  giveUp: () => createExecuteEvent({
224
223
  call_id: callEvent.id,
225
224
  operation: callEvent.operation,
@@ -255,14 +254,14 @@ async function correctTypeError<Model extends ILlmSchema.Model>(
255
254
  });
256
255
  }
257
256
 
258
- async function correctJsonError<Model extends ILlmSchema.Model>(
259
- ctx: AgenticaContext<Model> | MicroAgenticaContext<Model>,
257
+ async function correctJsonError(
258
+ ctx: AgenticaContext | MicroAgenticaContext,
260
259
  toolCall: OpenAI.ChatCompletionMessageFunctionToolCall,
261
- parseErrorEvent: AgenticaJsonParseErrorEvent<Model>,
262
- previousValidationErrors: AgenticaValidateEvent<Model>[],
260
+ parseErrorEvent: AgenticaJsonParseErrorEvent,
261
+ previousValidationErrors: AgenticaValidateEvent[],
263
262
  life: number,
264
- ): Promise<AgenticaExecuteEvent<Model>> {
265
- return correctError<Model>(ctx, {
263
+ ): Promise<AgenticaExecuteEvent> {
264
+ return correctError(ctx, {
266
265
  giveUp: () => createExecuteEvent({
267
266
  call_id: toolCall.id,
268
267
  operation: parseErrorEvent.operation,
@@ -291,11 +290,11 @@ async function correctJsonError<Model extends ILlmSchema.Model>(
291
290
  });
292
291
  }
293
292
 
294
- function parseArguments<Model extends ILlmSchema.Model>(
295
- operation: AgenticaOperation<Model>,
293
+ function parseArguments(
294
+ operation: AgenticaOperation,
296
295
  toolCall: OpenAI.ChatCompletionMessageFunctionToolCall,
297
296
  life: number,
298
- ): AgenticaCallEvent<Model> | AgenticaJsonParseErrorEvent<Model> {
297
+ ): AgenticaCallEvent | AgenticaJsonParseErrorEvent {
299
298
  try {
300
299
  const data: Record<string, unknown> = JsonUtil.parse(toolCall.function.arguments);
301
300
  return createCallEvent({
@@ -315,11 +314,11 @@ function parseArguments<Model extends ILlmSchema.Model>(
315
314
  }
316
315
  }
317
316
 
318
- async function correctError<Model extends ILlmSchema.Model>(
319
- ctx: AgenticaContext<Model> | MicroAgenticaContext<Model>,
317
+ async function correctError(
318
+ ctx: AgenticaContext | MicroAgenticaContext,
320
319
  props: {
321
- giveUp: () => AgenticaExecuteEvent<Model>;
322
- operation: AgenticaOperation<Model>;
320
+ giveUp: () => AgenticaExecuteEvent;
321
+ operation: AgenticaOperation;
323
322
  toolCall: {
324
323
  id: string;
325
324
  arguments: string;
@@ -327,9 +326,9 @@ async function correctError<Model extends ILlmSchema.Model>(
327
326
  };
328
327
  systemPrompt: string;
329
328
  life: number;
330
- previousValidationErrors: AgenticaValidateEvent<Model>[];
329
+ previousValidationErrors: AgenticaValidateEvent[];
331
330
  },
332
- ): Promise<AgenticaExecuteEvent<Model>> {
331
+ ): Promise<AgenticaExecuteEvent> {
333
332
  if (props.life <= 0) {
334
333
  return props.giveUp();
335
334
  }
@@ -352,7 +351,7 @@ async function correctError<Model extends ILlmSchema.Model>(
352
351
  {
353
352
  role: "system",
354
353
  content:
355
- ctx.config?.systemPrompt?.execute?.(ctx.histories as MicroAgenticaHistory<Model>[])
354
+ ctx.config?.systemPrompt?.execute?.(ctx.histories as MicroAgenticaHistory[])
356
355
  ?? AgenticaSystemPrompt.EXECUTE,
357
356
  },
358
357
  {
@@ -399,7 +398,7 @@ async function correctError<Model extends ILlmSchema.Model>(
399
398
  properties: {},
400
399
  additionalProperties: false,
401
400
  required: [],
402
- } satisfies IChatGptSchema.IParameters))
401
+ } satisfies ILlmSchema.IParameters))
403
402
 
404
403
  : props.operation.function.parameters) as unknown as Record<string, unknown>,
405
404
  },
@@ -417,7 +416,7 @@ async function correctError<Model extends ILlmSchema.Model>(
417
416
  );
418
417
  return toolCall === undefined
419
418
  ? props.giveUp()
420
- : predicate<Model>(
419
+ : predicate(
421
420
  ctx,
422
421
  props.operation,
423
422
  toolCall,
@@ -429,10 +428,10 @@ async function correctError<Model extends ILlmSchema.Model>(
429
428
  /* -----------------------------------------------------------
430
429
  FUNCTION EXECUTORS
431
430
  ----------------------------------------------------------- */
432
- async function executeFunction<Model extends ILlmSchema.Model>(
433
- call: AgenticaCallEvent<Model>,
434
- operation: AgenticaOperation<Model>,
435
- ): Promise<AgenticaExecuteEvent<Model>> {
431
+ async function executeFunction(
432
+ call: AgenticaCallEvent,
433
+ operation: AgenticaOperation,
434
+ ): Promise<AgenticaExecuteEvent> {
436
435
  try {
437
436
  const value: unknown = await (async () => {
438
437
  switch (operation.protocol) {
@@ -473,9 +472,9 @@ async function executeFunction<Model extends ILlmSchema.Model>(
473
472
  }
474
473
  }
475
474
 
476
- async function executeClassFunction<Model extends ILlmSchema.Model>(
477
- call: AgenticaCallEvent<Model>,
478
- operation: AgenticaOperation.Class<Model>,
475
+ async function executeClassFunction(
476
+ call: AgenticaCallEvent,
477
+ operation: AgenticaOperation.Class,
479
478
  ): Promise<unknown> {
480
479
  const execute = operation.controller.execute;
481
480
  const value: unknown = typeof execute === "function"
@@ -490,9 +489,9 @@ async function executeClassFunction<Model extends ILlmSchema.Model>(
490
489
  return value;
491
490
  }
492
491
 
493
- async function executeHttpOperation<Model extends ILlmSchema.Model>(
494
- call: AgenticaCallEvent<Model>,
495
- operation: AgenticaOperation.Http<Model>,
492
+ async function executeHttpOperation(
493
+ call: AgenticaCallEvent,
494
+ operation: AgenticaOperation.Http,
496
495
  ): Promise<unknown> {
497
496
  const execute = operation.controller.execute;
498
497
  const value: IHttpResponse = typeof execute === "function"
@@ -511,9 +510,9 @@ async function executeHttpOperation<Model extends ILlmSchema.Model>(
511
510
  return value;
512
511
  }
513
512
 
514
- async function executeMcpOperation<Model extends ILlmSchema.Model>(
515
- call: AgenticaCallEvent<Model>,
516
- operation: AgenticaOperation.Mcp<Model>,
513
+ async function executeMcpOperation(
514
+ call: AgenticaCallEvent,
515
+ operation: AgenticaOperation.Mcp,
517
516
  ): Promise<unknown> {
518
517
  return operation.controller.client.callTool({
519
518
  method: operation.function.name,
@@ -1,4 +1,4 @@
1
- import type { ILlmApplication, ILlmSchema } from "@samchon/openapi";
1
+ import type { ILlmApplication } from "@samchon/openapi";
2
2
  import type OpenAI from "openai";
3
3
  import type { IValidation } from "typia";
4
4
 
@@ -22,9 +22,8 @@ import { StreamUtil } from "../utils/StreamUtil";
22
22
 
23
23
  import { cancelFunctionFromContext } from "./internal/cancelFunctionFromContext";
24
24
 
25
- const CONTAINER: ILlmApplication<"chatgpt"> = typia.llm.application<
26
- __IChatCancelFunctionsApplication,
27
- "chatgpt"
25
+ const CONTAINER: ILlmApplication = typia.llm.application<
26
+ __IChatCancelFunctionsApplication
28
27
  >();
29
28
 
30
29
  interface IFailure {
@@ -33,16 +32,16 @@ interface IFailure {
33
32
  validation: IValidation.IFailure;
34
33
  }
35
34
 
36
- export async function cancel<Model extends ILlmSchema.Model>(
37
- ctx: AgenticaContext<Model>,
35
+ export async function cancel(
36
+ ctx: AgenticaContext,
38
37
  ): Promise<void> {
39
38
  if (ctx.operations.divided === undefined) {
40
39
  return step(ctx, ctx.operations.array, 0);
41
40
  }
42
41
 
43
- const stacks: AgenticaOperationSelection<Model>[][]
42
+ const stacks: AgenticaOperationSelection[][]
44
43
  = ctx.operations.divided.map(() => []);
45
- const events: AgenticaEvent<Model>[] = [];
44
+ const events: AgenticaEvent[] = [];
46
45
  await Promise.all(
47
46
  ctx.operations.divided.map(async (operations, i) =>
48
47
  step(
@@ -78,7 +77,7 @@ export async function cancel<Model extends ILlmSchema.Model>(
78
77
  );
79
78
  }
80
79
  else {
81
- const cancelled: AgenticaCancelEvent<Model>[]
80
+ const cancelled: AgenticaCancelEvent[]
82
81
  = events.filter(e => e.type === "cancel");
83
82
  (cancelled.length !== 0 ? cancelled : events)
84
83
  .forEach((e) => {
@@ -87,9 +86,9 @@ export async function cancel<Model extends ILlmSchema.Model>(
87
86
  }
88
87
  }
89
88
 
90
- async function step<Model extends ILlmSchema.Model>(
91
- ctx: AgenticaContext<Model>,
92
- operations: AgenticaOperation<Model>[],
89
+ async function step(
90
+ ctx: AgenticaContext,
91
+ operations: AgenticaOperation[],
93
92
  retry: number,
94
93
  failures?: IFailure[],
95
94
  ): Promise<void> {
@@ -1,4 +1,3 @@
1
- import type { ILlmSchema } from "@samchon/openapi";
2
1
  import type OpenAI from "openai";
3
2
 
4
3
  import type { AgenticaContext } from "../context/AgenticaContext";
@@ -12,9 +11,9 @@ import { createDescribeEvent } from "../factory/events";
12
11
  import { decodeHistory } from "../factory/histories";
13
12
  import { reduceStreamingWithDispatch } from "../utils/ChatGptCompletionStreamingUtil";
14
13
 
15
- export async function describe<Model extends ILlmSchema.Model>(
16
- ctx: AgenticaContext<Model> | MicroAgenticaContext<Model>,
17
- histories: AgenticaExecuteHistory<Model>[],
14
+ export async function describe(
15
+ ctx: AgenticaContext | MicroAgenticaContext,
16
+ histories: AgenticaExecuteHistory[],
18
17
  ): Promise<void> {
19
18
  if (histories.length === 0) {
20
19
  return;
@@ -40,7 +39,7 @@ export async function describe<Model extends ILlmSchema.Model>(
40
39
  });
41
40
 
42
41
  await reduceStreamingWithDispatch(completionStream, (props) => {
43
- const event: AgenticaDescribeEvent<Model> = createDescribeEvent({
42
+ const event: AgenticaDescribeEvent = createDescribeEvent({
44
43
  executes: histories,
45
44
  ...props,
46
45
  });
@@ -1,5 +1,3 @@
1
- import type { ILlmSchema } from "@samchon/openapi";
2
-
3
1
  import type { AgenticaContext } from "../context/AgenticaContext";
4
2
  import type { AgenticaExecuteEvent } from "../events";
5
3
  import type { IAgenticaExecutor } from "../structures/IAgenticaExecutor";
@@ -10,8 +8,8 @@ import { describe } from "./describe";
10
8
  import { initialize } from "./initialize";
11
9
  import { select } from "./select";
12
10
 
13
- export function execute<Model extends ILlmSchema.Model>(executor: Partial<IAgenticaExecutor<Model>> | null) {
14
- return async (ctx: AgenticaContext<Model>): Promise<void> => {
11
+ export function execute(executor: Partial<IAgenticaExecutor> | null) {
12
+ return async (ctx: AgenticaContext): Promise<void> => {
15
13
  // FUNCTIONS ARE NOT LISTED YET
16
14
  if (ctx.ready() === false) {
17
15
  if (executor?.initialize !== true && typeof executor?.initialize !== "function") {
@@ -43,7 +41,7 @@ export function execute<Model extends ILlmSchema.Model>(executor: Partial<IAgent
43
41
  // FUNCTION CALLING LOOP
44
42
  while (true) {
45
43
  // EXECUTE FUNCTIONS
46
- const executes: AgenticaExecuteEvent<Model>[] = await (
44
+ const executes: AgenticaExecuteEvent[] = await (
47
45
  executor?.call ?? call
48
46
  )(ctx, ctx.stack.map(s => s.operation));
49
47
 
@@ -1,4 +1,4 @@
1
- import type { ILlmFunction, ILlmSchema } from "@samchon/openapi";
1
+ import type { ILlmFunction } from "@samchon/openapi";
2
2
  import type OpenAI from "openai";
3
3
 
4
4
  import typia from "typia";
@@ -13,12 +13,11 @@ import { createAssistantMessageEvent } from "../factory/events";
13
13
  import { decodeHistory, decodeUserMessageContent } from "../factory/histories";
14
14
  import { reduceStreamingWithDispatch } from "../utils/ChatGptCompletionStreamingUtil";
15
15
 
16
- const FUNCTION: ILlmFunction<"chatgpt"> = typia.llm.application<
17
- __IChatInitialApplication,
18
- "chatgpt"
16
+ const FUNCTION: ILlmFunction = typia.llm.application<
17
+ __IChatInitialApplication
19
18
  >().functions[0]!;
20
19
 
21
- export async function initialize<Model extends ILlmSchema.Model>(ctx: AgenticaContext<Model>): Promise<void> {
20
+ export async function initialize(ctx: AgenticaContext): Promise<void> {
22
21
  // ----
23
22
  // EXECUTE CHATGPT API
24
23
  // ----
@@ -1,5 +1,3 @@
1
- import type { ILlmSchema } from "@samchon/openapi";
2
-
3
1
  import type { AgenticaContext } from "../../context/AgenticaContext";
4
2
  import type { AgenticaOperationSelection } from "../../context/AgenticaOperationSelection";
5
3
  import type { __IChatFunctionReference } from "../../context/internal/__IChatFunctionReference";
@@ -11,8 +9,8 @@ import { createOperationSelection } from "../../factory/operations";
11
9
  /**
12
10
  * @internal
13
11
  */
14
- export function cancelFunctionFromContext<Model extends ILlmSchema.Model>(
15
- ctx: AgenticaContext<Model>,
12
+ export function cancelFunctionFromContext(
13
+ ctx: AgenticaContext,
16
14
  reference: __IChatFunctionReference,
17
15
  ): void {
18
16
  const index: number = ctx.stack.findIndex(
@@ -22,10 +20,10 @@ export function cancelFunctionFromContext<Model extends ILlmSchema.Model>(
22
20
  return;
23
21
  }
24
22
 
25
- const item: AgenticaOperationSelection<Model> = ctx.stack[index]!;
23
+ const item: AgenticaOperationSelection = ctx.stack[index]!;
26
24
  ctx.stack.splice(index, 1);
27
25
 
28
- const event: AgenticaCancelEvent<Model> = createCancelEvent({
26
+ const event: AgenticaCancelEvent = createCancelEvent({
29
27
  selection: createOperationSelection({
30
28
  operation: item.operation,
31
29
  reason: reference.reason,
@@ -1,5 +1,3 @@
1
- import type { ILlmSchema } from "@samchon/openapi";
2
-
3
1
  import type { AgenticaContext } from "../../context/AgenticaContext";
4
2
  import type { AgenticaOperation } from "../../context/AgenticaOperation";
5
3
  import type { AgenticaOperationSelection } from "../../context/AgenticaOperationSelection";
@@ -12,26 +10,24 @@ import { createOperationSelection } from "../../factory/operations";
12
10
  /**
13
11
  * @internal
14
12
  */
15
- export function selectFunctionFromContext<
16
- Model extends ILlmSchema.Model,
17
- >(
18
- ctx: AgenticaContext<Model>,
13
+ export function selectFunctionFromContext(
14
+ ctx: AgenticaContext,
19
15
  reference: __IChatFunctionReference,
20
16
  ): void {
21
- const operation: AgenticaOperation<Model> | undefined
17
+ const operation: AgenticaOperation | undefined
22
18
  = ctx.operations.flat.get(reference.name);
23
19
  if (operation === undefined) {
24
20
  return;
25
21
  }
26
22
 
27
- const selection: AgenticaOperationSelection<Model>
23
+ const selection: AgenticaOperationSelection
28
24
  = createOperationSelection({
29
25
  operation,
30
26
  reason: reference.reason,
31
27
  });
32
28
  ctx.stack.push(selection);
33
29
 
34
- const event: AgenticaSelectEvent<Model> = createSelectEvent({
30
+ const event: AgenticaSelectEvent = createSelectEvent({
35
31
  selection,
36
32
  });
37
33
  void ctx.dispatch(event).catch(() => {});
@@ -1,4 +1,4 @@
1
- import type { ILlmApplication, ILlmSchema } from "@samchon/openapi";
1
+ import type { ILlmApplication } from "@samchon/openapi";
2
2
  import type OpenAI from "openai";
3
3
  import type { IValidation } from "typia";
4
4
 
@@ -25,9 +25,8 @@ import { toAsyncGenerator } from "../utils/StreamUtil";
25
25
 
26
26
  import { selectFunctionFromContext } from "./internal/selectFunctionFromContext";
27
27
 
28
- const CONTAINER: ILlmApplication<"chatgpt"> = typia.llm.application<
29
- __IChatSelectFunctionsApplication,
30
- "chatgpt"
28
+ const CONTAINER: ILlmApplication = typia.llm.application<
29
+ __IChatSelectFunctionsApplication
31
30
  >();
32
31
 
33
32
  interface IFailure {
@@ -36,16 +35,16 @@ interface IFailure {
36
35
  validation: IValidation.IFailure;
37
36
  }
38
37
 
39
- export async function select<Model extends ILlmSchema.Model>(
40
- ctx: AgenticaContext<Model>,
38
+ export async function select(
39
+ ctx: AgenticaContext,
41
40
  ): Promise<void> {
42
41
  if (ctx.operations.divided === undefined) {
43
42
  return step(ctx, ctx.operations.array, 0);
44
43
  }
45
44
 
46
- const stacks: AgenticaOperationSelection<Model>[][]
45
+ const stacks: AgenticaOperationSelection[][]
47
46
  = ctx.operations.divided.map(() => []);
48
- const events: AgenticaEvent<Model>[] = [];
47
+ const events: AgenticaEvent[] = [];
49
48
  await Promise.all(
50
49
  ctx.operations.divided.map(async (operations, i) =>
51
50
  step(
@@ -81,7 +80,7 @@ export async function select<Model extends ILlmSchema.Model>(
81
80
  );
82
81
  }
83
82
  else {
84
- const selected: AgenticaSelectEvent<Model>[]
83
+ const selected: AgenticaSelectEvent[]
85
84
  = events.filter(e => e.type === "select");
86
85
  (selected.length !== 0 ? selected : events)
87
86
  .forEach((e) => {
@@ -90,9 +89,9 @@ export async function select<Model extends ILlmSchema.Model>(
90
89
  }
91
90
  }
92
91
 
93
- async function step<Model extends ILlmSchema.Model>(
94
- ctx: AgenticaContext<Model>,
95
- operations: AgenticaOperation<Model>[],
92
+ async function step(
93
+ ctx: AgenticaContext,
94
+ operations: AgenticaOperation[],
96
95
  retry: number,
97
96
  failures?: IFailure[],
98
97
  ): Promise<void> {
@@ -1,5 +1,3 @@
1
- import type { ILlmSchema } from "@samchon/openapi";
2
-
3
1
  import type { AgenticaContext } from "../context/AgenticaContext";
4
2
 
5
3
  import type { IAgenticaExecutor } from "./IAgenticaExecutor";
@@ -22,7 +20,7 @@ import type { IAgenticaSystemPrompt } from "./IAgenticaSystemPrompt";
22
20
  *
23
21
  * @author Samchon
24
22
  */
25
- export interface IAgenticaConfig<Model extends ILlmSchema.Model> {
23
+ export interface IAgenticaConfig {
26
24
  /**
27
25
  * Agent executor.
28
26
  *
@@ -38,8 +36,8 @@ export interface IAgenticaConfig<Model extends ILlmSchema.Model> {
38
36
  * @default ChatGptAgent.execute
39
37
  */
40
38
  executor?:
41
- | Partial<IAgenticaExecutor<Model>>
42
- | ((ctx: AgenticaContext<Model>) => Promise<void>);
39
+ | Partial<IAgenticaExecutor>
40
+ | ((ctx: AgenticaContext) => Promise<void>);
43
41
 
44
42
  /**
45
43
  * System prompt messages.
@@ -47,7 +45,7 @@ export interface IAgenticaConfig<Model extends ILlmSchema.Model> {
47
45
  * System prompt messages if you want to customize the system prompt
48
46
  * messages for each situation.
49
47
  */
50
- systemPrompt?: IAgenticaSystemPrompt<Model>;
48
+ systemPrompt?: IAgenticaSystemPrompt;
51
49
 
52
50
  /**
53
51
  * Locale of the A.I. chatbot.