@agentica/core 0.7.0-dev.20250224

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 (163) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +464 -0
  3. package/lib/Agentica.d.ts +124 -0
  4. package/lib/Agentica.js +271 -0
  5. package/lib/Agentica.js.map +1 -0
  6. package/lib/chatgpt/ChatGptAgent.d.ts +6 -0
  7. package/lib/chatgpt/ChatGptAgent.js +59 -0
  8. package/lib/chatgpt/ChatGptAgent.js.map +1 -0
  9. package/lib/chatgpt/ChatGptCallFunctionAgent.d.ts +5 -0
  10. package/lib/chatgpt/ChatGptCallFunctionAgent.js +362 -0
  11. package/lib/chatgpt/ChatGptCallFunctionAgent.js.map +1 -0
  12. package/lib/chatgpt/ChatGptCancelFunctionAgent.d.ts +8 -0
  13. package/lib/chatgpt/ChatGptCancelFunctionAgent.js +359 -0
  14. package/lib/chatgpt/ChatGptCancelFunctionAgent.js.map +1 -0
  15. package/lib/chatgpt/ChatGptDescribeFunctionAgent.d.ts +5 -0
  16. package/lib/chatgpt/ChatGptDescribeFunctionAgent.js +56 -0
  17. package/lib/chatgpt/ChatGptDescribeFunctionAgent.js.map +1 -0
  18. package/lib/chatgpt/ChatGptHistoryDecoder.d.ts +5 -0
  19. package/lib/chatgpt/ChatGptHistoryDecoder.js +77 -0
  20. package/lib/chatgpt/ChatGptHistoryDecoder.js.map +1 -0
  21. package/lib/chatgpt/ChatGptInitializeFunctionAgent.d.ts +5 -0
  22. package/lib/chatgpt/ChatGptInitializeFunctionAgent.js +1883 -0
  23. package/lib/chatgpt/ChatGptInitializeFunctionAgent.js.map +1 -0
  24. package/lib/chatgpt/ChatGptSelectFunctionAgent.d.ts +5 -0
  25. package/lib/chatgpt/ChatGptSelectFunctionAgent.js +381 -0
  26. package/lib/chatgpt/ChatGptSelectFunctionAgent.js.map +1 -0
  27. package/lib/functional/createHttpLlmApplication.d.ts +33 -0
  28. package/lib/functional/createHttpLlmApplication.js +7766 -0
  29. package/lib/functional/createHttpLlmApplication.js.map +1 -0
  30. package/lib/index.d.ts +16 -0
  31. package/lib/index.js +35 -0
  32. package/lib/index.js.map +1 -0
  33. package/lib/index.mjs +10366 -0
  34. package/lib/index.mjs.map +1 -0
  35. package/lib/internal/AgenticaConstant.d.ts +4 -0
  36. package/lib/internal/AgenticaConstant.js +9 -0
  37. package/lib/internal/AgenticaConstant.js.map +1 -0
  38. package/lib/internal/AgenticaCostAggregator.d.ts +5 -0
  39. package/lib/internal/AgenticaCostAggregator.js +30 -0
  40. package/lib/internal/AgenticaCostAggregator.js.map +1 -0
  41. package/lib/internal/AgenticaDefaultPrompt.d.ts +4 -0
  42. package/lib/internal/AgenticaDefaultPrompt.js +32 -0
  43. package/lib/internal/AgenticaDefaultPrompt.js.map +1 -0
  44. package/lib/internal/AgenticaOperationComposer.d.ts +9 -0
  45. package/lib/internal/AgenticaOperationComposer.js +58 -0
  46. package/lib/internal/AgenticaOperationComposer.js.map +1 -0
  47. package/lib/internal/AgenticaPromptFactory.d.ts +6 -0
  48. package/lib/internal/AgenticaPromptFactory.js +9 -0
  49. package/lib/internal/AgenticaPromptFactory.js.map +1 -0
  50. package/lib/internal/AgenticaPromptTransformer.d.ts +9 -0
  51. package/lib/internal/AgenticaPromptTransformer.js +58 -0
  52. package/lib/internal/AgenticaPromptTransformer.js.map +1 -0
  53. package/lib/internal/AgenticaSystemPrompt.d.ts +8 -0
  54. package/lib/internal/AgenticaSystemPrompt.js +13 -0
  55. package/lib/internal/AgenticaSystemPrompt.js.map +1 -0
  56. package/lib/internal/MathUtil.d.ts +3 -0
  57. package/lib/internal/MathUtil.js +8 -0
  58. package/lib/internal/MathUtil.js.map +1 -0
  59. package/lib/internal/Singleton.d.ts +1 -0
  60. package/lib/internal/Singleton.js +23 -0
  61. package/lib/internal/Singleton.js.map +1 -0
  62. package/lib/internal/__map_take.d.ts +1 -0
  63. package/lib/internal/__map_take.js +16 -0
  64. package/lib/internal/__map_take.js.map +1 -0
  65. package/lib/structures/IAgenticaConfig.d.ts +112 -0
  66. package/lib/structures/IAgenticaConfig.js +3 -0
  67. package/lib/structures/IAgenticaConfig.js.map +1 -0
  68. package/lib/structures/IAgenticaContext.d.ts +106 -0
  69. package/lib/structures/IAgenticaContext.js +3 -0
  70. package/lib/structures/IAgenticaContext.js.map +1 -0
  71. package/lib/structures/IAgenticaController.d.ts +110 -0
  72. package/lib/structures/IAgenticaController.js +3 -0
  73. package/lib/structures/IAgenticaController.js.map +1 -0
  74. package/lib/structures/IAgenticaEvent.d.ts +191 -0
  75. package/lib/structures/IAgenticaEvent.js +3 -0
  76. package/lib/structures/IAgenticaEvent.js.map +1 -0
  77. package/lib/structures/IAgenticaExecutor.d.ts +144 -0
  78. package/lib/structures/IAgenticaExecutor.js +3 -0
  79. package/lib/structures/IAgenticaExecutor.js.map +1 -0
  80. package/lib/structures/IAgenticaOperation.d.ts +48 -0
  81. package/lib/structures/IAgenticaOperation.js +3 -0
  82. package/lib/structures/IAgenticaOperation.js.map +1 -0
  83. package/lib/structures/IAgenticaOperationCollection.d.ts +46 -0
  84. package/lib/structures/IAgenticaOperationCollection.js +3 -0
  85. package/lib/structures/IAgenticaOperationCollection.js.map +1 -0
  86. package/lib/structures/IAgenticaOperationSelection.d.ts +51 -0
  87. package/lib/structures/IAgenticaOperationSelection.js +3 -0
  88. package/lib/structures/IAgenticaOperationSelection.js.map +1 -0
  89. package/lib/structures/IAgenticaPrompt.d.ts +139 -0
  90. package/lib/structures/IAgenticaPrompt.js +3 -0
  91. package/lib/structures/IAgenticaPrompt.js.map +1 -0
  92. package/lib/structures/IAgenticaProps.d.ts +59 -0
  93. package/lib/structures/IAgenticaProps.js +3 -0
  94. package/lib/structures/IAgenticaProps.js.map +1 -0
  95. package/lib/structures/IAgenticaProvider.d.ts +41 -0
  96. package/lib/structures/IAgenticaProvider.js +3 -0
  97. package/lib/structures/IAgenticaProvider.js.map +1 -0
  98. package/lib/structures/IAgenticaSystemPrompt.d.ts +116 -0
  99. package/lib/structures/IAgenticaSystemPrompt.js +3 -0
  100. package/lib/structures/IAgenticaSystemPrompt.js.map +1 -0
  101. package/lib/structures/IAgenticaTokenUsage.d.ts +50 -0
  102. package/lib/structures/IAgenticaTokenUsage.js +3 -0
  103. package/lib/structures/IAgenticaTokenUsage.js.map +1 -0
  104. package/lib/structures/internal/__IChatCancelFunctionsApplication.d.ts +22 -0
  105. package/lib/structures/internal/__IChatCancelFunctionsApplication.js +3 -0
  106. package/lib/structures/internal/__IChatCancelFunctionsApplication.js.map +1 -0
  107. package/lib/structures/internal/__IChatFunctionReference.d.ts +20 -0
  108. package/lib/structures/internal/__IChatFunctionReference.js +3 -0
  109. package/lib/structures/internal/__IChatFunctionReference.js.map +1 -0
  110. package/lib/structures/internal/__IChatInitialApplication.d.ts +14 -0
  111. package/lib/structures/internal/__IChatInitialApplication.js +3 -0
  112. package/lib/structures/internal/__IChatInitialApplication.js.map +1 -0
  113. package/lib/structures/internal/__IChatSelectFunctionsApplication.d.ts +23 -0
  114. package/lib/structures/internal/__IChatSelectFunctionsApplication.js +3 -0
  115. package/lib/structures/internal/__IChatSelectFunctionsApplication.js.map +1 -0
  116. package/lib/typings/AgenticaSource.d.ts +1 -0
  117. package/lib/typings/AgenticaSource.js +3 -0
  118. package/lib/typings/AgenticaSource.js.map +1 -0
  119. package/package.json +74 -0
  120. package/prompts/cancel.md +5 -0
  121. package/prompts/common.md +3 -0
  122. package/prompts/describe.md +7 -0
  123. package/prompts/execute.md +7 -0
  124. package/prompts/initialize.md +3 -0
  125. package/prompts/select.md +7 -0
  126. package/src/Agentica.ts +322 -0
  127. package/src/chatgpt/ChatGptAgent.ts +71 -0
  128. package/src/chatgpt/ChatGptCallFunctionAgent.ts +445 -0
  129. package/src/chatgpt/ChatGptCancelFunctionAgent.ts +283 -0
  130. package/src/chatgpt/ChatGptDescribeFunctionAgent.ts +51 -0
  131. package/src/chatgpt/ChatGptHistoryDecoder.ts +86 -0
  132. package/src/chatgpt/ChatGptInitializeFunctionAgent.ts +88 -0
  133. package/src/chatgpt/ChatGptSelectFunctionAgent.ts +316 -0
  134. package/src/functional/createHttpLlmApplication.ts +63 -0
  135. package/src/index.ts +19 -0
  136. package/src/internal/AgenticaConstant.ts +4 -0
  137. package/src/internal/AgenticaCostAggregator.ts +35 -0
  138. package/src/internal/AgenticaDefaultPrompt.ts +39 -0
  139. package/src/internal/AgenticaOperationComposer.ts +82 -0
  140. package/src/internal/AgenticaPromptFactory.ts +30 -0
  141. package/src/internal/AgenticaPromptTransformer.ts +83 -0
  142. package/src/internal/AgenticaSystemPrompt.ts +14 -0
  143. package/src/internal/MathUtil.ts +3 -0
  144. package/src/internal/Singleton.ts +22 -0
  145. package/src/internal/__map_take.ts +15 -0
  146. package/src/structures/IAgenticaConfig.ts +121 -0
  147. package/src/structures/IAgenticaContext.ts +128 -0
  148. package/src/structures/IAgenticaController.ts +130 -0
  149. package/src/structures/IAgenticaEvent.ts +224 -0
  150. package/src/structures/IAgenticaExecutor.ts +152 -0
  151. package/src/structures/IAgenticaOperation.ts +64 -0
  152. package/src/structures/IAgenticaOperationCollection.ts +50 -0
  153. package/src/structures/IAgenticaOperationSelection.ts +69 -0
  154. package/src/structures/IAgenticaPrompt.ts +173 -0
  155. package/src/structures/IAgenticaProps.ts +64 -0
  156. package/src/structures/IAgenticaProvider.ts +45 -0
  157. package/src/structures/IAgenticaSystemPrompt.ts +122 -0
  158. package/src/structures/IAgenticaTokenUsage.ts +52 -0
  159. package/src/structures/internal/__IChatCancelFunctionsApplication.ts +23 -0
  160. package/src/structures/internal/__IChatFunctionReference.ts +21 -0
  161. package/src/structures/internal/__IChatInitialApplication.ts +15 -0
  162. package/src/structures/internal/__IChatSelectFunctionsApplication.ts +24 -0
  163. package/src/typings/AgenticaSource.ts +6 -0
