@agentica/core 0.8.3-dev.20250227 → 0.9.0-dev.20250302

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 (71) hide show
  1. package/README.md +25 -10
  2. package/lib/Agentica.d.ts +10 -9
  3. package/lib/Agentica.js.map +1 -1
  4. package/lib/chatgpt/ChatGptAgent.d.ts +2 -1
  5. package/lib/chatgpt/ChatGptAgent.js.map +1 -1
  6. package/lib/chatgpt/ChatGptCallFunctionAgent.d.ts +2 -1
  7. package/lib/chatgpt/ChatGptCallFunctionAgent.js +3 -1
  8. package/lib/chatgpt/ChatGptCallFunctionAgent.js.map +1 -1
  9. package/lib/chatgpt/ChatGptCancelFunctionAgent.d.ts +3 -2
  10. package/lib/chatgpt/ChatGptCancelFunctionAgent.js +55 -2
  11. package/lib/chatgpt/ChatGptCancelFunctionAgent.js.map +1 -1
  12. package/lib/chatgpt/ChatGptDescribeFunctionAgent.d.ts +2 -1
  13. package/lib/chatgpt/ChatGptDescribeFunctionAgent.js.map +1 -1
  14. package/lib/chatgpt/ChatGptHistoryDecoder.d.ts +2 -1
  15. package/lib/chatgpt/ChatGptHistoryDecoder.js.map +1 -1
  16. package/lib/chatgpt/ChatGptInitializeFunctionAgent.d.ts +2 -1
  17. package/lib/chatgpt/ChatGptInitializeFunctionAgent.js +63 -1
  18. package/lib/chatgpt/ChatGptInitializeFunctionAgent.js.map +1 -1
  19. package/lib/chatgpt/ChatGptSelectFunctionAgent.d.ts +2 -1
  20. package/lib/chatgpt/ChatGptSelectFunctionAgent.js +55 -2
  21. package/lib/chatgpt/ChatGptSelectFunctionAgent.js.map +1 -1
  22. package/lib/functional/createHttpLlmApplication.js +826 -798
  23. package/lib/functional/createHttpLlmApplication.js.map +1 -1
  24. package/lib/index.mjs +987 -804
  25. package/lib/index.mjs.map +1 -1
  26. package/lib/internal/AgenticaDefaultPrompt.d.ts +2 -1
  27. package/lib/internal/AgenticaDefaultPrompt.js.map +1 -1
  28. package/lib/internal/AgenticaOperationComposer.d.ts +5 -4
  29. package/lib/internal/AgenticaOperationComposer.js +1 -1
  30. package/lib/internal/AgenticaOperationComposer.js.map +1 -1
  31. package/lib/internal/AgenticaPromptFactory.d.ts +3 -2
  32. package/lib/internal/AgenticaPromptFactory.js.map +1 -1
  33. package/lib/internal/AgenticaPromptTransformer.d.ts +5 -4
  34. package/lib/internal/AgenticaPromptTransformer.js.map +1 -1
  35. package/lib/structures/IAgenticaConfig.d.ts +4 -3
  36. package/lib/structures/IAgenticaContext.d.ts +7 -6
  37. package/lib/structures/IAgenticaController.d.ts +8 -8
  38. package/lib/structures/IAgenticaEvent.d.ts +19 -18
  39. package/lib/structures/IAgenticaExecutor.d.ts +7 -6
  40. package/lib/structures/IAgenticaOperation.d.ts +4 -4
  41. package/lib/structures/IAgenticaOperationCollection.d.ts +6 -5
  42. package/lib/structures/IAgenticaOperationSelection.d.ts +4 -4
  43. package/lib/structures/IAgenticaPrompt.d.ts +11 -11
  44. package/lib/structures/IAgenticaProps.d.ts +9 -4
  45. package/lib/structures/IAgenticaProvider.d.ts +22 -27
  46. package/lib/structures/IAgenticaSystemPrompt.d.ts +8 -7
  47. package/package.json +6 -9
  48. package/src/Agentica.ts +24 -19
  49. package/src/chatgpt/ChatGptAgent.ts +9 -5
  50. package/src/chatgpt/ChatGptCallFunctionAgent.ts +25 -22
  51. package/src/chatgpt/ChatGptCancelFunctionAgent.ts +26 -22
  52. package/src/chatgpt/ChatGptDescribeFunctionAgent.ts +7 -6
  53. package/src/chatgpt/ChatGptHistoryDecoder.ts +3 -2
  54. package/src/chatgpt/ChatGptInitializeFunctionAgent.ts +5 -5
  55. package/src/chatgpt/ChatGptSelectFunctionAgent.ts +33 -32
  56. package/src/internal/AgenticaDefaultPrompt.ts +5 -1
  57. package/src/internal/AgenticaOperationComposer.ts +20 -15
  58. package/src/internal/AgenticaPromptFactory.ts +10 -8
  59. package/src/internal/AgenticaPromptTransformer.ts +19 -16
  60. package/src/structures/IAgenticaConfig.ts +6 -4
  61. package/src/structures/IAgenticaContext.ts +7 -6
  62. package/src/structures/IAgenticaController.ts +12 -10
  63. package/src/structures/IAgenticaEvent.ts +28 -23
  64. package/src/structures/IAgenticaExecutor.ts +12 -8
  65. package/src/structures/IAgenticaOperation.ts +10 -10
  66. package/src/structures/IAgenticaOperationCollection.ts +7 -5
  67. package/src/structures/IAgenticaOperationSelection.ts +10 -10
  68. package/src/structures/IAgenticaPrompt.ts +24 -19
  69. package/src/structures/IAgenticaProps.ts +10 -4
  70. package/src/structures/IAgenticaProvider.ts +22 -28
  71. package/src/structures/IAgenticaSystemPrompt.ts +9 -7
