@agentica/core 0.15.6 → 0.16.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 +21 -21
- package/lib/Agentica.js +27 -27
- package/lib/Agentica.js.map +1 -1
- package/lib/MicroAgentica.d.ts +115 -0
- package/lib/MicroAgentica.js +279 -0
- package/lib/MicroAgentica.js.map +1 -0
- package/lib/constants/AgenticaDefaultPrompt.d.ts +2 -1
- package/lib/constants/AgenticaDefaultPrompt.js +7 -5
- package/lib/constants/AgenticaDefaultPrompt.js.map +1 -1
- package/lib/context/AgenticaCancelPrompt.d.ts +3 -3
- package/lib/context/AgenticaContext.d.ts +12 -12
- package/lib/context/AgenticaOperationCollection.d.ts +1 -1
- package/lib/context/MicroAgenticaContext.d.ts +75 -0
- package/lib/{prompts/AgenticaCancelPrompt.js → context/MicroAgenticaContext.js} +1 -1
- package/lib/context/MicroAgenticaContext.js.map +1 -0
- package/lib/context/internal/AgenticaOperationComposer.d.ts +2 -1
- package/lib/context/internal/AgenticaOperationComposer.js +3 -2
- package/lib/context/internal/AgenticaOperationComposer.js.map +1 -1
- package/lib/context/internal/isAgenticaContext.d.ts +1 -0
- package/lib/context/internal/isAgenticaContext.js +10 -0
- package/lib/context/internal/isAgenticaContext.js.map +1 -0
- package/lib/events/AgenticaDescribeEvent.d.ts +4 -4
- package/lib/events/AgenticaEvent.d.ts +1 -0
- package/lib/events/AgenticaExecuteEvent.d.ts +5 -5
- package/lib/events/AgenticaSelectEvent.d.ts +2 -2
- package/lib/events/AgenticaTextEvent.d.ts +2 -2
- package/lib/events/MicroAgenticaEvent.d.ts +32 -0
- package/lib/{prompts/AgenticaTextPrompt.js → events/MicroAgenticaEvent.js} +1 -1
- package/lib/events/MicroAgenticaEvent.js.map +1 -0
- package/lib/factory/events.d.ts +2 -2
- package/lib/factory/events.js +5 -5
- package/lib/factory/events.js.map +1 -1
- package/lib/factory/histories.d.ts +33 -0
- package/lib/factory/{prompts.js → histories.js} +13 -13
- package/lib/factory/histories.js.map +1 -0
- package/lib/factory/index.d.ts +1 -1
- package/lib/factory/index.js +1 -1
- package/lib/factory/index.js.map +1 -1
- package/lib/functional/assertHttpLlmApplication.js +577 -387
- package/lib/functional/assertHttpLlmApplication.js.map +1 -1
- package/lib/functional/validateHttpLlmApplication.js +500 -348
- package/lib/functional/validateHttpLlmApplication.js.map +1 -1
- package/lib/histories/AgenticaCancelHistory.d.ts +8 -0
- package/lib/{prompts/AgenticaExecutePrompt.js → histories/AgenticaCancelHistory.js} +1 -1
- package/lib/histories/AgenticaCancelHistory.js.map +1 -0
- package/lib/histories/AgenticaDescribeHistory.d.ts +16 -0
- package/lib/histories/AgenticaDescribeHistory.js +3 -0
- package/lib/histories/AgenticaDescribeHistory.js.map +1 -0
- package/lib/{prompts/AgenticaExecutePrompt.d.ts → histories/AgenticaExecuteHistory.d.ts} +5 -5
- package/lib/{prompts/AgenticaDescribePrompt.js → histories/AgenticaExecuteHistory.js} +1 -1
- package/lib/histories/AgenticaExecuteHistory.js.map +1 -0
- package/lib/histories/AgenticaHistory.d.ts +17 -0
- package/lib/{prompts/AgenticaPrompt.js → histories/AgenticaHistory.js} +1 -1
- package/lib/histories/AgenticaHistory.js.map +1 -0
- package/lib/{prompts/AgenticaPromptBase.d.ts → histories/AgenticaHistoryBase.d.ts} +4 -4
- package/lib/{json/IAgenticaPromptJson.js → histories/AgenticaHistoryBase.js} +1 -1
- package/lib/histories/AgenticaHistoryBase.js.map +1 -0
- package/lib/histories/AgenticaSelectHistory.d.ts +8 -0
- package/lib/histories/AgenticaSelectHistory.js +3 -0
- package/lib/histories/AgenticaSelectHistory.js.map +1 -0
- package/lib/histories/AgenticaTextHistory.d.ts +6 -0
- package/lib/{prompts/AgenticaPromptBase.js → histories/AgenticaTextHistory.js} +1 -1
- package/lib/histories/AgenticaTextHistory.js.map +1 -0
- package/lib/histories/MicroAgenticaHistory.d.ts +13 -0
- package/lib/histories/MicroAgenticaHistory.js +3 -0
- package/lib/histories/MicroAgenticaHistory.js.map +1 -0
- package/lib/index.d.ts +12 -7
- package/lib/index.js +12 -7
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +1393 -902
- package/lib/index.mjs.map +1 -1
- package/lib/json/IAgenticaEventJson.d.ts +6 -5
- package/lib/json/{IAgenticaPromptJson.d.ts → IAgenticaHistoryJson.d.ts} +8 -8
- package/lib/json/IAgenticaHistoryJson.js +3 -0
- package/lib/json/IAgenticaHistoryJson.js.map +1 -0
- package/lib/json/IAgenticaOperationSelectionJson.d.ts +7 -1
- package/lib/json/IMicroAgenticaEventJson.d.ts +13 -0
- package/lib/json/IMicroAgenticaEventJson.js +3 -0
- package/lib/json/IMicroAgenticaEventJson.js.map +1 -0
- package/lib/json/IMicroAgenticaHistoryJson.d.ts +19 -0
- package/lib/json/IMicroAgenticaHistoryJson.js +3 -0
- package/lib/json/IMicroAgenticaHistoryJson.js.map +1 -0
- package/lib/orchestrate/call.d.ts +4 -2
- package/lib/orchestrate/call.js +50 -41
- package/lib/orchestrate/call.js.map +1 -1
- package/lib/orchestrate/cancel.js +4 -4
- package/lib/orchestrate/cancel.js.map +1 -1
- package/lib/orchestrate/describe.d.ts +4 -3
- package/lib/orchestrate/describe.js +3 -3
- package/lib/orchestrate/describe.js.map +1 -1
- package/lib/orchestrate/execute.d.ts +2 -2
- package/lib/orchestrate/execute.js +1 -1
- package/lib/orchestrate/execute.js.map +1 -1
- package/lib/orchestrate/initialize.d.ts +2 -2
- package/lib/orchestrate/initialize.js +3 -3
- package/lib/orchestrate/initialize.js.map +1 -1
- package/lib/orchestrate/internal/selectFunction.d.ts +1 -5
- package/lib/orchestrate/internal/selectFunction.js +3 -0
- package/lib/orchestrate/internal/selectFunction.js.map +1 -1
- package/lib/orchestrate/select.d.ts +2 -2
- package/lib/orchestrate/select.js +5 -5
- package/lib/orchestrate/select.js.map +1 -1
- package/lib/structures/IAgenticaConfig.d.ts +6 -5
- package/lib/structures/IAgenticaController.d.ts +1 -1
- package/lib/structures/IAgenticaExecutor.d.ts +11 -9
- package/lib/structures/IAgenticaProps.d.ts +3 -3
- package/lib/structures/IAgenticaSystemPrompt.d.ts +13 -13
- package/lib/structures/IAgenticaVendor.d.ts +1 -1
- package/lib/structures/IMicroAgenticaConfig.d.ts +74 -0
- package/lib/structures/IMicroAgenticaConfig.js +3 -0
- package/lib/structures/IMicroAgenticaConfig.js.map +1 -0
- package/lib/structures/IMicroAgenticaExecutor.d.ts +57 -0
- package/lib/structures/IMicroAgenticaExecutor.js +3 -0
- package/lib/structures/IMicroAgenticaExecutor.js.map +1 -0
- package/lib/structures/IMicroAgenticaProps.d.ts +63 -0
- package/lib/structures/IMicroAgenticaProps.js +3 -0
- package/lib/structures/IMicroAgenticaProps.js.map +1 -0
- package/lib/structures/IMicroAgenticaSystemPrompt.d.ts +66 -0
- package/lib/structures/IMicroAgenticaSystemPrompt.js +3 -0
- package/lib/structures/IMicroAgenticaSystemPrompt.js.map +1 -0
- package/lib/transformers/AgenticaPromptTransformer.d.ts +19 -19
- package/lib/transformers/AgenticaPromptTransformer.js +27 -27
- package/lib/transformers/AgenticaPromptTransformer.js.map +1 -1
- package/package.json +7 -7
- package/src/Agentica.ts +34 -34
- package/src/MicroAgentica.ts +337 -0
- package/src/constants/AgenticaDefaultPrompt.ts +7 -3
- package/src/context/AgenticaCancelPrompt.ts +3 -3
- package/src/context/AgenticaContext.ts +12 -12
- package/src/context/AgenticaOperationCollection.ts +1 -1
- package/src/context/MicroAgenticaContext.ts +95 -0
- package/src/context/internal/AgenticaOperationComposer.ts +6 -3
- package/src/context/internal/isAgenticaContext.ts +13 -0
- package/src/events/AgenticaDescribeEvent.ts +4 -4
- package/src/events/AgenticaEvent.ts +6 -0
- package/src/events/AgenticaExecuteEvent.ts +5 -5
- package/src/events/AgenticaSelectEvent.ts +2 -2
- package/src/events/AgenticaTextEvent.ts +2 -2
- package/src/events/MicroAgenticaEvent.ts +41 -0
- package/src/factory/events.ts +8 -8
- package/src/factory/{prompts.ts → histories.ts} +18 -18
- package/src/factory/index.ts +1 -1
- package/src/histories/AgenticaCancelHistory.ts +13 -0
- package/src/histories/AgenticaDescribeHistory.ts +22 -0
- package/src/{prompts/AgenticaExecutePrompt.ts → histories/AgenticaExecuteHistory.ts} +7 -7
- package/src/histories/AgenticaHistory.ts +25 -0
- package/src/{prompts/AgenticaPromptBase.ts → histories/AgenticaHistoryBase.ts} +4 -4
- package/src/histories/AgenticaSelectHistory.ts +13 -0
- package/src/histories/AgenticaTextHistory.ts +10 -0
- package/src/histories/MicroAgenticaHistory.ts +18 -0
- package/src/index.ts +18 -15
- package/src/json/IAgenticaEventJson.ts +6 -5
- package/src/json/{IAgenticaPromptJson.ts → IAgenticaHistoryJson.ts} +13 -13
- package/src/json/IAgenticaOperationSelectionJson.ts +8 -1
- package/src/json/IMicroAgenticaEventJson.ts +21 -0
- package/src/json/IMicroAgenticaHistoryJson.ts +23 -0
- package/src/orchestrate/call.ts +83 -59
- package/src/orchestrate/cancel.ts +4 -4
- package/src/orchestrate/describe.ts +11 -7
- package/src/orchestrate/execute.ts +7 -7
- package/src/orchestrate/initialize.ts +6 -6
- package/src/orchestrate/internal/selectFunction.ts +3 -0
- package/src/orchestrate/select.ts +13 -13
- package/src/structures/IAgenticaConfig.ts +6 -5
- package/src/structures/IAgenticaController.ts +1 -1
- package/src/structures/IAgenticaExecutor.ts +12 -10
- package/src/structures/IAgenticaProps.ts +3 -3
- package/src/structures/IAgenticaSystemPrompt.ts +13 -13
- package/src/structures/IAgenticaVendor.ts +1 -1
- package/src/structures/IMicroAgenticaConfig.ts +82 -0
- package/src/structures/IMicroAgenticaExecutor.ts +63 -0
- package/src/structures/IMicroAgenticaProps.ts +70 -0
- package/src/structures/IMicroAgenticaSystemPrompt.ts +71 -0
- package/src/transformers/AgenticaPromptTransformer.ts +46 -46
- package/lib/factory/prompts.d.ts +0 -33
- package/lib/factory/prompts.js.map +0 -1
- package/lib/json/IAgenticaPromptJson.js.map +0 -1
- package/lib/prompts/AgenticaCancelPrompt.d.ts +0 -8
- package/lib/prompts/AgenticaCancelPrompt.js.map +0 -1
- package/lib/prompts/AgenticaDescribePrompt.d.ts +0 -16
- package/lib/prompts/AgenticaDescribePrompt.js.map +0 -1
- package/lib/prompts/AgenticaExecutePrompt.js.map +0 -1
- package/lib/prompts/AgenticaPrompt.d.ts +0 -17
- package/lib/prompts/AgenticaPrompt.js.map +0 -1
- package/lib/prompts/AgenticaPromptBase.js.map +0 -1
- package/lib/prompts/AgenticaSelectPrompt.d.ts +0 -8
- package/lib/prompts/AgenticaSelectPrompt.js +0 -3
- package/lib/prompts/AgenticaSelectPrompt.js.map +0 -1
- package/lib/prompts/AgenticaTextPrompt.d.ts +0 -6
- package/lib/prompts/AgenticaTextPrompt.js.map +0 -1
- package/src/prompts/AgenticaCancelPrompt.ts +0 -13
- package/src/prompts/AgenticaDescribePrompt.ts +0 -22
- package/src/prompts/AgenticaPrompt.ts +0 -25
- package/src/prompts/AgenticaSelectPrompt.ts +0 -13
- package/src/prompts/AgenticaTextPrompt.ts +0 -10
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
2
|
|
|
3
3
|
import type { AgenticaOperationSelection } from "../context/AgenticaOperationSelection";
|
|
4
|
+
import type { AgenticaSelectHistory } from "../histories/AgenticaSelectHistory";
|
|
4
5
|
import type { IAgenticaEventJson } from "../json/IAgenticaEventJson";
|
|
5
|
-
import type { AgenticaSelectPrompt } from "../prompts/AgenticaSelectPrompt";
|
|
6
6
|
|
|
7
7
|
import type { AgenticaEventBase } from "./AgenticaEventBase";
|
|
8
8
|
|
|
@@ -11,5 +11,5 @@ export interface AgenticaSelectEvent<
|
|
|
11
11
|
> extends AgenticaEventBase<"select"> {
|
|
12
12
|
selection: AgenticaOperationSelection<Model>;
|
|
13
13
|
toJSON: () => IAgenticaEventJson.ISelect;
|
|
14
|
-
|
|
14
|
+
toHistory: () => AgenticaSelectHistory<Model>;
|
|
15
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { AgenticaTextHistory } from "../histories/AgenticaTextHistory";
|
|
1
2
|
import type { IAgenticaEventJson } from "../json/IAgenticaEventJson";
|
|
2
|
-
import type { AgenticaTextPrompt } from "../prompts/AgenticaTextPrompt";
|
|
3
3
|
|
|
4
4
|
import type { AgenticaEventBase } from "./AgenticaEventBase";
|
|
5
5
|
|
|
@@ -10,5 +10,5 @@ export interface AgenticaTextEvent<
|
|
|
10
10
|
stream: ReadableStream<string>;
|
|
11
11
|
join: () => Promise<string>;
|
|
12
12
|
toJSON: () => IAgenticaEventJson.IText;
|
|
13
|
-
|
|
13
|
+
toHistory: () => AgenticaTextHistory;
|
|
14
14
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
|
|
3
|
+
import type { AgenticaCallEvent } from "./AgenticaCallEvent";
|
|
4
|
+
import type { AgenticaDescribeEvent } from "./AgenticaDescribeEvent";
|
|
5
|
+
import type { AgenticaExecuteEvent } from "./AgenticaExecuteEvent";
|
|
6
|
+
import type { AgenticaRequestEvent } from "./AgenticaRequestEvent";
|
|
7
|
+
import type { AgenticaResponseEvent } from "./AgenticaResponseEvent";
|
|
8
|
+
import type { AgenticaTextEvent } from "./AgenticaTextEvent";
|
|
9
|
+
import type { AgenticaValidateEvent } from "./AgenticaValidateEvent";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Micro Agentica agent event.
|
|
13
|
+
*
|
|
14
|
+
* `MicroAgenticaEvent` is an union type of all possible events that
|
|
15
|
+
* can be emitted by the AI chatbot of the {@link MicroAgentica} class.
|
|
16
|
+
*
|
|
17
|
+
* You can discriminate the subtype by checking the {@link type} property.
|
|
18
|
+
*
|
|
19
|
+
* @author Samchon
|
|
20
|
+
*/
|
|
21
|
+
export type MicroAgenticaEvent<Model extends ILlmSchema.Model> =
|
|
22
|
+
| AgenticaCallEvent<Model>
|
|
23
|
+
| AgenticaDescribeEvent<Model>
|
|
24
|
+
| AgenticaExecuteEvent<Model>
|
|
25
|
+
| AgenticaRequestEvent
|
|
26
|
+
| AgenticaResponseEvent
|
|
27
|
+
| AgenticaTextEvent
|
|
28
|
+
| AgenticaValidateEvent<Model>;
|
|
29
|
+
export namespace MicroAgenticaEvent {
|
|
30
|
+
export type Type = MicroAgenticaEvent<any>["type"];
|
|
31
|
+
export interface Mapper<Model extends ILlmSchema.Model> {
|
|
32
|
+
call: AgenticaCallEvent<Model>;
|
|
33
|
+
describe: AgenticaDescribeEvent<Model>;
|
|
34
|
+
execute: AgenticaExecuteEvent<Model>;
|
|
35
|
+
request: AgenticaRequestEvent;
|
|
36
|
+
response: AgenticaResponseEvent;
|
|
37
|
+
text: AgenticaTextEvent;
|
|
38
|
+
validate: AgenticaValidateEvent<Model>;
|
|
39
|
+
}
|
|
40
|
+
export type Source = "call" | "describe";
|
|
41
|
+
}
|
package/src/factory/events.ts
CHANGED
|
@@ -16,10 +16,10 @@ import type { AgenticaResponseEvent } from "../events/AgenticaResponseEvent";
|
|
|
16
16
|
import type { AgenticaSelectEvent } from "../events/AgenticaSelectEvent";
|
|
17
17
|
import type { AgenticaTextEvent } from "../events/AgenticaTextEvent";
|
|
18
18
|
import type { AgenticaValidateEvent } from "../events/AgenticaValidateEvent";
|
|
19
|
+
import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory";
|
|
19
20
|
import type { IAgenticaEventJson } from "../json/IAgenticaEventJson";
|
|
20
|
-
import type { AgenticaExecutePrompt } from "../prompts/AgenticaExecutePrompt";
|
|
21
21
|
|
|
22
|
-
import {
|
|
22
|
+
import { createExecuteHistory, createSelectHistory } from "./histories";
|
|
23
23
|
|
|
24
24
|
/* -----------------------------------------------------------
|
|
25
25
|
FUNCTION SELECTS
|
|
@@ -44,7 +44,7 @@ export function createSelectEvent<Model extends ILlmSchema.Model>(props: {
|
|
|
44
44
|
type: "select",
|
|
45
45
|
selection: props.selection.toJSON(),
|
|
46
46
|
}),
|
|
47
|
-
|
|
47
|
+
toHistory: () => createSelectHistory({
|
|
48
48
|
id: v4(),
|
|
49
49
|
selections: [props.selection],
|
|
50
50
|
}),
|
|
@@ -126,8 +126,8 @@ export function createExecuteEvent<Model extends ILlmSchema.Model>(props: {
|
|
|
126
126
|
arguments: props.arguments,
|
|
127
127
|
value: props.value,
|
|
128
128
|
}),
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
toHistory: () =>
|
|
130
|
+
createExecuteHistory(props) as AgenticaExecuteHistory.Class<Model>,
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -152,7 +152,7 @@ export function createTextEvent<Role extends "user" | "assistant">(props: {
|
|
|
152
152
|
done: props.done(),
|
|
153
153
|
text: props.get(),
|
|
154
154
|
}),
|
|
155
|
-
|
|
155
|
+
toHistory: () => ({
|
|
156
156
|
type: "text",
|
|
157
157
|
role: props.role,
|
|
158
158
|
text: props.get(),
|
|
@@ -166,7 +166,7 @@ export function createTextEvent<Role extends "user" | "assistant">(props: {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
export function createDescribeEvent<Model extends ILlmSchema.Model>(props: {
|
|
169
|
-
executes:
|
|
169
|
+
executes: AgenticaExecuteHistory<Model>[];
|
|
170
170
|
stream: ReadableStream<string>;
|
|
171
171
|
done: () => boolean;
|
|
172
172
|
get: () => string;
|
|
@@ -183,7 +183,7 @@ export function createDescribeEvent<Model extends ILlmSchema.Model>(props: {
|
|
|
183
183
|
done: props.done(),
|
|
184
184
|
text: props.get(),
|
|
185
185
|
}),
|
|
186
|
-
|
|
186
|
+
toHistory: () => ({
|
|
187
187
|
type: "describe",
|
|
188
188
|
executes: props.executes,
|
|
189
189
|
text: props.get(),
|
|
@@ -4,14 +4,14 @@ import type OpenAI from "openai";
|
|
|
4
4
|
import type { AgenticaCancelPrompt } from "../context/AgenticaCancelPrompt";
|
|
5
5
|
import type { AgenticaOperation } from "../context/AgenticaOperation";
|
|
6
6
|
import type { AgenticaOperationSelection } from "../context/AgenticaOperationSelection";
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
7
|
+
import type { AgenticaDescribeHistory } from "../histories/AgenticaDescribeHistory";
|
|
8
|
+
import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory";
|
|
9
|
+
import type { AgenticaHistory } from "../histories/AgenticaHistory";
|
|
10
|
+
import type { AgenticaSelectHistory } from "../histories/AgenticaSelectHistory";
|
|
11
|
+
import type { AgenticaTextHistory } from "../histories/AgenticaTextHistory";
|
|
12
|
+
import type { IAgenticaHistoryJson } from "../json/IAgenticaHistoryJson";
|
|
13
13
|
|
|
14
|
-
export function
|
|
14
|
+
export function decodeHistory<Model extends ILlmSchema.Model>(history: AgenticaHistory<Model>): OpenAI.ChatCompletionMessageParam[] {
|
|
15
15
|
// NO NEED TO DECODE DESCRIBE
|
|
16
16
|
if (history.type === "describe") {
|
|
17
17
|
return [];
|
|
@@ -98,11 +98,11 @@ export function decodePrompt<Model extends ILlmSchema.Model>(history: AgenticaPr
|
|
|
98
98
|
/* -----------------------------------------------------------
|
|
99
99
|
TEXT PROMPTS
|
|
100
100
|
----------------------------------------------------------- */
|
|
101
|
-
export function
|
|
101
|
+
export function createTextHistory<Role extends "assistant" | "user" = "assistant" | "user">(props: {
|
|
102
102
|
role: Role;
|
|
103
103
|
text: string;
|
|
104
|
-
}):
|
|
105
|
-
const prompt:
|
|
104
|
+
}): AgenticaTextHistory<Role> {
|
|
105
|
+
const prompt: IAgenticaHistoryJson.IText<Role> = {
|
|
106
106
|
type: "text",
|
|
107
107
|
role: props.role,
|
|
108
108
|
text: props.text,
|
|
@@ -113,10 +113,10 @@ export function createTextPrompt<Role extends "assistant" | "user" = "assistant"
|
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
export function
|
|
117
|
-
executes:
|
|
116
|
+
export function createDescribeHistory<Model extends ILlmSchema.Model>(props: {
|
|
117
|
+
executes: AgenticaExecuteHistory<Model>[];
|
|
118
118
|
text: string;
|
|
119
|
-
}):
|
|
119
|
+
}): AgenticaDescribeHistory<Model> {
|
|
120
120
|
return {
|
|
121
121
|
type: "describe",
|
|
122
122
|
text: props.text,
|
|
@@ -132,10 +132,10 @@ export function createDescribePrompt<Model extends ILlmSchema.Model>(props: {
|
|
|
132
132
|
/* -----------------------------------------------------------
|
|
133
133
|
FUNCTION CALLING PROMPTS
|
|
134
134
|
----------------------------------------------------------- */
|
|
135
|
-
export function
|
|
135
|
+
export function createSelectHistory<Model extends ILlmSchema.Model>(props: {
|
|
136
136
|
id: string;
|
|
137
137
|
selections: AgenticaOperationSelection<Model>[];
|
|
138
|
-
}):
|
|
138
|
+
}): AgenticaSelectHistory<Model> {
|
|
139
139
|
return {
|
|
140
140
|
type: "select",
|
|
141
141
|
id: props.id,
|
|
@@ -148,7 +148,7 @@ export function createSelectPrompt<Model extends ILlmSchema.Model>(props: {
|
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
export function
|
|
151
|
+
export function createCancelHistory<Model extends ILlmSchema.Model>(props: {
|
|
152
152
|
id: string;
|
|
153
153
|
selections: AgenticaOperationSelection<Model>[];
|
|
154
154
|
}): AgenticaCancelPrompt<Model> {
|
|
@@ -164,14 +164,14 @@ export function createCancelPrompt<Model extends ILlmSchema.Model>(props: {
|
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
export function
|
|
167
|
+
export function createExecuteHistory<
|
|
168
168
|
Model extends ILlmSchema.Model,
|
|
169
169
|
>(props: {
|
|
170
170
|
id: string;
|
|
171
171
|
operation: AgenticaOperation<Model>;
|
|
172
172
|
arguments: Record<string, any>;
|
|
173
173
|
value: unknown;
|
|
174
|
-
}):
|
|
174
|
+
}): AgenticaExecuteHistory<Model> {
|
|
175
175
|
return {
|
|
176
176
|
type: "execute",
|
|
177
177
|
protocol: props.operation.protocol as "class",
|
package/src/factory/index.ts
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
|
|
3
|
+
import type { AgenticaOperationSelection } from "../context/AgenticaOperationSelection";
|
|
4
|
+
import type { IAgenticaHistoryJson } from "../json/IAgenticaHistoryJson";
|
|
5
|
+
|
|
6
|
+
import type { AgenticaHistoryBase } from "./AgenticaHistoryBase";
|
|
7
|
+
|
|
8
|
+
export interface AgenticaCancelHistory<
|
|
9
|
+
Model extends ILlmSchema.Model,
|
|
10
|
+
> extends AgenticaHistoryBase<"cancel", IAgenticaHistoryJson.ICancel> {
|
|
11
|
+
id: string;
|
|
12
|
+
selections: AgenticaOperationSelection<Model>[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
|
|
3
|
+
import type { IAgenticaHistoryJson } from "../json/IAgenticaHistoryJson";
|
|
4
|
+
|
|
5
|
+
import type { AgenticaExecuteHistory } from "./AgenticaExecuteHistory";
|
|
6
|
+
import type { AgenticaHistoryBase } from "./AgenticaHistoryBase";
|
|
7
|
+
|
|
8
|
+
export interface AgenticaDescribeHistory<
|
|
9
|
+
Model extends ILlmSchema.Model,
|
|
10
|
+
> extends AgenticaHistoryBase<"describe", IAgenticaHistoryJson.IDescribe> {
|
|
11
|
+
/**
|
|
12
|
+
* Executions of the LLM function calling.
|
|
13
|
+
*
|
|
14
|
+
* This prompt describes the return value of them.
|
|
15
|
+
*/
|
|
16
|
+
executes: AgenticaExecuteHistory<Model>[];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Description text.
|
|
20
|
+
*/
|
|
21
|
+
text: string;
|
|
22
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { IHttpResponse, ILlmSchema } from "@samchon/openapi";
|
|
2
2
|
|
|
3
3
|
import type { AgenticaOperation } from "../context/AgenticaOperation";
|
|
4
|
-
import type {
|
|
4
|
+
import type { IAgenticaHistoryJson } from "../json/IAgenticaHistoryJson";
|
|
5
5
|
|
|
6
|
-
import type {
|
|
6
|
+
import type { AgenticaHistoryBase } from "./AgenticaHistoryBase";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Execute prompt.
|
|
10
10
|
*
|
|
11
11
|
* @author Samchon
|
|
12
12
|
*/
|
|
13
|
-
export type
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
export namespace
|
|
13
|
+
export type AgenticaExecuteHistory<Model extends ILlmSchema.Model> =
|
|
14
|
+
| AgenticaExecuteHistory.Class<Model>
|
|
15
|
+
| AgenticaExecuteHistory.Http<Model>;
|
|
16
|
+
export namespace AgenticaExecuteHistory {
|
|
17
17
|
/**
|
|
18
18
|
* Class protocol case.
|
|
19
19
|
*/
|
|
@@ -30,7 +30,7 @@ export namespace AgenticaExecutePrompt {
|
|
|
30
30
|
Protocol extends "http" | "class",
|
|
31
31
|
Operation extends AgenticaOperation<any>,
|
|
32
32
|
Value,
|
|
33
|
-
> extends
|
|
33
|
+
> extends AgenticaHistoryBase<"execute", IAgenticaHistoryJson.IExecute> {
|
|
34
34
|
/**
|
|
35
35
|
* ID of the LLM tool call result.
|
|
36
36
|
*/
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
|
|
3
|
+
import type { AgenticaCancelPrompt } from "../context/AgenticaCancelPrompt";
|
|
4
|
+
|
|
5
|
+
import type { AgenticaDescribeHistory } from "./AgenticaDescribeHistory";
|
|
6
|
+
import type { AgenticaExecuteHistory } from "./AgenticaExecuteHistory";
|
|
7
|
+
import type { AgenticaSelectHistory } from "./AgenticaSelectHistory";
|
|
8
|
+
import type { AgenticaTextHistory } from "./AgenticaTextHistory";
|
|
9
|
+
|
|
10
|
+
export type AgenticaHistory<Model extends ILlmSchema.Model> =
|
|
11
|
+
| AgenticaCancelPrompt<Model>
|
|
12
|
+
| AgenticaDescribeHistory<Model>
|
|
13
|
+
| AgenticaExecuteHistory<Model>
|
|
14
|
+
| AgenticaSelectHistory<Model>
|
|
15
|
+
| AgenticaTextHistory;
|
|
16
|
+
export namespace AgenticaHistory {
|
|
17
|
+
export type Type = AgenticaHistory<any>["type"];
|
|
18
|
+
export interface Mapper<Model extends ILlmSchema.Model> {
|
|
19
|
+
cancel: AgenticaCancelPrompt<Model>;
|
|
20
|
+
describe: AgenticaDescribeHistory<Model>;
|
|
21
|
+
execute: AgenticaExecuteHistory<Model>;
|
|
22
|
+
select: AgenticaSelectHistory<Model>;
|
|
23
|
+
text: AgenticaTextHistory;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Base type for all
|
|
2
|
+
* Base type for all histories in Agentica.
|
|
3
3
|
*
|
|
4
|
-
* `
|
|
4
|
+
* `AgenticaHistoryBase` is a base type for every history types
|
|
5
5
|
* in Agentica. It is generated by {@link Agentica.conversate} function,
|
|
6
6
|
* and used for restoring the previous conversation history when
|
|
7
7
|
* constructing the {@link Agentica} instance.
|
|
8
8
|
*
|
|
9
9
|
* @template Type Discriminator type
|
|
10
|
-
* @template Json Primitive type of the
|
|
10
|
+
* @template Json Primitive type of the history
|
|
11
11
|
* @author Samchon
|
|
12
12
|
*/
|
|
13
|
-
export interface
|
|
13
|
+
export interface AgenticaHistoryBase<
|
|
14
14
|
Type extends string,
|
|
15
15
|
Json extends { type: Type },
|
|
16
16
|
> {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
|
|
3
|
+
import type { AgenticaOperationSelection } from "../context/AgenticaOperationSelection";
|
|
4
|
+
import type { IAgenticaHistoryJson } from "../json/IAgenticaHistoryJson";
|
|
5
|
+
|
|
6
|
+
import type { AgenticaHistoryBase } from "./AgenticaHistoryBase";
|
|
7
|
+
|
|
8
|
+
export interface AgenticaSelectHistory<
|
|
9
|
+
Model extends ILlmSchema.Model,
|
|
10
|
+
> extends AgenticaHistoryBase<"select", IAgenticaHistoryJson.ISelect> {
|
|
11
|
+
id: string;
|
|
12
|
+
selections: AgenticaOperationSelection<Model>[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IAgenticaHistoryJson } from "../json/IAgenticaHistoryJson";
|
|
2
|
+
|
|
3
|
+
import type { AgenticaHistoryBase } from "./AgenticaHistoryBase";
|
|
4
|
+
|
|
5
|
+
export interface AgenticaTextHistory<
|
|
6
|
+
Role extends "assistant" | "user" = "assistant" | "user",
|
|
7
|
+
> extends AgenticaHistoryBase<"text", IAgenticaHistoryJson.IText> {
|
|
8
|
+
role: Role;
|
|
9
|
+
text: string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
|
|
3
|
+
import type { AgenticaDescribeHistory } from "./AgenticaDescribeHistory";
|
|
4
|
+
import type { AgenticaExecuteHistory } from "./AgenticaExecuteHistory";
|
|
5
|
+
import type { AgenticaTextHistory } from "./AgenticaTextHistory";
|
|
6
|
+
|
|
7
|
+
export type MicroAgenticaHistory<Model extends ILlmSchema.Model> =
|
|
8
|
+
| AgenticaDescribeHistory<Model>
|
|
9
|
+
| AgenticaExecuteHistory<Model>
|
|
10
|
+
| AgenticaTextHistory;
|
|
11
|
+
export namespace MicroAgenticaHistory {
|
|
12
|
+
export type Type = MicroAgenticaHistory<any>["type"];
|
|
13
|
+
export interface Mapper<Model extends ILlmSchema.Model> {
|
|
14
|
+
describe: AgenticaDescribeHistory<Model>;
|
|
15
|
+
execute: AgenticaExecuteHistory<Model>;
|
|
16
|
+
text: AgenticaTextHistory;
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
export * from "./Agentica";
|
|
2
|
-
|
|
3
2
|
export * from "./context/AgenticaContext";
|
|
3
|
+
|
|
4
4
|
export * from "./context/AgenticaOperation";
|
|
5
|
+
|
|
5
6
|
export * from "./context/AgenticaOperationCollection";
|
|
6
7
|
export * from "./context/AgenticaOperationSelection";
|
|
7
8
|
export * from "./context/AgenticaTokenUsage";
|
|
8
|
-
|
|
9
9
|
export * from "./events/AgenticaCallEvent";
|
|
10
10
|
export * from "./events/AgenticaCancelEvent";
|
|
11
|
+
|
|
11
12
|
export * from "./events/AgenticaDescribeEvent";
|
|
12
13
|
export * from "./events/AgenticaEvent";
|
|
13
14
|
export * from "./events/AgenticaEventSource";
|
|
@@ -17,34 +18,36 @@ export * from "./events/AgenticaResponseEvent";
|
|
|
17
18
|
export * from "./events/AgenticaSelectEvent";
|
|
18
19
|
export * from "./events/AgenticaTextEvent";
|
|
19
20
|
export * from "./events/AgenticaValidateEvent";
|
|
20
|
-
|
|
21
|
+
export * from "./events/MicroAgenticaEvent";
|
|
21
22
|
export * as factory from "./factory";
|
|
22
|
-
|
|
23
23
|
export * from "./functional/assertHttpLlmApplication";
|
|
24
|
+
|
|
24
25
|
export * from "./functional/validateHttpLlmApplication";
|
|
26
|
+
export * from "./histories/AgenticaCancelHistory";
|
|
27
|
+
export * from "./histories/AgenticaDescribeHistory";
|
|
28
|
+
export * from "./histories/AgenticaExecuteHistory";
|
|
29
|
+
export * from "./histories/AgenticaHistory";
|
|
30
|
+
export * from "./histories/AgenticaSelectHistory";
|
|
31
|
+
export * from "./histories/AgenticaTextHistory";
|
|
32
|
+
|
|
33
|
+
export * from "./histories/MicroAgenticaHistory";
|
|
34
|
+
|
|
25
35
|
export * from "./json/IAgenticaEventJson";
|
|
36
|
+
export * from "./json/IAgenticaHistoryJson";
|
|
26
37
|
export * from "./json/IAgenticaOperationJson";
|
|
27
38
|
export * from "./json/IAgenticaOperationSelectionJson";
|
|
28
|
-
export * from "./json/IAgenticaPromptJson";
|
|
29
|
-
|
|
30
39
|
export * from "./json/IAgenticaTokenUsageJson";
|
|
31
|
-
|
|
40
|
+
export * from "./MicroAgentica";
|
|
32
41
|
export * as orchestrate from "./orchestrate";
|
|
33
42
|
|
|
34
|
-
export * from "./prompts/AgenticaCancelPrompt";
|
|
35
|
-
export * from "./prompts/AgenticaDescribePrompt";
|
|
36
|
-
export * from "./prompts/AgenticaExecutePrompt";
|
|
37
|
-
export * from "./prompts/AgenticaPrompt";
|
|
38
|
-
export * from "./prompts/AgenticaSelectPrompt";
|
|
39
|
-
|
|
40
|
-
export * from "./prompts/AgenticaTextPrompt";
|
|
41
43
|
export * from "./structures/IAgenticaConfig";
|
|
42
44
|
export * from "./structures/IAgenticaController";
|
|
43
45
|
export * from "./structures/IAgenticaExecutor";
|
|
44
46
|
export * from "./structures/IAgenticaProps";
|
|
45
47
|
export * from "./structures/IAgenticaSystemPrompt";
|
|
46
|
-
|
|
47
48
|
export * from "./structures/IAgenticaVendor";
|
|
49
|
+
export * from "./structures/IMicroAgenticaConfig";
|
|
50
|
+
export * from "./structures/IMicroAgenticaProps";
|
|
48
51
|
|
|
49
52
|
/**
|
|
50
53
|
* @internal
|
|
@@ -2,16 +2,17 @@ import type OpenAI from "openai";
|
|
|
2
2
|
|
|
3
3
|
import type { AgenticaEventSource } from "../events/AgenticaEventSource";
|
|
4
4
|
|
|
5
|
+
import type { IAgenticaHistoryJson } from "./IAgenticaHistoryJson";
|
|
5
6
|
import type { IAgenticaOperationJson } from "./IAgenticaOperationJson";
|
|
6
7
|
import type { IAgenticaOperationSelectionJson } from "./IAgenticaOperationSelectionJson";
|
|
7
|
-
import type { IAgenticaPromptJson } from "./IAgenticaPromptJson";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Agentic AI agent event.
|
|
11
11
|
*
|
|
12
12
|
* `IAgenticaEventJson` is an union type of all possible events that can
|
|
13
|
-
* be emitted by the A.I. chatbot of the {@link Agentica} class.
|
|
14
|
-
*
|
|
13
|
+
* be emitted by the A.I. chatbot of the {@link Agentica} class.
|
|
14
|
+
*
|
|
15
|
+
* You can discriminate the subtype by checking the {@link type} property.
|
|
15
16
|
*
|
|
16
17
|
* @author Samchon
|
|
17
18
|
*/
|
|
@@ -119,7 +120,7 @@ export namespace IAgenticaEventJson {
|
|
|
119
120
|
*
|
|
120
121
|
* This prompt describes the return value of them.
|
|
121
122
|
*/
|
|
122
|
-
executes:
|
|
123
|
+
executes: IAgenticaHistoryJson.IExecute[];
|
|
123
124
|
|
|
124
125
|
/**
|
|
125
126
|
* Description text.
|
|
@@ -2,14 +2,14 @@ import type { IAgenticaOperationJson } from "./IAgenticaOperationJson";
|
|
|
2
2
|
import type { IAgenticaOperationSelectionJson } from "./IAgenticaOperationSelectionJson";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Agentic AI agent prompt.
|
|
6
6
|
*
|
|
7
|
-
* `
|
|
8
|
-
* be generated by the
|
|
7
|
+
* `IAgenticaHistoryJson` is an union type of all possible prompts that
|
|
8
|
+
* can be generated by the AI chatbot of the {@link Agentica} class.
|
|
9
9
|
*
|
|
10
|
-
* In other words, `
|
|
11
|
-
* is occurred during the conversation between the user and the
|
|
12
|
-
* in the {@link Agentica} class.
|
|
10
|
+
* In other words, `IAgenticaHistoryJson` is a type of chat history that
|
|
11
|
+
* is occurred during the conversation between the user and the AI
|
|
12
|
+
* chatbot in the {@link Agentica} class.
|
|
13
13
|
*
|
|
14
14
|
* If you want to continue the previous A.I. chatbot session, you can
|
|
15
15
|
* accomplish it by assigning the {@link IAgenticaProps.histories}
|
|
@@ -17,13 +17,13 @@ import type { IAgenticaOperationSelectionJson } from "./IAgenticaOperationSelect
|
|
|
17
17
|
*
|
|
18
18
|
* @author Samchon
|
|
19
19
|
*/
|
|
20
|
-
export type
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
export namespace
|
|
20
|
+
export type IAgenticaHistoryJson =
|
|
21
|
+
| IAgenticaHistoryJson.IText
|
|
22
|
+
| IAgenticaHistoryJson.ISelect
|
|
23
|
+
| IAgenticaHistoryJson.ICancel
|
|
24
|
+
| IAgenticaHistoryJson.IExecute
|
|
25
|
+
| IAgenticaHistoryJson.IDescribe;
|
|
26
|
+
export namespace IAgenticaHistoryJson {
|
|
27
27
|
/**
|
|
28
28
|
* Select prompt.
|
|
29
29
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IAgenticaOperationJson } from "./IAgenticaOperationJson";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Agentica agent operation selection.
|
|
5
5
|
*
|
|
6
6
|
* `IAgenticaOperationSelection` is a type represents an operation
|
|
7
7
|
* which has been selected by the A.I. chatbot of {@link Agentica}
|
|
@@ -14,6 +14,13 @@ import type { IAgenticaOperationJson } from "./IAgenticaOperationJson";
|
|
|
14
14
|
* @author Samchon
|
|
15
15
|
*/
|
|
16
16
|
export interface IAgenticaOperationSelectionJson {
|
|
17
|
+
/**
|
|
18
|
+
* The reason of the selection.
|
|
19
|
+
*/
|
|
17
20
|
reason: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Selected operation.
|
|
24
|
+
*/
|
|
18
25
|
operation: IAgenticaOperationJson;
|
|
19
26
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IAgenticaEventJson } from "./IAgenticaEventJson";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Micro Agentic AI agent event.
|
|
5
|
+
*
|
|
6
|
+
* `IMicroAgenticaEventJson` is an union type of all possible events
|
|
7
|
+
* that can be emitted by the A.I. chatbot of the {@link MicroAgentica}
|
|
8
|
+
* class.
|
|
9
|
+
*
|
|
10
|
+
* You can discriminate the subtype by checking the {@link type} property.
|
|
11
|
+
*
|
|
12
|
+
* @author Samchon
|
|
13
|
+
*/
|
|
14
|
+
export type IMicroAgenticaEventJson =
|
|
15
|
+
| IAgenticaEventJson.ICall
|
|
16
|
+
| IAgenticaEventJson.IDescribe
|
|
17
|
+
| IAgenticaEventJson.IExecute
|
|
18
|
+
| IAgenticaEventJson.IInitialize
|
|
19
|
+
| IAgenticaEventJson.IRequest
|
|
20
|
+
| IAgenticaEventJson.IText
|
|
21
|
+
| IAgenticaEventJson.IValidate;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { IAgenticaHistoryJson } from "./IAgenticaHistoryJson";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Micro Agentic AI agent prompt.
|
|
5
|
+
*
|
|
6
|
+
* `IMicroAgenticaPromptJson` is an union type of all possible prompts
|
|
7
|
+
* that can be generated by the AI chatbot of the {@link MicroAgentica}
|
|
8
|
+
* class.
|
|
9
|
+
*
|
|
10
|
+
* In other words, `IMicroAgenticaPromptJson` is a type of chat history
|
|
11
|
+
* that is occurred during the conversation between the user and the
|
|
12
|
+
* AI chatbot in the {@link MicroAgentica} class.
|
|
13
|
+
*
|
|
14
|
+
* If you want to continue the previous A.I. chatbot session, you can
|
|
15
|
+
* accomplish it by assigning the {@link IMicroAgenticaProps.histories}
|
|
16
|
+
* property when creating a new {@link MicroAgentica} instance.
|
|
17
|
+
*
|
|
18
|
+
* @author Samchon
|
|
19
|
+
*/
|
|
20
|
+
export type IMicroAgenticaHistoryJson =
|
|
21
|
+
| IAgenticaHistoryJson.IText
|
|
22
|
+
| IAgenticaHistoryJson.IExecute
|
|
23
|
+
| IAgenticaHistoryJson.IDescribe;
|