@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.
- package/lib/Agentica.d.ts +9 -10
- package/lib/Agentica.js.map +1 -1
- package/lib/MicroAgentica.d.ts +9 -10
- package/lib/MicroAgentica.js.map +1 -1
- package/lib/constants/AgenticaDefaultPrompt.d.ts +1 -2
- package/lib/constants/AgenticaDefaultPrompt.js.map +1 -1
- package/lib/context/AgenticaContext.d.ts +6 -7
- package/lib/context/AgenticaOperation.d.ts +5 -5
- package/lib/context/AgenticaOperationCollection.d.ts +5 -6
- package/lib/context/AgenticaOperationSelection.d.ts +2 -3
- package/lib/context/MicroAgenticaContext.d.ts +5 -6
- package/lib/context/internal/AgenticaOperationComposer.js.map +1 -1
- package/lib/context/internal/AgenticaOperationComposer.spec.js +41 -9
- package/lib/context/internal/AgenticaOperationComposer.spec.js.map +1 -1
- package/lib/context/internal/__IChatInitialApplication.d.ts +1 -1
- package/lib/context/internal/isAgenticaContext.js.map +1 -1
- package/lib/events/AgenticaCallEvent.d.ts +2 -3
- package/lib/events/AgenticaCancelEvent.d.ts +2 -3
- package/lib/events/AgenticaDescribeEvent.d.ts +3 -4
- package/lib/events/AgenticaEvent.d.ts +10 -11
- package/lib/events/AgenticaExecuteEvent.d.ts +5 -5
- package/lib/events/AgenticaJsonParseErrorEvent.d.ts +2 -3
- package/lib/events/AgenticaSelectEvent.d.ts +3 -4
- package/lib/events/AgenticaValidateEvent.d.ts +2 -3
- package/lib/events/MicroAgenticaEvent.d.ts +8 -9
- package/lib/factory/events.d.ts +22 -22
- package/lib/factory/events.js.map +1 -1
- package/lib/factory/histories.js.map +1 -1
- package/lib/factory/operations.d.ts +3 -4
- package/lib/factory/operations.js.map +1 -1
- package/lib/functional/assertHttpController.d.ts +6 -10
- package/lib/functional/assertHttpController.js +775 -91
- package/lib/functional/assertHttpController.js.map +1 -1
- package/lib/functional/assertHttpLlmApplication.d.ts +4 -8
- package/lib/functional/assertHttpLlmApplication.js +775 -91
- package/lib/functional/assertHttpLlmApplication.js.map +1 -1
- package/lib/functional/assertMcpController.d.ts +5 -6
- package/lib/functional/assertMcpController.js +201 -32
- package/lib/functional/assertMcpController.js.map +1 -1
- package/lib/functional/validateHttpController.d.ts +6 -10
- package/lib/functional/validateHttpController.js +636 -89
- package/lib/functional/validateHttpController.js.map +1 -1
- package/lib/functional/validateHttpLlmApplication.d.ts +4 -8
- package/lib/functional/validateHttpLlmApplication.js +636 -89
- package/lib/functional/validateHttpLlmApplication.js.map +1 -1
- package/lib/functional/validateMcpController.d.ts +5 -6
- package/lib/functional/validateMcpController.js +366 -61
- package/lib/functional/validateMcpController.js.map +1 -1
- package/lib/histories/AgenticaCancelHistory.d.ts +2 -3
- package/lib/histories/AgenticaDescribeHistory.d.ts +2 -3
- package/lib/histories/AgenticaExecuteHistory.d.ts +5 -5
- package/lib/histories/AgenticaHistory.d.ts +7 -8
- package/lib/histories/AgenticaSelectHistory.d.ts +2 -3
- package/lib/histories/MicroAgenticaHistory.d.ts +5 -6
- package/lib/index.mjs +3964 -849
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/call.d.ts +1 -2
- package/lib/orchestrate/call.js.map +1 -1
- package/lib/orchestrate/cancel.d.ts +1 -2
- package/lib/orchestrate/cancel.js +4 -4
- package/lib/orchestrate/cancel.js.map +1 -1
- package/lib/orchestrate/describe.d.ts +1 -2
- package/lib/orchestrate/describe.js.map +1 -1
- package/lib/orchestrate/execute.d.ts +1 -2
- package/lib/orchestrate/execute.js.map +1 -1
- package/lib/orchestrate/initialize.d.ts +1 -2
- package/lib/orchestrate/initialize.js +262 -83
- package/lib/orchestrate/initialize.js.map +1 -1
- package/lib/orchestrate/internal/cancelFunctionFromContext.js.map +1 -1
- package/lib/orchestrate/internal/selectFunctionFromContext.js.map +1 -1
- package/lib/orchestrate/select.d.ts +1 -2
- package/lib/orchestrate/select.js +4 -4
- package/lib/orchestrate/select.js.map +1 -1
- package/lib/structures/IAgenticaConfig.d.ts +3 -4
- package/lib/structures/IAgenticaController.d.ts +11 -14
- package/lib/structures/IAgenticaExecutor.d.ts +6 -7
- package/lib/structures/IAgenticaProps.d.ts +3 -8
- package/lib/structures/IAgenticaSystemPrompt.d.ts +9 -10
- package/lib/structures/IMicroAgenticaConfig.d.ts +3 -4
- package/lib/structures/IMicroAgenticaExecutor.d.ts +3 -4
- package/lib/structures/IMicroAgenticaProps.d.ts +3 -8
- package/lib/structures/IMicroAgenticaSystemPrompt.d.ts +6 -7
- package/lib/transformers/transformHistory.js.map +1 -1
- package/lib/utils/ChatGptCompletionStreamingUtil.spec.js +2 -2
- package/lib/utils/ChatGptCompletionStreamingUtil.spec.js.map +1 -1
- package/lib/utils/request.d.ts +2 -3
- package/lib/utils/request.js.map +1 -1
- package/package.json +8 -8
- package/src/Agentica.ts +24 -26
- package/src/MicroAgentica.ts +27 -29
- package/src/constants/AgenticaDefaultPrompt.ts +2 -4
- package/src/context/AgenticaContext.ts +6 -7
- package/src/context/AgenticaOperation.ts +14 -14
- package/src/context/AgenticaOperationCollection.ts +5 -8
- package/src/context/AgenticaOperationSelection.ts +2 -4
- package/src/context/MicroAgenticaContext.ts +5 -6
- package/src/context/internal/AgenticaOperationComposer.spec.ts +50 -18
- package/src/context/internal/AgenticaOperationComposer.ts +21 -23
- package/src/context/internal/__IChatInitialApplication.ts +1 -1
- package/src/context/internal/isAgenticaContext.ts +4 -6
- package/src/events/AgenticaCallEvent.ts +2 -5
- package/src/events/AgenticaCancelEvent.ts +2 -6
- package/src/events/AgenticaDescribeEvent.ts +3 -7
- package/src/events/AgenticaEvent.ts +17 -19
- package/src/events/AgenticaEvent.type.ts +1 -1
- package/src/events/AgenticaExecuteEvent.ts +12 -12
- package/src/events/AgenticaJsonParseErrorEvent.ts +2 -4
- package/src/events/AgenticaSelectEvent.ts +3 -7
- package/src/events/AgenticaValidateEvent.ts +2 -5
- package/src/events/MicroAgenticaEvent.ts +13 -15
- package/src/factory/events.ts +24 -24
- package/src/factory/histories.ts +15 -17
- package/src/factory/operations.ts +3 -5
- package/src/functional/assertHttpController.ts +7 -15
- package/src/functional/assertHttpLlmApplication.ts +4 -13
- package/src/functional/assertMcpController.ts +6 -8
- package/src/functional/validateHttpController.ts +7 -15
- package/src/functional/validateHttpLlmApplication.ts +4 -13
- package/src/functional/validateMcpController.ts +6 -11
- package/src/histories/AgenticaCancelHistory.ts +2 -6
- package/src/histories/AgenticaDescribeHistory.ts +2 -6
- package/src/histories/AgenticaExecuteHistory.ts +7 -9
- package/src/histories/AgenticaHistory.ts +11 -13
- package/src/histories/AgenticaSelectHistory.ts +2 -6
- package/src/histories/MicroAgenticaHistory.ts +7 -9
- package/src/orchestrate/call.ts +55 -56
- package/src/orchestrate/cancel.ts +11 -12
- package/src/orchestrate/describe.ts +4 -5
- package/src/orchestrate/execute.ts +3 -5
- package/src/orchestrate/initialize.ts +4 -5
- package/src/orchestrate/internal/cancelFunctionFromContext.ts +4 -6
- package/src/orchestrate/internal/selectFunctionFromContext.ts +5 -9
- package/src/orchestrate/select.ts +11 -12
- package/src/structures/IAgenticaConfig.ts +4 -6
- package/src/structures/IAgenticaController.ts +11 -14
- package/src/structures/IAgenticaExecutor.ts +9 -11
- package/src/structures/IAgenticaProps.ts +3 -10
- package/src/structures/IAgenticaSystemPrompt.ts +9 -11
- package/src/structures/IMicroAgenticaConfig.ts +3 -5
- package/src/structures/IMicroAgenticaExecutor.ts +4 -6
- package/src/structures/IMicroAgenticaProps.ts +3 -10
- package/src/structures/IMicroAgenticaSystemPrompt.ts +6 -8
- package/src/transformers/transformHistory.ts +19 -21
- package/src/utils/ChatGptCompletionStreamingUtil.spec.ts +4 -5
- package/src/utils/request.ts +2 -3
|
@@ -5,7 +5,6 @@ import type {
|
|
|
5
5
|
IHttpResponse,
|
|
6
6
|
ILlmApplication,
|
|
7
7
|
ILlmFunction,
|
|
8
|
-
ILlmSchema,
|
|
9
8
|
IMcpLlmApplication,
|
|
10
9
|
} from "@samchon/openapi";
|
|
11
10
|
|
|
@@ -25,10 +24,10 @@ import type {
|
|
|
25
24
|
*
|
|
26
25
|
* @author Samchon
|
|
27
26
|
*/
|
|
28
|
-
export type IAgenticaController
|
|
29
|
-
| IAgenticaController.IHttp
|
|
30
|
-
| IAgenticaController.IClass
|
|
31
|
-
| IAgenticaController.IMcp
|
|
27
|
+
export type IAgenticaController =
|
|
28
|
+
| IAgenticaController.IHttp
|
|
29
|
+
| IAgenticaController.IClass
|
|
30
|
+
| IAgenticaController.IMcp;
|
|
32
31
|
|
|
33
32
|
export namespace IAgenticaController {
|
|
34
33
|
/**
|
|
@@ -37,8 +36,7 @@ export namespace IAgenticaController {
|
|
|
37
36
|
* You can make it by {@link validateHttpLlmApplication} function with
|
|
38
37
|
* the Swagger or OpenAPI document.
|
|
39
38
|
*/
|
|
40
|
-
export interface IHttp
|
|
41
|
-
extends IBase<"http", IHttpLlmApplication<Model>> {
|
|
39
|
+
export interface IHttp extends IBase<"http", IHttpLlmApplication> {
|
|
42
40
|
/**
|
|
43
41
|
* Connection to the server.
|
|
44
42
|
*
|
|
@@ -61,12 +59,12 @@ export namespace IAgenticaController {
|
|
|
61
59
|
/**
|
|
62
60
|
* Application schema.
|
|
63
61
|
*/
|
|
64
|
-
application: IHttpLlmApplication
|
|
62
|
+
application: IHttpLlmApplication;
|
|
65
63
|
|
|
66
64
|
/**
|
|
67
65
|
* Function schema.
|
|
68
66
|
*/
|
|
69
|
-
function: IHttpLlmFunction
|
|
67
|
+
function: IHttpLlmFunction;
|
|
70
68
|
|
|
71
69
|
/**
|
|
72
70
|
* Arguments of the function calling.
|
|
@@ -89,8 +87,7 @@ export namespace IAgenticaController {
|
|
|
89
87
|
*
|
|
90
88
|
* - https://typia.io/docs/llm/application
|
|
91
89
|
*/
|
|
92
|
-
export interface IClass
|
|
93
|
-
extends IBase<"class", ILlmApplication<Model>> {
|
|
90
|
+
export interface IClass extends IBase<"class", ILlmApplication> {
|
|
94
91
|
/**
|
|
95
92
|
* Executor of the class function.
|
|
96
93
|
*
|
|
@@ -104,12 +101,12 @@ export namespace IAgenticaController {
|
|
|
104
101
|
/**
|
|
105
102
|
* Target application schema.
|
|
106
103
|
*/
|
|
107
|
-
application: ILlmApplication
|
|
104
|
+
application: ILlmApplication;
|
|
108
105
|
|
|
109
106
|
/**
|
|
110
107
|
* Target function schema.
|
|
111
108
|
*/
|
|
112
|
-
function: ILlmFunction
|
|
109
|
+
function: ILlmFunction;
|
|
113
110
|
|
|
114
111
|
/**
|
|
115
112
|
* Arguments of the function calling.
|
|
@@ -121,7 +118,7 @@ export namespace IAgenticaController {
|
|
|
121
118
|
/**
|
|
122
119
|
* MCP Server controller.
|
|
123
120
|
*/
|
|
124
|
-
export interface IMcp
|
|
121
|
+
export interface IMcp extends IBase<"mcp", IMcpLlmApplication> {
|
|
125
122
|
/**
|
|
126
123
|
* MCP client for connection.
|
|
127
124
|
*
|
|
@@ -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 { AgenticaExecuteEvent } from "../events/AgenticaExecuteEvent";
|
|
@@ -27,7 +25,7 @@ import type { AgenticaExecuteEvent } from "../events/AgenticaExecuteEvent";
|
|
|
27
25
|
* @reference https://github.com/wrtnlabs/agentica/blob/main/packages/core/src/orchestrate/execute.ts
|
|
28
26
|
* @author Samchon
|
|
29
27
|
*/
|
|
30
|
-
export interface IAgenticaExecutor
|
|
28
|
+
export interface IAgenticaExecutor {
|
|
31
29
|
/**
|
|
32
30
|
* Initializer agent listing up functions.
|
|
33
31
|
*
|
|
@@ -60,7 +58,7 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
|
|
|
60
58
|
initialize:
|
|
61
59
|
| boolean
|
|
62
60
|
| null
|
|
63
|
-
| ((ctx: AgenticaContext
|
|
61
|
+
| ((ctx: AgenticaContext) => Promise<void>);
|
|
64
62
|
|
|
65
63
|
/**
|
|
66
64
|
* Function selector agent.
|
|
@@ -89,7 +87,7 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
|
|
|
89
87
|
* @param ctx Context of the agent
|
|
90
88
|
* @returns List of prompts generated by the selector
|
|
91
89
|
*/
|
|
92
|
-
select: (ctx: AgenticaContext
|
|
90
|
+
select: (ctx: AgenticaContext) => Promise<void>;
|
|
93
91
|
|
|
94
92
|
/**
|
|
95
93
|
* Function caller agent.
|
|
@@ -118,9 +116,9 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
|
|
|
118
116
|
* applied to all domain fields.
|
|
119
117
|
*/
|
|
120
118
|
call: (
|
|
121
|
-
ctx: AgenticaContext
|
|
122
|
-
operations: AgenticaOperation
|
|
123
|
-
) => Promise<AgenticaExecuteEvent
|
|
119
|
+
ctx: AgenticaContext,
|
|
120
|
+
operations: AgenticaOperation[],
|
|
121
|
+
) => Promise<AgenticaExecuteEvent[]>;
|
|
124
122
|
|
|
125
123
|
/**
|
|
126
124
|
* Describer agent of the function calling result.
|
|
@@ -139,8 +137,8 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
|
|
|
139
137
|
| boolean
|
|
140
138
|
| null
|
|
141
139
|
| ((
|
|
142
|
-
ctx: AgenticaContext
|
|
143
|
-
executes: AgenticaExecuteEvent
|
|
140
|
+
ctx: AgenticaContext,
|
|
141
|
+
executes: AgenticaExecuteEvent[],
|
|
144
142
|
) => Promise<void>);
|
|
145
143
|
|
|
146
144
|
/**
|
|
@@ -165,5 +163,5 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
|
|
|
165
163
|
* @param ctx Context of the agent
|
|
166
164
|
* @returns List of prompts generated by the canceler
|
|
167
165
|
*/
|
|
168
|
-
cancel: (ctx: AgenticaContext
|
|
166
|
+
cancel: (ctx: AgenticaContext) => Promise<void>;
|
|
169
167
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
|
|
3
1
|
import type { AgenticaTokenUsage } from "../context/AgenticaTokenUsage";
|
|
4
2
|
import type { IAgenticaHistoryJson } from "../json/IAgenticaHistoryJson";
|
|
5
3
|
import type { IAgenticaTokenUsageJson } from "../json/IAgenticaTokenUsageJson";
|
|
@@ -29,12 +27,7 @@ import type { IAgenticaVendor } from "./IAgenticaVendor";
|
|
|
29
27
|
*
|
|
30
28
|
* @author Samchon
|
|
31
29
|
*/
|
|
32
|
-
export interface IAgenticaProps
|
|
33
|
-
/**
|
|
34
|
-
* LLM schema model.
|
|
35
|
-
*/
|
|
36
|
-
model: Model;
|
|
37
|
-
|
|
30
|
+
export interface IAgenticaProps {
|
|
38
31
|
/**
|
|
39
32
|
* LLM service vendor.
|
|
40
33
|
*/
|
|
@@ -43,7 +36,7 @@ export interface IAgenticaProps<Model extends ILlmSchema.Model> {
|
|
|
43
36
|
/**
|
|
44
37
|
* Controllers serving functions to call.
|
|
45
38
|
*/
|
|
46
|
-
controllers: IAgenticaController
|
|
39
|
+
controllers: IAgenticaController[];
|
|
47
40
|
|
|
48
41
|
/**
|
|
49
42
|
* Configuration of agent.
|
|
@@ -60,7 +53,7 @@ export interface IAgenticaProps<Model extends ILlmSchema.Model> {
|
|
|
60
53
|
* - `systemPrompt`: default prompts written in markdown
|
|
61
54
|
* - https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts
|
|
62
55
|
*/
|
|
63
|
-
config?: IAgenticaConfig
|
|
56
|
+
config?: IAgenticaConfig;
|
|
64
57
|
|
|
65
58
|
/**
|
|
66
59
|
* Prompt histories.
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
|
|
3
1
|
import type { AgenticaJsonParseErrorEvent } from "../events";
|
|
4
2
|
import type { AgenticaValidateEvent } from "../events/AgenticaValidateEvent";
|
|
5
3
|
import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory";
|
|
@@ -25,7 +23,7 @@ import type { IAgenticaConfig } from "./IAgenticaConfig";
|
|
|
25
23
|
*
|
|
26
24
|
* @author Samchon
|
|
27
25
|
*/
|
|
28
|
-
export interface IAgenticaSystemPrompt
|
|
26
|
+
export interface IAgenticaSystemPrompt {
|
|
29
27
|
/**
|
|
30
28
|
* Common system prompt that would be used in every situation.
|
|
31
29
|
*
|
|
@@ -38,7 +36,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
38
36
|
* @returns The common system prompt
|
|
39
37
|
* @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/common.md
|
|
40
38
|
*/
|
|
41
|
-
common?: (config?: IAgenticaConfig
|
|
39
|
+
common?: (config?: IAgenticaConfig | undefined) => string;
|
|
42
40
|
|
|
43
41
|
/**
|
|
44
42
|
* Initialize system prompt.
|
|
@@ -63,7 +61,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
63
61
|
* @returns initialize system prompt
|
|
64
62
|
* @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/initialize.md
|
|
65
63
|
*/
|
|
66
|
-
initialize?: (histories: AgenticaHistory
|
|
64
|
+
initialize?: (histories: AgenticaHistory[]) => string;
|
|
67
65
|
|
|
68
66
|
/**
|
|
69
67
|
* Select system prompt.
|
|
@@ -91,7 +89,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
91
89
|
* @returns select system prompt
|
|
92
90
|
* @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/select.md
|
|
93
91
|
*/
|
|
94
|
-
select?: (histories: AgenticaHistory
|
|
92
|
+
select?: (histories: AgenticaHistory[]) => string;
|
|
95
93
|
|
|
96
94
|
/**
|
|
97
95
|
* Cancel system prompt.
|
|
@@ -113,7 +111,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
113
111
|
* @returns cancel system prompt
|
|
114
112
|
* @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/cancel.md
|
|
115
113
|
*/
|
|
116
|
-
cancel?: (histories: AgenticaHistory
|
|
114
|
+
cancel?: (histories: AgenticaHistory[]) => string;
|
|
117
115
|
|
|
118
116
|
/**
|
|
119
117
|
* Execute system prompt.
|
|
@@ -140,7 +138,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
140
138
|
* @returns execute system prompt
|
|
141
139
|
* @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/execute.md
|
|
142
140
|
*/
|
|
143
|
-
execute?: (histories: AgenticaHistory
|
|
141
|
+
execute?: (histories: AgenticaHistory[]) => string;
|
|
144
142
|
|
|
145
143
|
/**
|
|
146
144
|
* Validation feedback system prompt.
|
|
@@ -173,7 +171,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
173
171
|
* @returns validation feedback system prompt
|
|
174
172
|
* @default Built-in validation feedback prompt optimized for typia IValidation.IFailure processing
|
|
175
173
|
*/
|
|
176
|
-
validate?: (events: AgenticaValidateEvent
|
|
174
|
+
validate?: (events: AgenticaValidateEvent[]) => string;
|
|
177
175
|
|
|
178
176
|
/**
|
|
179
177
|
* JSON parsing error system prompt.
|
|
@@ -204,7 +202,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
204
202
|
* @returns JSON parse error system prompt
|
|
205
203
|
* @default Built-in JSON parse error prompt optimized for syntax correction
|
|
206
204
|
*/
|
|
207
|
-
jsonParseError?: (event: AgenticaJsonParseErrorEvent
|
|
205
|
+
jsonParseError?: (event: AgenticaJsonParseErrorEvent) => string;
|
|
208
206
|
|
|
209
207
|
/**
|
|
210
208
|
* Describe system prompt.
|
|
@@ -234,5 +232,5 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
234
232
|
* @returns describe system prompt
|
|
235
233
|
* @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/describe.md
|
|
236
234
|
*/
|
|
237
|
-
describe?: (histories: AgenticaExecuteHistory
|
|
235
|
+
describe?: (histories: AgenticaExecuteHistory[]) => string;
|
|
238
236
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
|
|
3
1
|
import type { IMicroAgenticaExecutor } from "./IMicroAgenticaExecutor";
|
|
4
2
|
import type { IMicroAgenticaSystemPrompt } from "./IMicroAgenticaSystemPrompt";
|
|
5
3
|
|
|
@@ -13,7 +11,7 @@ import type { IMicroAgenticaSystemPrompt } from "./IMicroAgenticaSystemPrompt";
|
|
|
13
11
|
*
|
|
14
12
|
* @author Samchon
|
|
15
13
|
*/
|
|
16
|
-
export interface IMicroAgenticaConfig
|
|
14
|
+
export interface IMicroAgenticaConfig {
|
|
17
15
|
/**
|
|
18
16
|
* Agent executor.
|
|
19
17
|
*
|
|
@@ -31,7 +29,7 @@ export interface IMicroAgenticaConfig<Model extends ILlmSchema.Model> {
|
|
|
31
29
|
*/
|
|
32
30
|
executor?:
|
|
33
31
|
| undefined
|
|
34
|
-
| Partial<IMicroAgenticaExecutor
|
|
32
|
+
| Partial<IMicroAgenticaExecutor>;
|
|
35
33
|
|
|
36
34
|
/**
|
|
37
35
|
* System prompt messages.
|
|
@@ -39,7 +37,7 @@ export interface IMicroAgenticaConfig<Model extends ILlmSchema.Model> {
|
|
|
39
37
|
* System prompt messages if you want to customize the system prompt
|
|
40
38
|
* messages for each situation.
|
|
41
39
|
*/
|
|
42
|
-
systemPrompt?: IMicroAgenticaSystemPrompt
|
|
40
|
+
systemPrompt?: IMicroAgenticaSystemPrompt;
|
|
43
41
|
|
|
44
42
|
/**
|
|
45
43
|
* Locale of the A.I. chatbot.
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
|
|
3
1
|
import type { MicroAgenticaContext } from "../context/MicroAgenticaContext";
|
|
4
2
|
import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory";
|
|
5
3
|
|
|
@@ -17,7 +15,7 @@ import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory
|
|
|
17
15
|
*
|
|
18
16
|
* @author Samchon
|
|
19
17
|
*/
|
|
20
|
-
export interface IMicroAgenticaExecutor
|
|
18
|
+
export interface IMicroAgenticaExecutor {
|
|
21
19
|
/**
|
|
22
20
|
* Function caller agent.
|
|
23
21
|
*
|
|
@@ -43,7 +41,7 @@ export interface IMicroAgenticaExecutor<Model extends ILlmSchema.Model> {
|
|
|
43
41
|
* agent is the most general topic which can be universally
|
|
44
42
|
* applied to all domain fields.
|
|
45
43
|
*/
|
|
46
|
-
call: (ctx: MicroAgenticaContext
|
|
44
|
+
call: (ctx: MicroAgenticaContext) => Promise<AgenticaExecuteHistory[]>;
|
|
47
45
|
|
|
48
46
|
/**
|
|
49
47
|
* Describer agent of the function calling result.
|
|
@@ -62,7 +60,7 @@ export interface IMicroAgenticaExecutor<Model extends ILlmSchema.Model> {
|
|
|
62
60
|
| boolean
|
|
63
61
|
| null
|
|
64
62
|
| ((
|
|
65
|
-
ctx: MicroAgenticaContext
|
|
66
|
-
executes: AgenticaExecuteHistory
|
|
63
|
+
ctx: MicroAgenticaContext,
|
|
64
|
+
executes: AgenticaExecuteHistory[],
|
|
67
65
|
) => Promise<void>);
|
|
68
66
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
|
|
3
1
|
import type { AgenticaTokenUsage } from "../context/AgenticaTokenUsage";
|
|
4
2
|
import type { IAgenticaTokenUsageJson } from "../json/IAgenticaTokenUsageJson";
|
|
5
3
|
import type { IMicroAgenticaHistoryJson } from "../json/IMicroAgenticaHistoryJson";
|
|
@@ -29,12 +27,7 @@ import type { IMicroAgenticaConfig } from "./IMicroAgenticaConfig";
|
|
|
29
27
|
*
|
|
30
28
|
* @author Samchon
|
|
31
29
|
*/
|
|
32
|
-
export interface IMicroAgenticaProps
|
|
33
|
-
/**
|
|
34
|
-
* LLM schema model.
|
|
35
|
-
*/
|
|
36
|
-
model: Model;
|
|
37
|
-
|
|
30
|
+
export interface IMicroAgenticaProps {
|
|
38
31
|
/**
|
|
39
32
|
* LLM service vendor.
|
|
40
33
|
*/
|
|
@@ -43,7 +36,7 @@ export interface IMicroAgenticaProps<Model extends ILlmSchema.Model> {
|
|
|
43
36
|
/**
|
|
44
37
|
* Controllers serving functions to call.
|
|
45
38
|
*/
|
|
46
|
-
controllers: IAgenticaController
|
|
39
|
+
controllers: IAgenticaController[];
|
|
47
40
|
|
|
48
41
|
/**
|
|
49
42
|
* Configuration of agent.
|
|
@@ -60,7 +53,7 @@ export interface IMicroAgenticaProps<Model extends ILlmSchema.Model> {
|
|
|
60
53
|
* - `systemPrompt`: default prompts written in markdown
|
|
61
54
|
* - https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts
|
|
62
55
|
*/
|
|
63
|
-
config?: IMicroAgenticaConfig
|
|
56
|
+
config?: IMicroAgenticaConfig;
|
|
64
57
|
|
|
65
58
|
/**
|
|
66
59
|
* Prompt histories.
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
|
|
3
1
|
import type { AgenticaJsonParseErrorEvent } from "../events/AgenticaJsonParseErrorEvent";
|
|
4
2
|
import type { AgenticaValidateEvent } from "../events/AgenticaValidateEvent";
|
|
5
3
|
import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory";
|
|
@@ -26,7 +24,7 @@ import type { IMicroAgenticaConfig } from "./IMicroAgenticaConfig";
|
|
|
26
24
|
*
|
|
27
25
|
* @author Samchon
|
|
28
26
|
*/
|
|
29
|
-
export interface IMicroAgenticaSystemPrompt
|
|
27
|
+
export interface IMicroAgenticaSystemPrompt {
|
|
30
28
|
/**
|
|
31
29
|
* Common system prompt that would be used in every situation.
|
|
32
30
|
*
|
|
@@ -41,7 +39,7 @@ export interface IMicroAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
41
39
|
* @returns The common system prompt
|
|
42
40
|
* @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/common.md
|
|
43
41
|
*/
|
|
44
|
-
common?: (config?: IMicroAgenticaConfig
|
|
42
|
+
common?: (config?: IMicroAgenticaConfig | undefined) => string;
|
|
45
43
|
|
|
46
44
|
/**
|
|
47
45
|
* Execute system prompt.
|
|
@@ -72,7 +70,7 @@ export interface IMicroAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
72
70
|
* @returns execute system prompt
|
|
73
71
|
* @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/execute.md
|
|
74
72
|
*/
|
|
75
|
-
execute?: null | ((histories: MicroAgenticaHistory
|
|
73
|
+
execute?: null | ((histories: MicroAgenticaHistory[]) => string);
|
|
76
74
|
|
|
77
75
|
/**
|
|
78
76
|
* Validation feedback system prompt.
|
|
@@ -106,7 +104,7 @@ export interface IMicroAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
106
104
|
* @returns validation feedback system prompt
|
|
107
105
|
* @default Built-in validation feedback prompt optimized for typia IValidation.IFailure processing
|
|
108
106
|
*/
|
|
109
|
-
validate?: (events: AgenticaValidateEvent
|
|
107
|
+
validate?: (events: AgenticaValidateEvent[]) => string;
|
|
110
108
|
|
|
111
109
|
/**
|
|
112
110
|
* JSON parsing error system prompt.
|
|
@@ -137,7 +135,7 @@ export interface IMicroAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
137
135
|
* @returns JSON parse error system prompt
|
|
138
136
|
* @default Built-in JSON parse error prompt optimized for syntax correction
|
|
139
137
|
*/
|
|
140
|
-
jsonParseError?: (event: AgenticaJsonParseErrorEvent
|
|
138
|
+
jsonParseError?: (event: AgenticaJsonParseErrorEvent) => string;
|
|
141
139
|
|
|
142
140
|
/**
|
|
143
141
|
* Describe system prompt.
|
|
@@ -167,5 +165,5 @@ export interface IMicroAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
167
165
|
* @returns describe system prompt
|
|
168
166
|
* @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/describe.md
|
|
169
167
|
*/
|
|
170
|
-
describe?: (histories: AgenticaExecuteHistory
|
|
168
|
+
describe?: (histories: AgenticaExecuteHistory[]) => string;
|
|
171
169
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
|
|
3
1
|
import type { AgenticaOperation } from "../context/AgenticaOperation";
|
|
4
2
|
import type { AgenticaUserMessageHistory } from "../histories";
|
|
5
3
|
import type { AgenticaAssistantMessageHistory } from "../histories/AgenticaAssistantMessageHistory";
|
|
@@ -17,10 +15,10 @@ import { createOperationSelection } from "../factory/operations";
|
|
|
17
15
|
/**
|
|
18
16
|
* @internal
|
|
19
17
|
*/
|
|
20
|
-
export function transformHistory
|
|
21
|
-
operations: Map<string, Map<string, AgenticaOperation
|
|
18
|
+
export function transformHistory(props: {
|
|
19
|
+
operations: Map<string, Map<string, AgenticaOperation>>;
|
|
22
20
|
history: IAgenticaHistoryJson;
|
|
23
|
-
}): AgenticaHistory
|
|
21
|
+
}): AgenticaHistory {
|
|
24
22
|
// USER
|
|
25
23
|
if (props.history.type === "userMessage") {
|
|
26
24
|
return transformUserMessage({
|
|
@@ -83,10 +81,10 @@ function transformUserMessage(props: {
|
|
|
83
81
|
return createUserMessageHistory(props.history);
|
|
84
82
|
}
|
|
85
83
|
|
|
86
|
-
function transformSelect
|
|
87
|
-
operations: Map<string, Map<string, AgenticaOperation
|
|
84
|
+
function transformSelect(props: {
|
|
85
|
+
operations: Map<string, Map<string, AgenticaOperation>>;
|
|
88
86
|
history: IAgenticaHistoryJson.ISelect;
|
|
89
|
-
}): AgenticaSelectHistory
|
|
87
|
+
}): AgenticaSelectHistory {
|
|
90
88
|
return createSelectHistory({
|
|
91
89
|
id: props.history.id,
|
|
92
90
|
created_at: props.history.created_at,
|
|
@@ -100,10 +98,10 @@ function transformSelect<Model extends ILlmSchema.Model>(props: {
|
|
|
100
98
|
});
|
|
101
99
|
}
|
|
102
100
|
|
|
103
|
-
function transformCancel
|
|
104
|
-
operations: Map<string, Map<string, AgenticaOperation
|
|
101
|
+
function transformCancel(props: {
|
|
102
|
+
operations: Map<string, Map<string, AgenticaOperation>>;
|
|
105
103
|
history: IAgenticaHistoryJson.ICancel;
|
|
106
|
-
}): AgenticaCancelHistory
|
|
104
|
+
}): AgenticaCancelHistory {
|
|
107
105
|
return createCancelHistory({
|
|
108
106
|
id: props.history.id,
|
|
109
107
|
created_at: props.history.created_at,
|
|
@@ -117,10 +115,10 @@ function transformCancel<Model extends ILlmSchema.Model>(props: {
|
|
|
117
115
|
});
|
|
118
116
|
}
|
|
119
117
|
|
|
120
|
-
function transformExecute
|
|
121
|
-
operations: Map<string, Map<string, AgenticaOperation
|
|
118
|
+
function transformExecute(props: {
|
|
119
|
+
operations: Map<string, Map<string, AgenticaOperation>>;
|
|
122
120
|
history: IAgenticaHistoryJson.IExecute;
|
|
123
|
-
}): AgenticaExecuteHistory
|
|
121
|
+
}): AgenticaExecuteHistory {
|
|
124
122
|
return createExecuteHistory({
|
|
125
123
|
id: props.history.id,
|
|
126
124
|
created_at: props.history.created_at,
|
|
@@ -138,10 +136,10 @@ function transformExecute<Model extends ILlmSchema.Model>(props: {
|
|
|
138
136
|
});
|
|
139
137
|
}
|
|
140
138
|
|
|
141
|
-
function transformDescribe
|
|
142
|
-
operations: Map<string, Map<string, AgenticaOperation
|
|
139
|
+
function transformDescribe(props: {
|
|
140
|
+
operations: Map<string, Map<string, AgenticaOperation>>;
|
|
143
141
|
history: IAgenticaHistoryJson.IDescribe;
|
|
144
|
-
}): AgenticaDescribeHistory
|
|
142
|
+
}): AgenticaDescribeHistory {
|
|
145
143
|
return createDescribeHistory({
|
|
146
144
|
id: props.history.id,
|
|
147
145
|
created_at: props.history.created_at,
|
|
@@ -155,14 +153,14 @@ function transformDescribe<Model extends ILlmSchema.Model>(props: {
|
|
|
155
153
|
});
|
|
156
154
|
}
|
|
157
155
|
|
|
158
|
-
function findOperation
|
|
159
|
-
operations: Map<string, Map<string, AgenticaOperation
|
|
156
|
+
function findOperation(props: {
|
|
157
|
+
operations: Map<string, Map<string, AgenticaOperation>>;
|
|
160
158
|
input: {
|
|
161
159
|
controller: string;
|
|
162
160
|
function: string;
|
|
163
161
|
};
|
|
164
|
-
}): AgenticaOperation
|
|
165
|
-
const found: AgenticaOperation
|
|
162
|
+
}): AgenticaOperation {
|
|
163
|
+
const found: AgenticaOperation | undefined = props.operations
|
|
166
164
|
.get(props.input.controller)
|
|
167
165
|
?.get(props.input.function);
|
|
168
166
|
if (found === undefined) {
|
|
@@ -301,14 +301,13 @@ describe("reduceStreamingWithDispatch", () => {
|
|
|
301
301
|
const streamedContent: string[] = [];
|
|
302
302
|
await new Promise(async (resolve) => {
|
|
303
303
|
const eventProcessor = vi.fn(({ stream: contentStream }) => {
|
|
304
|
-
(async () => {
|
|
304
|
+
void (async () => {
|
|
305
305
|
for await (const content of contentStream) {
|
|
306
|
-
streamedContent.push(content);
|
|
306
|
+
streamedContent.push(content as string);
|
|
307
307
|
}
|
|
308
308
|
resolve(true);
|
|
309
|
-
})();
|
|
309
|
+
})().catch(() => {});
|
|
310
310
|
});
|
|
311
|
-
|
|
312
311
|
await reduceStreamingWithDispatch(stream, eventProcessor);
|
|
313
312
|
});
|
|
314
313
|
expect(streamedContent).toEqual(["Hello", " World"]);
|
|
@@ -895,7 +894,7 @@ describe("reduceStreamingWithDispatch", () => {
|
|
|
895
894
|
|
|
896
895
|
const stream = new ReadableStream<ChatCompletionChunk>({
|
|
897
896
|
start(controller) {
|
|
898
|
-
controller.enqueue(malformedChunk);
|
|
897
|
+
controller.enqueue(malformedChunk as ChatCompletionChunk);
|
|
899
898
|
controller.close();
|
|
900
899
|
},
|
|
901
900
|
});
|
package/src/utils/request.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
1
|
import type OpenAI from "openai";
|
|
3
2
|
|
|
4
3
|
import { v4 } from "uuid";
|
|
@@ -13,9 +12,9 @@ import { createRequestEvent } from "../factory";
|
|
|
13
12
|
import { ChatGptCompletionMessageUtil } from "./ChatGptCompletionMessageUtil";
|
|
14
13
|
import { streamDefaultReaderToAsyncGenerator, StreamUtil } from "./StreamUtil";
|
|
15
14
|
|
|
16
|
-
export function getChatCompletionWithStreamingFunction
|
|
15
|
+
export function getChatCompletionWithStreamingFunction(props: {
|
|
17
16
|
vendor: IAgenticaVendor;
|
|
18
|
-
config?: IAgenticaConfig
|
|
17
|
+
config?: IAgenticaConfig | IMicroAgenticaConfig;
|
|
19
18
|
dispatch: (event: AgenticaRequestEvent | AgenticaResponseEvent) => Promise<void>;
|
|
20
19
|
abortSignal?: AbortSignal;
|
|
21
20
|
usage: AgenticaTokenUsage;
|