@@ -0,0 +1,46 @@
1
+ import { IAgenticaOperation } from "./IAgenticaOperation";
2
+ /**
3
+ * Collection of operations used in the Nestia Agent.
4
+ *
5
+ * `IAgenticaOperationCollection` is an interface type representing
6
+ * a collection of operations for several purposes used in the
7
+ * {@link Agentica} internally.
8
+ *
9
+ * @author Samchon
10
+ */
11
+ export interface IAgenticaOperationCollection {
12
+ /**
13
+ * List of every operations.
14
+ */
15
+ array: IAgenticaOperation[];
16
+ /**
17
+ * Divided operations.
18
+ *
19
+ * If you've configured the {@link IAgenticaConfig.capacity} property,
20
+ * the A.I. chatbot ({@link Agentica}) will separate the operations
21
+ * into the several groups to divide and conquer and LLM function selecting
22
+ * for accuracy.
23
+ *
24
+ * In that case, this property `divided`'s length would be dtermined by
25
+ * dividing the number of operations ({@link array}'s length) by the
26
+ * {@link IAgenticaConfig.capacity}.
27
+ *
28
+ * Otherwise, if the {@link IAgenticaConfig.capacity} has not been
29
+ * configured, this `divided` property would be the `undefined` value.
30
+ */
31
+ divided?: IAgenticaOperation[][] | undefined;
32
+ /**
33
+ * Flat dictionary of operations.
34
+ *
35
+ * Dictionary of operations with their {@link IAgenticaOperation.name}.
36
+ */
37
+ flat: Map<string, IAgenticaOperation>;
38
+ /**
39
+ * Group dictionary of operations.
40
+ *
41
+ * Dictionary of operations with their
42
+ * {@link IAgenticaOperation.controller.name} and
43
+ * {@link IAgenticaOperation.function.name}.
44
+ */
45
+ group: Map<string, Map<string, IAgenticaOperation>>;
46
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IAgenticaOperationCollection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAgenticaOperationCollection.js","sourceRoot":"","sources":["../../src/structures/IAgenticaOperationCollection.ts"],"names":[],"mappings":""}
@@ -0,0 +1,51 @@
1
+ import { IHttpLlmFunction } from "@samchon/openapi";
2
+ import { ILlmFunctionOfValidate } from "typia";
3
+ import { IAgenticaController } from "./IAgenticaController";
4
+ /**
5
+ * Nestia agent operation selection.
6
+ *
7
+ * `IAgenticaOperationSelection` is a type represents an operation
8
+ * which has been selected by the A.I. chatbot of {@link Agentica}
9
+ * class for the LLM (Large Language Model) function calling with
10
+ * detailed {@link reason} of the selection (or cancellation).
11
+ *
12
+ * Also, `IAgenticaOperationSelection` is an union type that can
13
+ * specify a subtype by checking the {@link protocol} property.
14
+ *
15
+ * @author Samchon
16
+ */
17
+ export type IAgenticaOperationSelection = IAgenticaOperationSelection.IHttp | IAgenticaOperationSelection.IClass;
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">>;
21
+ interface IBase<Protocol, Controller, Function> {
22
+ /**
23
+ * Discriminator protocol.
24
+ */
25
+ protocol: Protocol;
26
+ /**
27
+ * Belonged controller of the target function.
28
+ */
29
+ controller: Controller;
30
+ /**
31
+ * Target function.
32
+ *
33
+ * Function that has been selected to prepare LLM function calling,
34
+ * or canceled due to no more required.
35
+ */
36
+ function: Function;
37
+ /**
38
+ * Identifier name of the target function.
39
+ *
40
+ * If {@link Agentica} has multiple {@link IAgenticaController}s,
41
+ * the `name` can be different from target function's name.
42
+ */
43
+ name: string;
44
+ /**
45
+ * The reason of the function selection or cancellation.
46
+ */
47
+ reason: string;
48
+ toJSON(): Omit<IBase<Protocol, string, string>, "toJSON">;
49
+ }
50
+ export {};
51
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IAgenticaOperationSelection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAgenticaOperationSelection.js","sourceRoot":"","sources":["../../src/structures/IAgenticaOperationSelection.ts"],"names":[],"mappings":""}
@@ -0,0 +1,139 @@
1
+ import { IHttpLlmFunction, IHttpResponse } from "@samchon/openapi";
2
+ import { ILlmFunctionOfValidate } from "typia";
3
+ import { IAgenticaController } from "./IAgenticaController";
4
+ import { IAgenticaOperationSelection } from "./IAgenticaOperationSelection";
5
+ /**
6
+ * Nestia A.I. chatbot prompt.
7
+ *
8
+ * `IWrtnChatPrompt` is an union type of all possible prompts that can
9
+ * be generated by the A.I. chatbot of the {@link Agentica} class.
10
+ *
11
+ * In other words, `IWrtnChatPrompt` is a type of chat history that
12
+ * is occurred during the conversation between the user and the A.I. chatbot
13
+ * in the {@link Agentica} class.
14
+ *
15
+ * If you want to continue the previous A.I. chatbot session, you can
16
+ * accomplish it by assigning the {@link IAgenticaProps.histories}
17
+ * property when creating a new {@link Agentica} instance.
18
+ *
19
+ * @author Samchon
20
+ */
21
+ export type IAgenticaPrompt = IAgenticaPrompt.IText | IAgenticaPrompt.ISelect | IAgenticaPrompt.ICancel | IAgenticaPrompt.IExecute | IAgenticaPrompt.IDescribe;
22
+ export declare namespace IAgenticaPrompt {
23
+ /**
24
+ * Select prompt.
25
+ *
26
+ * Selection prompt about candidate functions to call.
27
+ */
28
+ export interface ISelect extends IBase<"select"> {
29
+ /**
30
+ * ID of the LLM tool call result.
31
+ */
32
+ id: string;
33
+ /**
34
+ * Operations that have been selected.
35
+ */
36
+ operations: IAgenticaOperationSelection[];
37
+ }
38
+ /**
39
+ * Cancel prompt.
40
+ *
41
+ * Cancellation prompt about the candidate functions to be discarded.
42
+ */
43
+ export interface ICancel extends IBase<"cancel"> {
44
+ /**
45
+ * ID of the LLM tool call result.
46
+ */
47
+ id: string;
48
+ /**
49
+ * Operations that have been cancelled.
50
+ */
51
+ operations: IAgenticaOperationSelection[];
52
+ }
53
+ /**
54
+ * Execute prompt.
55
+ *
56
+ * Execution prompt about the LLM function calling.
57
+ */
58
+ export type IExecute = IExecute.IHttp | IExecute.IClass;
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>;
62
+ interface IBase<Protocol, Controller, Function, Value> {
63
+ /**
64
+ * Discriminator type.
65
+ */
66
+ type: "execute";
67
+ /**
68
+ * Protocol discriminator.
69
+ */
70
+ protocol: Protocol;
71
+ /**
72
+ * Belonged controller of the target function.
73
+ */
74
+ controller: Controller;
75
+ /**
76
+ * Target function to call.
77
+ */
78
+ function: Function;
79
+ /**
80
+ * ID of the LLM tool call result.
81
+ */
82
+ id: string;
83
+ /**
84
+ * Identifier name of the function.
85
+ *
86
+ * If {@link Agentica} has multiple {@link IAgenticaController}s,
87
+ * the `name` can be different from target function's name.
88
+ */
89
+ name: string;
90
+ /**
91
+ * Arguments of the LLM function calling.
92
+ */
93
+ arguments: object;
94
+ /**
95
+ * Return value.
96
+ */
97
+ value: Value;
98
+ toJSON(): Omit<IBase<Protocol, string, string, Value>, "toJSON">;
99
+ }
100
+ export {};
101
+ }
102
+ /**
103
+ * Description prompt.
104
+ *
105
+ * Description prompt about the return value of the LLM function calling.
106
+ */
107
+ export interface IDescribe extends IBase<"describe"> {
108
+ /**
109
+ * Executions of the LLM function calling.
110
+ *
111
+ * This prompt describes the return value of them.
112
+ */
113
+ executions: IExecute[];
114
+ /**
115
+ * Description text.
116
+ */
117
+ text: string;
118
+ }
119
+ /**
120
+ * Text prompt.
121
+ */
122
+ export interface IText<Role extends "assistant" | "user" = "assistant" | "user"> extends IBase<"text"> {
123
+ /**
124
+ * Role of the orator.
125
+ */
126
+ role: Role;
127
+ /**
128
+ * The text content.
129
+ */
130
+ text: string;
131
+ }
132
+ interface IBase<Type extends string> {
133
+ /**
134
+ * Discriminator type.
135
+ */
136
+ type: Type;
137
+ }
138
+ export {};
139
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IAgenticaPrompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAgenticaPrompt.js","sourceRoot":"","sources":["../../src/structures/IAgenticaPrompt.ts"],"names":[],"mappings":""}
@@ -0,0 +1,59 @@
1
+ import { Primitive } from "typia";
2
+ import { IAgenticaConfig } from "./IAgenticaConfig";
3
+ import { IAgenticaController } from "./IAgenticaController";
4
+ import { IAgenticaPrompt } from "./IAgenticaPrompt";
5
+ import { IAgenticaProvider } from "./IAgenticaProvider";
6
+ /**
7
+ * Properties of the Nestia Agent.
8
+ *
9
+ * `IAgenticaProps` is an interface that defines the properties
10
+ * of the {@link Agentica.constructor}. In the `IAgenticaProps`,
11
+ * there're everything to prepare to create a Super A.I. chatbot
12
+ * performing the LLM (Large Language Model) function calling.
13
+ *
14
+ * At first, you have to specify the LLM service {@link provider} like
15
+ * OpenAI with its API key and client API. And then, you have to define
16
+ * the {@link controllers} serving the functions to call. The controllers
17
+ * are separated by two protocols; HTTP API and TypeScript class. At last,
18
+ * you can {@link config configure} the agent by setting the locale, timezone,
19
+ * and some of system prompts.
20
+ *
21
+ * Additionally, if you want to start from the previous A.I. chatbot
22
+ * session, you can accomplish it by assigning the previous prompt
23
+ * histories to the {@link histories} property.
24
+ *
25
+ * @author Samchon
26
+ */
27
+ export interface IAgenticaProps {
28
+ /**
29
+ * LLM service provider.
30
+ */
31
+ provider: IAgenticaProvider;
32
+ /**
33
+ * Controllers serving functions to call.
34
+ */
35
+ controllers: IAgenticaController[];
36
+ /**
37
+ * Configuration of agent.
38
+ *
39
+ * Configuration of A.I. chatbot agent including the user's locale,
40
+ * timezone, and some of system prompts. Also, you can affect to the
41
+ * LLM function selecting/calling logic by configuring additional
42
+ * properties.
43
+ *
44
+ * If you don't configure this property, these values would be default.
45
+ *
46
+ * - `locale`: your system's locale and timezone
47
+ * - `timezone`: your system's timezone
48
+ * - `systemPrompt`: default prompts written in markdown
49
+ * - https://github.com/samchon/nestia/tree/master/packages/agent/prompts
50
+ */
51
+ config?: IAgenticaConfig;
52
+ /**
53
+ * Prompt histories.
54
+ *
55
+ * If you're starting the conversation from an existing session,
56
+ * assign the previouis prompt histories to this property.
57
+ */
58
+ histories?: Primitive<IAgenticaPrompt>[];
59
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IAgenticaProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAgenticaProps.js","sourceRoot":"","sources":["../../src/structures/IAgenticaProps.ts"],"names":[],"mappings":""}
@@ -0,0 +1,41 @@
1
+ import OpenAI from "openai";
2
+ /**
3
+ * LLM Provider for Nestia Chat.
4
+ *
5
+ * `IAgenticaProvider` is a type represents an LLM
6
+ * (Large Language Model) provider of the {@link Agentica}.
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.
12
+ *
13
+ * If you want to use another LLM provider like Claude or Gemini,
14
+ * please write an issue or contribute to `nestia` please.
15
+ *
16
+ * @author Samchon
17
+ */
18
+ export type IAgenticaProvider = IAgenticaProvider.IChatGpt;
19
+ export declare namespace IAgenticaProvider {
20
+ /**
21
+ * OpenAI provider.
22
+ */
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
+ }
41
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IAgenticaProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAgenticaProvider.js","sourceRoot":"","sources":["../../src/structures/IAgenticaProvider.ts"],"names":[],"mappings":""}
@@ -0,0 +1,116 @@
1
+ import { IAgenticaConfig } from "./IAgenticaConfig";
2
+ import { IAgenticaPrompt } from "./IAgenticaPrompt";
3
+ /**
4
+ * System prompt collection of the A.I. chatbot.
5
+ *
6
+ * `IAgenticaSystemPrompt` is a type represents a collection of system
7
+ * prompts that would be used by the A.I. chatbot of {@link Agentica}.
8
+ *
9
+ * You can customize the system prompt by configuring the
10
+ * {@link IAgenticaConfig.systemPrompt} property when creating a new
11
+ * {@link Agentica} instance.
12
+ *
13
+ * If you don't configure any system prompts, the default system prompts
14
+ * would be used which are written in the below directory as markdown
15
+ * documents.
16
+ *
17
+ * - https://github.com/samchon/nestia/tree/master/packages/agent/prompts
18
+ *
19
+ * @author Samchon
20
+ */
21
+ export interface IAgenticaSystemPrompt {
22
+ /**
23
+ * Common system prompt that would be used in every situation.
24
+ *
25
+ * @param config Configuration of the agent
26
+ * @returns The common system prompt
27
+ * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/common.md
28
+ */
29
+ common?: (config?: IAgenticaConfig | undefined) => string;
30
+ /**
31
+ * Initialize system prompt.
32
+ *
33
+ * When the A.I. chatbot has not informed any functions to the agent
34
+ * yet because the user has not implied any function calling request yet,
35
+ * {@link Agentica} says that it is a circumstance that nothing has
36
+ * been initialized yet.
37
+ *
38
+ * In that case, the `initialize` system prompt would be used. You can
39
+ * customize the `initialize` system prompt by assigning this function
40
+ * with the given {@link IAgenticaPrompt histories} parameter.
41
+ *
42
+ * @param histories Histories of the previous prompts
43
+ * @returns initialize system prompt
44
+ * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/initialize.md
45
+ */
46
+ initialize?: (histories: IAgenticaPrompt[]) => string;
47
+ /**
48
+ * Select system prompt.
49
+ *
50
+ * The {@link Agentica} has a process selecting some candidate
51
+ * functions to call by asking to the A.I. agent with the previous
52
+ * prompt histories.
53
+ *
54
+ * In that case, this `select` system prompt would be used. You can
55
+ * customize it by assigning this function with the given
56
+ * {@link IAgenticaPrompt histories} parameter.
57
+ *
58
+ * Note that, the `"select"` means only the function selection. It does
59
+ * not contain the filling argument or executing the function. It
60
+ * literally contains only the selection process.
61
+ *
62
+ * @param histories Histories of the previous prompts
63
+ * @returns select system promopt
64
+ * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/select.md
65
+ */
66
+ select?: (histories: IAgenticaPrompt[]) => string;
67
+ /**
68
+ * Cancel system prompt.
69
+ *
70
+ * The {@link Agentica} has a process canceling some candidate
71
+ * functions to call by asking to the A.I. agent with the previous
72
+ * prompt histories.
73
+ *
74
+ * In that case, this `cancel` system prompt would be used. You can
75
+ * customize it by assigning this function with the given
76
+ * {@link IAgenticaPrompt histories} parameter.
77
+ *
78
+ * @param histories Histories of the previous prompts
79
+ * @returns cancel system prompt
80
+ * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/cancel.md
81
+ */
82
+ cancel?: (histories: IAgenticaPrompt[]) => string;
83
+ /**
84
+ * Execute system prompt.
85
+ *
86
+ * The {@link Agentica} has a process filling the arguments of some
87
+ * selected candidate functions by the LLM (Large Language Model)
88
+ * function calling feature with the previous prompt histories, and
89
+ * executing the arguments filled function with validation feedback.
90
+ *
91
+ * In that case, this `execute` system prompt would be used. You can
92
+ * customize it by assigning this function with the given
93
+ * {@link IAgenticaPrompt histories} parameter.
94
+ *
95
+ * @param histories Histories of the previous prompts
96
+ * @returns execute system prompt
97
+ * https://github.com/samchon/nestia/blob/master/packages/agent/prompts/execute.md
98
+ */
99
+ execute?: (histories: IAgenticaPrompt[]) => string;
100
+ /**
101
+ * Describe system prompt.
102
+ *
103
+ * The {@link Agentica} has a process describing the return values of
104
+ * the executed functions by requesting to the A.I. agent with the
105
+ * previous prompt histories.
106
+ *
107
+ * In that case, this `describe` system prompt would be used. You can
108
+ * customize it by assigning this function with the given
109
+ * {@link IAgenticaPrompt histories} parameter.
110
+ *
111
+ * @param histories Histories of the previous prompts
112
+ * @returns describe system prompt
113
+ * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/describe.md
114
+ */
115
+ describe?: (histories: IAgenticaPrompt.IExecute[]) => string;
116
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IAgenticaSystemPrompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAgenticaSystemPrompt.js","sourceRoot":"","sources":["../../src/structures/IAgenticaSystemPrompt.ts"],"names":[],"mappings":""}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Token usage information from the A.I. chatbot.
3
+ *
4
+ * `IAgenticaTokenUsage` is a structure representing the token usage
5
+ * information from the {@link Agentica} class. And you can get the
6
+ * token usage information by calling the {@link Agentica.getTokenUsage}
7
+ * method.
8
+ *
9
+ * For reference, `IAgenticaTokenUsage` provides only the token usage
10
+ * information, and does not contain any price or cost information. It is
11
+ * because the price or cost can be changed by below reasons.
12
+ *
13
+ * - Type of {@link IAgenticaProps.provider LLM provider}
14
+ * - {@link IAgenticaProvider.model} in the LLM provider.
15
+ * - Just by a policy change of the LLM provider company.
16
+ *
17
+ * @author Samchon
18
+ */
19
+ export interface IAgenticaTokenUsage {
20
+ /**
21
+ * Total token usage.
22
+ */
23
+ total: number;
24
+ /**
25
+ * Token usage in the prompt.
26
+ *
27
+ * In other words, it is called as the input token.
28
+ */
29
+ prompt: IAgenticaTokenUsage.IPrompt;
30
+ /**
31
+ * Token usage in the completion.
32
+ *
33
+ * In other words, it is called as the output token.
34
+ */
35
+ completion: IAgenticaTokenUsage.ICompletion;
36
+ }
37
+ export declare namespace IAgenticaTokenUsage {
38
+ interface IPrompt {
39
+ total: number;
40
+ audio: number;
41
+ cached: number;
42
+ }
43
+ interface ICompletion {
44
+ total: number;
45
+ accepted_prediction: number;
46
+ audio: number;
47
+ reasoning: number;
48
+ rejected_prediction: number;
49
+ }
50
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IAgenticaTokenUsage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAgenticaTokenUsage.js","sourceRoot":"","sources":["../../src/structures/IAgenticaTokenUsage.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import { __IChatFunctionReference } from "./__IChatFunctionReference";
2
+ export interface __IChatCancelFunctionsApplication {
3
+ /**
4
+ * Cancel a function from the candidate list to call.
5
+ *
6
+ * If you A.I. agent has understood that the user wants to cancel
7
+ * some candidate functions to call from the conversation, please cancel
8
+ * them through this function.
9
+ *
10
+ * Also, when you A.I. find a function that has been selected by the candidate
11
+ * pooling, cancel the function by calling this function. For reference, the
12
+ * candidate pooling means that user wants only one function to call, but you A.I.
13
+ * agent selects multiple candidate functions because the A.I. agent can't specify
14
+ * only one thing due to lack of specificity or homogeneity of candidate functions.
15
+ *
16
+ * Additionally, if you A.I. agent wants to cancel same function multiply, you can
17
+ * do it by assigning the same function name multiply in the `functions` property.
18
+ *
19
+ * @param props Properties of the function
20
+ */
21
+ cancelFunctions(props: __IChatFunctionReference.IProps): Promise<void>;
22
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=__IChatCancelFunctionsApplication.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"__IChatCancelFunctionsApplication.js","sourceRoot":"","sources":["../../../src/structures/internal/__IChatCancelFunctionsApplication.ts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ export interface __IChatFunctionReference {
2
+ /**
3
+ * The reason of the function selection.
4
+ *
5
+ * Just write the reason why you've determined to select this function.
6
+ */
7
+ reason: string;
8
+ /**
9
+ * Name of the target function to call.
10
+ */
11
+ name: string;
12
+ }
13
+ export declare namespace __IChatFunctionReference {
14
+ interface IProps {
15
+ /**
16
+ * List of target functions.
17
+ */
18
+ functions: __IChatFunctionReference[];
19
+ }
20
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=__IChatFunctionReference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"__IChatFunctionReference.js","sourceRoot":"","sources":["../../../src/structures/internal/__IChatFunctionReference.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import { IHttpLlmFunction } from "@samchon/openapi";
2
+ export interface __IChatInitialApplication {
3
+ /**
4
+ * Get list of API functions.
5
+ *
6
+ * If user seems like to request some function calling except this one,
7
+ * call this `getApiFunctions()` to get the list of candidate API functions
8
+ * provided from this application.
9
+ *
10
+ * Also, user just wants to list up every remote API functions that can be
11
+ * called from the backend server, utilize this function too.
12
+ */
13
+ getApiFunctions({}: {}): Promise<Array<IHttpLlmFunction<"chatgpt">>>;
14
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=__IChatInitialApplication.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"__IChatInitialApplication.js","sourceRoot":"","sources":["../../../src/structures/internal/__IChatInitialApplication.ts"],"names":[],"mappings":""}