@@ -1,3 +1,4 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
1
2
  import { IAgenticaContext } from "./IAgenticaContext";
2
3
  import { IAgenticaPrompt } from "./IAgenticaPrompt";
3
4
  /**
@@ -23,7 +24,7 @@ import { IAgenticaPrompt } from "./IAgenticaPrompt";
23
24
  * @reference https://github.com/wrtnlabs/agentica/blob/main/packages/agent/src/chatgpt/ChatGptAgent.ts
24
25
  * @author Samchon
25
26
  */
26
- export interface IAgenticaExecutor {
27
+ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
27
28
  /**
28
29
  * Initializer agent listing up functions.
29
30
  *
@@ -52,7 +53,7 @@ export interface IAgenticaExecutor {
52
53
  * @param ctx Context of the agent
53
54
  * @returns List of prompts generated by the initializer
54
55
  */
55
- initialize: null | ((ctx: IAgenticaContext) => Promise<IAgenticaPrompt[]>);
56
+ initialize: null | ((ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>);
56
57
  /**
57
58
  * Function selector agent.
58
59
  *
@@ -80,7 +81,7 @@ export interface IAgenticaExecutor {
80
81
  * @param ctx Context of the agent
81
82
  * @returns List of prompts generated by the selector
82
83
  */
83
- select: (ctx: IAgenticaContext) => Promise<IAgenticaPrompt[]>;
84
+ select: (ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>;
84
85
  /**
85
86
  * Function caller agent.
86
87
  *
@@ -106,7 +107,7 @@ export interface IAgenticaExecutor {
106
107
  * agent is the most general topic which can be universally
107
108
  * applied to all domain fields.
108
109
  */
109
- call: (ctx: IAgenticaContext) => Promise<IAgenticaPrompt[]>;
110
+ call: (ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>;
110
111
  /**
111
112
  * Describer agent of the function calling result.
112
113
  *
@@ -117,7 +118,7 @@ export interface IAgenticaExecutor {
117
118
  * @param executes List of function calling results
118
119
  * @returns List of prompts generated by the describer
119
120
  */
120
- describe: (ctx: IAgenticaContext, executes: IAgenticaPrompt.IExecute[]) => Promise<IAgenticaPrompt[]>;
121
+ describe: (ctx: IAgenticaContext<Model>, executes: IAgenticaPrompt.IExecute<Model>[]) => Promise<IAgenticaPrompt<Model>[]>;
121
122
  /**
122
123
  * Function canceler agent.
123
124
  *
@@ -140,5 +141,5 @@ export interface IAgenticaExecutor {
140
141
  * @param ctx Context of the agent
141
142
  * @returns List of prompts generated by the canceler
142
143
  */
143
- cancel: (ctx: IAgenticaContext) => Promise<IAgenticaPrompt[]>;
144
+ cancel: (ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>;
144
145
  }
@@ -1,4 +1,4 @@
1
- import { IHttpLlmFunction } from "@samchon/openapi";
1
+ import { IHttpLlmFunction, ILlmSchema } from "@samchon/openapi";
2
2
  import { ILlmFunctionOfValidate } from "typia";
3
3
  import { IAgenticaController } from "./IAgenticaController";
4
4
  /**
@@ -16,16 +16,16 @@ import { IAgenticaController } from "./IAgenticaController";
16
16
  *
17
17
  * @author Samchon
18
18
  */
19
- export type IAgenticaOperation = IAgenticaOperation.IHttp | IAgenticaOperation.IClass;
19
+ export type IAgenticaOperation<Model extends ILlmSchema.Model> = IAgenticaOperation.IHttp<Model> | IAgenticaOperation.IClass<Model>;
20
20
  export declare namespace IAgenticaOperation {
21
21
  /**
22
22
  * HTTP API operation.
23
23
  */
24
- export type IHttp = IBase<"http", IAgenticaController.IHttp, IHttpLlmFunction<"chatgpt">>;
24
+ export type IHttp<Model extends ILlmSchema.Model> = IBase<"http", IAgenticaController.IHttp<Model>, IHttpLlmFunction<Model>>;
25
25
  /**
26
26
  * TypeScript class operation.
27
27
  */
28
- export type IClass = IBase<"class", IAgenticaController.IClass, ILlmFunctionOfValidate<"chatgpt">>;
28
+ export type IClass<Model extends ILlmSchema.Model> = IBase<"class", IAgenticaController.IClass<Model>, ILlmFunctionOfValidate<Model>>;
29
29
  interface IBase<Protocol, Application, Function> {
30
30
  /**
31
31
  * Protocol discriminator.
@@ -1,3 +1,4 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
1
2
  import { IAgenticaOperation } from "./IAgenticaOperation";
2
3
  /**
3
4
  * Collection of operations used in the Nestia Agent.
@@ -8,11 +9,11 @@ import { IAgenticaOperation } from "./IAgenticaOperation";
8
9
  *
9
10
  * @author Samchon
10
11
  */
11
- export interface IAgenticaOperationCollection {
12
+ export interface IAgenticaOperationCollection<Model extends ILlmSchema.Model> {
12
13
  /**
13
14
  * List of every operations.
14
15
  */
15
- array: IAgenticaOperation[];
16
+ array: IAgenticaOperation<Model>[];
16
17
  /**
17
18
  * Divided operations.
18
19
  *
@@ -28,13 +29,13 @@ export interface IAgenticaOperationCollection {
28
29
  * Otherwise, if the {@link IAgenticaConfig.capacity} has not been
29
30
  * configured, this `divided` property would be the `undefined` value.
30
31
  */
31
- divided?: IAgenticaOperation[][] | undefined;
32
+ divided?: IAgenticaOperation<Model>[][] | undefined;
32
33
  /**
33
34
  * Flat dictionary of operations.
34
35
  *
35
36
  * Dictionary of operations with their {@link IAgenticaOperation.name}.
36
37
  */
37
- flat: Map<string, IAgenticaOperation>;
38
+ flat: Map<string, IAgenticaOperation<Model>>;
38
39
  /**
39
40
  * Group dictionary of operations.
40
41
  *
@@ -42,5 +43,5 @@ export interface IAgenticaOperationCollection {
42
43
  * {@link IAgenticaOperation.controller.name} and
43
44
  * {@link IAgenticaOperation.function.name}.
44
45
  */
45
- group: Map<string, Map<string, IAgenticaOperation>>;
46
+ group: Map<string, Map<string, IAgenticaOperation<Model>>>;
46
47
  }
@@ -1,4 +1,4 @@
1
- import { IHttpLlmFunction } from "@samchon/openapi";
1
+ import { IHttpLlmFunction, ILlmSchema } from "@samchon/openapi";
2
2
  import { ILlmFunctionOfValidate } from "typia";
3
3
  import { IAgenticaController } from "./IAgenticaController";
4
4
  /**
@@ -14,10 +14,10 @@ import { IAgenticaController } from "./IAgenticaController";
14
14
  *
15
15
  * @author Samchon
16
16
  */
17
- export type IAgenticaOperationSelection = IAgenticaOperationSelection.IHttp | IAgenticaOperationSelection.IClass;
17
+ export type IAgenticaOperationSelection<Model extends ILlmSchema.Model> = IAgenticaOperationSelection.IHttp<Model> | IAgenticaOperationSelection.IClass<Model>;
18
18
  export declare namespace IAgenticaOperationSelection {
19
- export type IHttp = IBase<"http", IAgenticaController.IHttp, IHttpLlmFunction<"chatgpt">>;
20
- export type IClass = IBase<"class", IAgenticaController.IClass, ILlmFunctionOfValidate<"chatgpt">>;
19
+ export type IHttp<Model extends ILlmSchema.Model> = IBase<"http", IAgenticaController.IHttp<Model>, IHttpLlmFunction<Model>>;
20
+ export type IClass<Model extends ILlmSchema.Model> = IBase<"class", IAgenticaController.IClass<Model>, ILlmFunctionOfValidate<Model>>;
21
21
  interface IBase<Protocol, Controller, Function> {
22
22
  /**
23
23
  * Discriminator protocol.
@@ -1,4 +1,4 @@
1
- import { IHttpLlmFunction, IHttpResponse } from "@samchon/openapi";
1
+ import { IHttpLlmFunction, IHttpResponse, ILlmSchema } from "@samchon/openapi";
2
2
  import { ILlmFunctionOfValidate } from "typia";
3
3
  import { IAgenticaController } from "./IAgenticaController";
4
4
  import { IAgenticaOperationSelection } from "./IAgenticaOperationSelection";
@@ -18,14 +18,14 @@ import { IAgenticaOperationSelection } from "./IAgenticaOperationSelection";
18
18
  *
19
19
  * @author Samchon
20
20
  */
21
- export type IAgenticaPrompt = IAgenticaPrompt.IText | IAgenticaPrompt.ISelect | IAgenticaPrompt.ICancel | IAgenticaPrompt.IExecute | IAgenticaPrompt.IDescribe;
21
+ export type IAgenticaPrompt<Model extends ILlmSchema.Model> = IAgenticaPrompt.IText | IAgenticaPrompt.ISelect<Model> | IAgenticaPrompt.ICancel<Model> | IAgenticaPrompt.IExecute<Model> | IAgenticaPrompt.IDescribe<Model>;
22
22
  export declare namespace IAgenticaPrompt {
23
23
  /**
24
24
  * Select prompt.
25
25
  *
26
26
  * Selection prompt about candidate functions to call.
27
27
  */
28
- export interface ISelect extends IBase<"select"> {
28
+ export interface ISelect<Model extends ILlmSchema.Model> extends IBase<"select"> {
29
29
  /**
30
30
  * ID of the LLM tool call result.
31
31
  */
@@ -33,14 +33,14 @@ export declare namespace IAgenticaPrompt {
33
33
  /**
34
34
  * Operations that have been selected.
35
35
  */
36
- operations: IAgenticaOperationSelection[];
36
+ operations: IAgenticaOperationSelection<Model>[];
37
37
  }
38
38
  /**
39
39
  * Cancel prompt.
40
40
  *
41
41
  * Cancellation prompt about the candidate functions to be discarded.
42
42
  */
43
- export interface ICancel extends IBase<"cancel"> {
43
+ export interface ICancel<Model extends ILlmSchema.Model> extends IBase<"cancel"> {
44
44
  /**
45
45
  * ID of the LLM tool call result.
46
46
  */
@@ -48,17 +48,17 @@ export declare namespace IAgenticaPrompt {
48
48
  /**
49
49
  * Operations that have been cancelled.
50
50
  */
51
- operations: IAgenticaOperationSelection[];
51
+ operations: IAgenticaOperationSelection<Model>[];
52
52
  }
53
53
  /**
54
54
  * Execute prompt.
55
55
  *
56
56
  * Execution prompt about the LLM function calling.
57
57
  */
58
- export type IExecute = IExecute.IHttp | IExecute.IClass;
58
+ export type IExecute<Model extends ILlmSchema.Model> = IExecute.IHttp<Model> | IExecute.IClass<Model>;
59
59
  export namespace IExecute {
60
- export type IHttp = IBase<"http", IAgenticaController.IHttp, IHttpLlmFunction<"chatgpt">, IHttpResponse>;
61
- export type IClass = IBase<"class", IAgenticaController.IClass, ILlmFunctionOfValidate<"chatgpt">, any>;
60
+ export type IHttp<Model extends ILlmSchema.Model> = IBase<"http", IAgenticaController.IHttp<Model>, IHttpLlmFunction<Model>, IHttpResponse>;
61
+ export type IClass<Model extends ILlmSchema.Model> = IBase<"class", IAgenticaController.IClass<Model>, ILlmFunctionOfValidate<Model>, any>;
62
62
  interface IBase<Protocol, Controller, Function, Value> {
63
63
  /**
64
64
  * Discriminator type.
@@ -104,13 +104,13 @@ export declare namespace IAgenticaPrompt {
104
104
  *
105
105
  * Description prompt about the return value of the LLM function calling.
106
106
  */
107
- export interface IDescribe extends IBase<"describe"> {
107
+ export interface IDescribe<Model extends ILlmSchema.Model> extends IBase<"describe"> {
108
108
  /**
109
109
  * Executions of the LLM function calling.
110
110
  *
111
111
  * This prompt describes the return value of them.
112
112
  */
113
- executions: IExecute[];
113
+ executions: IExecute<Model>[];
114
114
  /**
115
115
  * Description text.
116
116
  */
@@ -1,3 +1,4 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
1
2
  import { Primitive } from "typia";
2
3
  import { IAgenticaConfig } from "./IAgenticaConfig";
3
4
  import { IAgenticaController } from "./IAgenticaController";
@@ -24,7 +25,11 @@ import { IAgenticaProvider } from "./IAgenticaProvider";
24
25
  *
25
26
  * @author Samchon
26
27
  */
27
- export interface IAgenticaProps {
28
+ export interface IAgenticaProps<Model extends ILlmSchema.Model> {
29
+ /**
30
+ * LLM schema model.
31
+ */
32
+ model: Model;
28
33
  /**
29
34
  * LLM service provider.
30
35
  */
@@ -32,7 +37,7 @@ export interface IAgenticaProps {
32
37
  /**
33
38
  * Controllers serving functions to call.
34
39
  */
35
- controllers: IAgenticaController[];
40
+ controllers: IAgenticaController<Model>[];
36
41
  /**
37
42
  * Configuration of agent.
38
43
  *
@@ -48,12 +53,12 @@ export interface IAgenticaProps {
48
53
  * - `systemPrompt`: default prompts written in markdown
49
54
  * - https://github.com/samchon/nestia/tree/master/packages/agent/prompts
50
55
  */
51
- config?: IAgenticaConfig;
56
+ config?: IAgenticaConfig<Model>;
52
57
  /**
53
58
  * Prompt histories.
54
59
  *
55
60
  * If you're starting the conversation from an existing session,
56
61
  * assign the previouis prompt histories to this property.
57
62
  */
58
- histories?: Primitive<IAgenticaPrompt>[];
63
+ histories?: Primitive<IAgenticaPrompt<Model>>[];
59
64
  }
@@ -5,37 +5,32 @@ import OpenAI from "openai";
5
5
  * `IAgenticaProvider` is a type represents an LLM
6
6
  * (Large Language Model) provider of the {@link Agentica}.
7
7
  *
8
- * Currently, {@link Agentica} is supporting only one provider OpenAI.
9
- * You can specify the provider by configuring the `type` property as
10
- * `"chatgpt"`. Also, you have to assign the OpenAI API client instance
11
- * to the `api` property, and specify the `model` to use.
8
+ * Currently, {@link Agentica} supports OpenAI SDK. However, it does
9
+ * not mean that you can use only OpenAI's GPT model in the
10
+ * {@link Agentica}. The OpenAI SDK is just a connection tool to the
11
+ * LLM provider's API, and you can use other LLM providers by configuring
12
+ * its `baseURL` and API key.
12
13
  *
13
- * If you want to use another LLM provider like Claude or Gemini,
14
- * please write an issue or contribute to `nestia` please.
14
+ * Therefore, if you want to use another LLM provider like Claude or
15
+ * Gemini, please configure the `baseURL` to the {@link api}, and
16
+ * set {@link IAgenticaController}'s schema model as "cluade" or
17
+ * "gemini".
15
18
  *
16
19
  * @author Samchon
17
20
  */
18
- export type IAgenticaProvider = IAgenticaProvider.IChatGpt;
19
- export declare namespace IAgenticaProvider {
21
+ export interface IAgenticaProvider {
20
22
  /**
21
- * OpenAI provider.
23
+ * OpenAI API instance.
22
24
  */
23
- interface IChatGpt {
24
- /**
25
- * Discriminator type.
26
- */
27
- type: "chatgpt";
28
- /**
29
- * OpenAI API instance.
30
- */
31
- api: OpenAI;
32
- /**
33
- * Chat model to be used.
34
- */
35
- model: OpenAI.ChatModel;
36
- /**
37
- * Options for the request.
38
- */
39
- options?: OpenAI.RequestOptions | undefined;
40
- }
25
+ api: OpenAI;
26
+ /**
27
+ * Chat model to be used.
28
+ *
29
+ * `({}) & string` means to support third party hosting cloud(eg. openRouter, aws)
30
+ */
31
+ model: OpenAI.ChatModel | ({} & string);
32
+ /**
33
+ * Options for the request.
34
+ */
35
+ options?: OpenAI.RequestOptions | undefined;
41
36
  }
@@ -1,3 +1,4 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
1
2
  import { IAgenticaConfig } from "./IAgenticaConfig";
2
3
  import { IAgenticaPrompt } from "./IAgenticaPrompt";
3
4
  /**
@@ -18,7 +19,7 @@ import { IAgenticaPrompt } from "./IAgenticaPrompt";
18
19
  *
19
20
  * @author Samchon
20
21
  */
21
- export interface IAgenticaSystemPrompt {
22
+ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
22
23
  /**
23
24
  * Common system prompt that would be used in every situation.
24
25
  *
@@ -26,7 +27,7 @@ export interface IAgenticaSystemPrompt {
26
27
  * @returns The common system prompt
27
28
  * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/common.md
28
29
  */
29
- common?: (config?: IAgenticaConfig | undefined) => string;
30
+ common?: (config?: IAgenticaConfig<Model> | undefined) => string;
30
31
  /**
31
32
  * Initialize system prompt.
32
33
  *
@@ -43,7 +44,7 @@ export interface IAgenticaSystemPrompt {
43
44
  * @returns initialize system prompt
44
45
  * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/initialize.md
45
46
  */
46
- initialize?: (histories: IAgenticaPrompt[]) => string;
47
+ initialize?: (histories: IAgenticaPrompt<Model>[]) => string;
47
48
  /**
48
49
  * Select system prompt.
49
50
  *
@@ -63,7 +64,7 @@ export interface IAgenticaSystemPrompt {
63
64
  * @returns select system promopt
64
65
  * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/select.md
65
66
  */
66
- select?: (histories: IAgenticaPrompt[]) => string;
67
+ select?: (histories: IAgenticaPrompt<Model>[]) => string;
67
68
  /**
68
69
  * Cancel system prompt.
69
70
  *
@@ -79,7 +80,7 @@ export interface IAgenticaSystemPrompt {
79
80
  * @returns cancel system prompt
80
81
  * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/cancel.md
81
82
  */
82
- cancel?: (histories: IAgenticaPrompt[]) => string;
83
+ cancel?: (histories: IAgenticaPrompt<Model>[]) => string;
83
84
  /**
84
85
  * Execute system prompt.
85
86
  *
@@ -96,7 +97,7 @@ export interface IAgenticaSystemPrompt {
96
97
  * @returns execute system prompt
97
98
  * https://github.com/samchon/nestia/blob/master/packages/agent/prompts/execute.md
98
99
  */
99
- execute?: (histories: IAgenticaPrompt[]) => string;
100
+ execute?: (histories: IAgenticaPrompt<Model>[]) => string;
100
101
  /**
101
102
  * Describe system prompt.
102
103
  *
@@ -112,5 +113,5 @@ export interface IAgenticaSystemPrompt {
112
113
  * @returns describe system prompt
113
114
  * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/describe.md
114
115
  */
115
- describe?: (histories: IAgenticaPrompt.IExecute[]) => string;
116
+ describe?: (histories: IAgenticaPrompt.IExecute<Model>[]) => string;
116
117
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentica/core",
3
- "version": "0.8.3-dev.20250227",
3
+ "version": "0.9.0-dev.20250302",
4
4
  "main": "lib/index.js",
5
5
  "description": "Agentic AI Library specialized in LLM Function Calling",
6
6
  "scripts": {
@@ -45,7 +45,6 @@
45
45
  "@nestia/e2e": "^0.8.2",
46
46
  "@rollup/plugin-terser": "^0.4.4",
47
47
  "@rollup/plugin-typescript": "^12.1.2",
48
- "@samchon/openapi": "^2.4.2",
49
48
  "@trivago/prettier-plugin-sort-imports": "^5.2.2",
50
49
  "@types/node": "^22.13.4",
51
50
  "@types/uuid": "^10.0.0",
@@ -57,18 +56,16 @@
57
56
  "ts-node": "^10.9.2",
58
57
  "ts-patch": "^3.3.0",
59
58
  "typedoc": "^0.27.7",
60
- "typescript": "~5.7.3",
61
- "typia": "^7.6.4"
59
+ "typescript": "~5.8.2"
62
60
  },
63
61
  "dependencies": {
64
- "@samchon/openapi": "^2.4.3",
65
- "typia": "^7.6.4",
62
+ "@samchon/openapi": "^3.0.0",
63
+ "typia": "^8.0.0",
66
64
  "uuid": "^11.0.4"
67
65
  },
68
66
  "peerDependencies": {
69
- "@samchon/openapi": ">= 2.4.3",
70
- "openai": ">= 4.80.0",
71
- "typia": ">= 7.6.4"
67
+ "@samchon/openapi": ">=3.0.0 <4.0.0",
68
+ "openai": ">=4.80.0"
72
69
  },
73
70
  "module": "lib/index.mjs",
74
71
  "typings": "lib/index.d.ts"
package/src/Agentica.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
1
2
  import OpenAI from "openai";
2
3
 
3
4
  import { ChatGptAgent } from "./chatgpt/ChatGptAgent";
@@ -44,21 +45,21 @@ import { IAgenticaTokenUsage } from "./structures/IAgenticaTokenUsage";
44
45
  *
45
46
  * @author Samchon
46
47
  */
47
- export class Agentica {
48
+ export class Agentica<Model extends ILlmSchema.Model> {
48
49
  // THE OPERATIONS
49
- private readonly operations_: IAgenticaOperationCollection;
50
+ private readonly operations_: IAgenticaOperationCollection<Model>;
50
51
 
51
52
  // STACK
52
- private readonly stack_: IAgenticaOperationSelection[];
53
- private readonly prompt_histories_: IAgenticaPrompt[];
53
+ private readonly stack_: IAgenticaOperationSelection<Model>[];
54
+ private readonly prompt_histories_: IAgenticaPrompt<Model>[];
54
55
  private readonly listeners_: Map<string, Set<Function>>;
55
56
 
56
57
  // STATUS
57
58
  private readonly token_usage_: IAgenticaTokenUsage;
58
59
  private ready_: boolean;
59
60
  private readonly executor_: (
60
- ctx: IAgenticaContext,
61
- ) => Promise<IAgenticaPrompt[]>;
61
+ ctx: IAgenticaContext<Model>,
62
+ ) => Promise<IAgenticaPrompt<Model>[]>;
62
63
 
63
64
  /* -----------------------------------------------------------
64
65
  CONSTRUCTOR
@@ -68,7 +69,7 @@ export class Agentica {
68
69
  *
69
70
  * @param props Properties to construct the agent
70
71
  */
71
- public constructor(private readonly props: IAgenticaProps) {
72
+ public constructor(private readonly props: IAgenticaProps<Model>) {
72
73
  // OPERATIONS
73
74
  this.operations_ = AgenticaOperationComposer.compose({
74
75
  controllers: props.controllers,
@@ -97,7 +98,7 @@ export class Agentica {
97
98
  /**
98
99
  * @internal
99
100
  */
100
- public clone(): Agentica {
101
+ public clone(): Agentica<Model> {
101
102
  return new Agentica({
102
103
  ...this.props,
103
104
  histories: this.props.histories?.slice(),
@@ -119,7 +120,7 @@ export class Agentica {
119
120
  * @param content The content to talk
120
121
  * @returns List of newly created chat prompts
121
122
  */
122
- public async conversate(content: string): Promise<IAgenticaPrompt[]> {
123
+ public async conversate(content: string): Promise<IAgenticaPrompt<Model>[]> {
123
124
  const prompt: IAgenticaPrompt.IText<"user"> = {
124
125
  type: "text",
125
126
  role: "user",
@@ -127,7 +128,7 @@ export class Agentica {
127
128
  };
128
129
  await this.dispatch(prompt);
129
130
 
130
- const newbie: IAgenticaPrompt[] = await this.executor_(
131
+ const newbie: IAgenticaPrompt<Model>[] = await this.executor_(
131
132
  this.getContext({
132
133
  prompt,
133
134
  usage: this.token_usage_,
@@ -140,7 +141,7 @@ export class Agentica {
140
141
  /**
141
142
  * Get configuration.
142
143
  */
143
- public getConfig(): IAgenticaConfig | undefined {
144
+ public getConfig(): IAgenticaConfig<Model> | undefined {
144
145
  return this.props.config;
145
146
  }
146
147
 
@@ -157,7 +158,7 @@ export class Agentica {
157
158
  * Get list of controllers, which are the collection of functions that
158
159
  * the "Super A.I. Chatbot" can execute.
159
160
  */
160
- public getControllers(): ReadonlyArray<IAgenticaController> {
161
+ public getControllers(): ReadonlyArray<IAgenticaController<Model>> {
161
162
  return this.props.controllers;
162
163
  }
163
164
 
@@ -169,7 +170,7 @@ export class Agentica {
169
170
  *
170
171
  * @returns
171
172
  */
172
- public getOperations(): ReadonlyArray<IAgenticaOperation> {
173
+ public getOperations(): ReadonlyArray<IAgenticaOperation<Model>> {
173
174
  return this.operations_.array;
174
175
  }
175
176
 
@@ -180,7 +181,7 @@ export class Agentica {
180
181
  *
181
182
  * @returns List of chat prompts
182
183
  */
183
- public getPromptHistories(): IAgenticaPrompt[] {
184
+ public getPromptHistories(): IAgenticaPrompt<Model>[] {
184
185
  return this.prompt_histories_;
185
186
  }
186
187
 
@@ -202,8 +203,8 @@ export class Agentica {
202
203
  public getContext(props: {
203
204
  prompt: IAgenticaPrompt.IText<"user">;
204
205
  usage: IAgenticaTokenUsage;
205
- }): IAgenticaContext {
206
- const dispatch = (event: IAgenticaEvent) => this.dispatch(event);
206
+ }): IAgenticaContext<Model> {
207
+ const dispatch = (event: IAgenticaEvent<Model>) => this.dispatch(event);
207
208
  return {
208
209
  // APPLICATION
209
210
  operations: this.operations_,
@@ -272,7 +273,9 @@ export class Agentica {
272
273
  */
273
274
  public on<Type extends IAgenticaEvent.Type>(
274
275
  type: Type,
275
- listener: (event: IAgenticaEvent.Mapper[Type]) => void | Promise<void>,
276
+ listener: (
277
+ event: IAgenticaEvent.Mapper<Model>[Type],
278
+ ) => void | Promise<void>,
276
279
  ): this {
277
280
  __map_take(this.listeners_, type, () => new Set()).add(listener);
278
281
  return this;
@@ -288,7 +291,9 @@ export class Agentica {
288
291
  */
289
292
  public off<Type extends IAgenticaEvent.Type>(
290
293
  type: Type,
291
- listener: (event: IAgenticaEvent.Mapper[Type]) => void | Promise<void>,
294
+ listener: (
295
+ event: IAgenticaEvent.Mapper<Model>[Type],
296
+ ) => void | Promise<void>,
292
297
  ): this {
293
298
  const set = this.listeners_.get(type);
294
299
  if (set) {
@@ -298,7 +303,7 @@ export class Agentica {
298
303
  return this;
299
304
  }
300
305
 
301
- private async dispatch<Event extends IAgenticaEvent>(
306
+ private async dispatch<Event extends IAgenticaEvent<Model>>(
302
307
  event: Event,
303
308
  ): Promise<void> {
304
309
  const set = this.listeners_.get(event.type);
@@ -1,3 +1,5 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
2
+
1
3
  import { IAgenticaContext } from "../structures/IAgenticaContext";
2
4
  import { IAgenticaExecutor } from "../structures/IAgenticaExecutor";
3
5
  import { IAgenticaPrompt } from "../structures/IAgenticaPrompt";
@@ -9,9 +11,11 @@ import { ChatGptSelectFunctionAgent } from "./ChatGptSelectFunctionAgent";
9
11
 
10
12
  export namespace ChatGptAgent {
11
13
  export const execute =
12
- (executor: Partial<IAgenticaExecutor> | null) =>
13
- async (ctx: IAgenticaContext): Promise<IAgenticaPrompt[]> => {
14
- const histories: IAgenticaPrompt[] = [];
14
+ <Model extends ILlmSchema.Model>(
15
+ executor: Partial<IAgenticaExecutor<Model>> | null,
16
+ ) =>
17
+ async (ctx: IAgenticaContext<Model>): Promise<IAgenticaPrompt<Model>[]> => {
18
+ const histories: IAgenticaPrompt<Model>[] = [];
15
19
 
16
20
  // FUNCTIONS ARE NOT LISTED YET
17
21
  if (ctx.ready() === false) {
@@ -45,13 +49,13 @@ export namespace ChatGptAgent {
45
49
  // FUNCTION CALLING LOOP
46
50
  while (true) {
47
51
  // EXECUTE FUNCTIONS
48
- const prompts: IAgenticaPrompt[] = await (
52
+ const prompts: IAgenticaPrompt<Model>[] = await (
49
53
  executor?.call ?? ChatGptCallFunctionAgent.execute
50
54
  )(ctx);
51
55
  histories.push(...prompts);
52
56
 
53
57
  // EXPLAIN RETURN VALUES
54
- const executes: IAgenticaPrompt.IExecute[] = prompts.filter(
58
+ const executes: IAgenticaPrompt.IExecute<Model>[] = prompts.filter(
55
59
  (prompt) => prompt.type === "execute",
56
60
  );
57
61
  for (const e of executes)