@agentica/core 0.15.7 → 0.16.1
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 +29 -29
- 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 +4 -4
- 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 +1408 -917
- 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 +58 -49
- 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 +5 -5
- 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 +5 -5
- package/lib/orchestrate/initialize.js.map +1 -1
- package/lib/orchestrate/internal/selectFunction.d.ts +1 -5
- package/lib/orchestrate/internal/selectFunction.js +5 -2
- 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 +36 -36
- package/src/MicroAgentica.ts +337 -0
- package/src/constants/AgenticaDefaultPrompt.ts +4 -2
- 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 +91 -67
- package/src/orchestrate/cancel.ts +4 -4
- package/src/orchestrate/describe.ts +13 -9
- package/src/orchestrate/execute.ts +7 -7
- package/src/orchestrate/initialize.ts +8 -8
- package/src/orchestrate/internal/selectFunction.ts +5 -2
- 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectFunction.js","sourceRoot":"","sources":["../../../src/orchestrate/internal/selectFunction.ts"],"names":[],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"selectFunction.js","sourceRoot":"","sources":["../../../src/orchestrate/internal/selectFunction.ts"],"names":[],"mappings":";;;;;;;;;;;AAaA,wCAmBC;AAzBD,iDAAyD;AACzD,yDAAoE;AAEpE;;GAEG;AACH,SAAsB,cAAc,CAAiC,GAA2B,EAAE,SAAmC;;QACnI,MAAM,SAAS,GACT,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,SAAS,GACT,IAAA,qCAAwB,EAAC;YACzB,SAAS;YACT,MAAM,EAAE,SAAS,CAAC,MAAM;SACzB,CAAC,CAAC;QACP,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1B,GAAG,CAAC,QAAQ,CACV,IAAA,0BAAiB,EAAC;YAChB,SAAS;SACV,CAAC,CACH,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAClB,OAAO,SAAS,CAAC;IACnB,CAAC;CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
2
|
import type { AgenticaContext } from "../context/AgenticaContext";
|
|
3
|
-
import type {
|
|
4
|
-
export declare function select<Model extends ILlmSchema.Model>(ctx: AgenticaContext<Model>): Promise<
|
|
3
|
+
import type { AgenticaHistory } from "../histories/AgenticaHistory";
|
|
4
|
+
export declare function select<Model extends ILlmSchema.Model>(ctx: AgenticaContext<Model>): Promise<AgenticaHistory<Model>[]>;
|
|
@@ -53,8 +53,8 @@ const AgenticaConstant_1 = require("../constants/AgenticaConstant");
|
|
|
53
53
|
const AgenticaDefaultPrompt_1 = require("../constants/AgenticaDefaultPrompt");
|
|
54
54
|
const AgenticaSystemPrompt_1 = require("../constants/AgenticaSystemPrompt");
|
|
55
55
|
const events_1 = require("../factory/events");
|
|
56
|
+
const histories_1 = require("../factory/histories");
|
|
56
57
|
const operations_1 = require("../factory/operations");
|
|
57
|
-
const prompts_1 = require("../factory/prompts");
|
|
58
58
|
const ChatGptCompletionMessageUtil_1 = require("../utils/ChatGptCompletionMessageUtil");
|
|
59
59
|
const StreamUtil_1 = require("../utils/StreamUtil");
|
|
60
60
|
const selectFunction_1 = require("./internal/selectFunction");
|
|
@@ -186,7 +186,7 @@ function select(ctx) {
|
|
|
186
186
|
.get(s.operation.function.name)), 0);
|
|
187
187
|
}
|
|
188
188
|
// RE-COLLECT SELECT FUNCTION EVENTS
|
|
189
|
-
const collection = (0,
|
|
189
|
+
const collection = (0, histories_1.createSelectHistory)({
|
|
190
190
|
id: (0, uuid_1.v4)(),
|
|
191
191
|
selections: [],
|
|
192
192
|
});
|
|
@@ -241,7 +241,7 @@ function step(ctx, operations, retry, failures) {
|
|
|
241
241
|
: {}))))),
|
|
242
242
|
},
|
|
243
243
|
// PREVIOUS HISTORIES
|
|
244
|
-
...ctx.histories.map(
|
|
244
|
+
...ctx.histories.map(histories_1.decodeHistory).flat(),
|
|
245
245
|
// USER INPUT
|
|
246
246
|
{
|
|
247
247
|
role: "user",
|
|
@@ -367,7 +367,7 @@ function step(ctx, operations, retry, failures) {
|
|
|
367
367
|
if (input === null) {
|
|
368
368
|
continue;
|
|
369
369
|
}
|
|
370
|
-
const collection = (0,
|
|
370
|
+
const collection = (0, histories_1.createSelectHistory)({
|
|
371
371
|
id: tc.id,
|
|
372
372
|
selections: [],
|
|
373
373
|
});
|
|
@@ -389,7 +389,7 @@ function step(ctx, operations, retry, failures) {
|
|
|
389
389
|
// ASSISTANT MESSAGE
|
|
390
390
|
if (choice.message.role === "assistant"
|
|
391
391
|
&& choice.message.content != null) {
|
|
392
|
-
const text = (0,
|
|
392
|
+
const text = (0, histories_1.createTextHistory)({
|
|
393
393
|
role: "assistant",
|
|
394
394
|
text: choice.message.content,
|
|
395
395
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/orchestrate/select.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,wBA2DC;;AA9FD,kDAA0B;AAC1B,+BAA0B;AAY1B,oEAAiE;AACjE,8EAA2E;AAC3E,4EAAyE;AACzE,8CAAoD;AACpD,sDAAiE;AACjE,
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/orchestrate/select.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,wBA2DC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AAO,QAAQ;SACZ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACN;YACE,IAAI,EAAE,WAAW;YACjB,UAAU,EAAE;gBACV;oBACE,IAAI,EAAE,UAAU;oBAChB,EAAE,EAAE,CAAC,CAAC,EAAE;oBACR,QAAQ,EAAE;wBACR,IAAI,EAAE,CAAC,CAAC,IAAI;wBACZ,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC;qBAC7C;iBACF;aACF;SACmD;QACtD;YACE,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC;YAC5C,YAAY,EAAE,CAAC,CAAC,EAAE;SAC6B;QACjD;YACE,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,wDAAwD;gBACxD,EAAE;gBACF,0CAA0C;aAC3C,CAAC,IAAI,CAAC,IAAI,CAAC;SACqC;KACtD,CAAC;SACD,IAAI,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
2
|
import type { AgenticaContext } from "../context/AgenticaContext";
|
|
3
|
-
import type {
|
|
3
|
+
import type { AgenticaHistory } from "../histories/AgenticaHistory";
|
|
4
4
|
import type { IAgenticaExecutor } from "./IAgenticaExecutor";
|
|
5
5
|
import type { IAgenticaSystemPrompt } from "./IAgenticaSystemPrompt";
|
|
6
6
|
/**
|
|
7
|
-
* Configuration for
|
|
7
|
+
* Configuration for Agentic Agent.
|
|
8
8
|
*
|
|
9
9
|
* `IAgenticaConfig` is an interface that defines the configuration
|
|
10
10
|
* properties of the {@link Agentica}. With this configuration, you
|
|
11
|
-
* can set the user's locale, timezone, and some of
|
|
11
|
+
* can set the user's {@link locale}, {@link timezone}, and some of
|
|
12
|
+
* {@link systemPrompt system prompts}.
|
|
12
13
|
*
|
|
13
14
|
* Also, you can affect to the LLM function selecing/calling logic by
|
|
14
15
|
* configuring additional properties. For an example, if you configure the
|
|
15
|
-
* {@link capacity} property, the
|
|
16
|
+
* {@link capacity} property, the AI chatbot will divide the functions
|
|
16
17
|
* into the several groups with the configured capacity and select proper
|
|
17
18
|
* functions to call by operating the multiple LLM function selecting
|
|
18
19
|
* agents parallelly.
|
|
@@ -35,7 +36,7 @@ export interface IAgenticaConfig<Model extends ILlmSchema.Model> {
|
|
|
35
36
|
* @returns Lit of prompts generated by the executor
|
|
36
37
|
* @default ChatGptAgent.execute
|
|
37
38
|
*/
|
|
38
|
-
executor?: Partial<IAgenticaExecutor<Model>> | ((ctx: AgenticaContext<Model>) => Promise<
|
|
39
|
+
executor?: Partial<IAgenticaExecutor<Model>> | ((ctx: AgenticaContext<Model>) => Promise<AgenticaHistory<Model>[]>);
|
|
39
40
|
/**
|
|
40
41
|
* System prompt messages.
|
|
41
42
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IHttpConnection, IHttpLlmApplication, IHttpLlmFunction, IHttpResponse, ILlmApplication, ILlmFunction, ILlmSchema } from "@samchon/openapi";
|
|
2
2
|
/**
|
|
3
|
-
* Controller of the
|
|
3
|
+
* Controller of the Agentica Agent.
|
|
4
4
|
*
|
|
5
5
|
* `IAgenticaController` is a type represents a controller of the
|
|
6
6
|
* {@link Agentica}, which serves a set of functions to be called
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
2
|
import type { AgenticaContext } from "../context/AgenticaContext";
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
3
|
+
import type { AgenticaOperation } from "../context/AgenticaOperation";
|
|
4
|
+
import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory";
|
|
5
|
+
import type { AgenticaHistory } from "../histories/AgenticaHistory";
|
|
5
6
|
/**
|
|
6
7
|
* Executor of the Agentic AI.
|
|
7
8
|
*
|
|
@@ -21,8 +22,8 @@ import type { AgenticaPrompt } from "../prompts/AgenticaPrompt";
|
|
|
21
22
|
* the executor logic, it can entirely break the {@link Agentica}'s
|
|
22
23
|
* operation.
|
|
23
24
|
*
|
|
24
|
-
* @reference https://
|
|
25
|
-
* @reference https://github.com/wrtnlabs/agentica/blob/main/packages/
|
|
25
|
+
* @reference https://wrtnlabs.io/agentica/docs/concepts/function-calling/#orchestration-strategy
|
|
26
|
+
* @reference https://github.com/wrtnlabs/agentica/blob/main/packages/core/src/orchestrate/execute.ts
|
|
26
27
|
* @author Samchon
|
|
27
28
|
*/
|
|
28
29
|
export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
|
|
@@ -54,7 +55,7 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
|
|
|
54
55
|
* @param ctx Context of the agent
|
|
55
56
|
* @returns List of prompts generated by the initializer
|
|
56
57
|
*/
|
|
57
|
-
initialize: null | ((ctx: AgenticaContext<Model>) => Promise<
|
|
58
|
+
initialize: null | ((ctx: AgenticaContext<Model>) => Promise<AgenticaHistory<Model>[]>);
|
|
58
59
|
/**
|
|
59
60
|
* Function selector agent.
|
|
60
61
|
*
|
|
@@ -82,7 +83,7 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
|
|
|
82
83
|
* @param ctx Context of the agent
|
|
83
84
|
* @returns List of prompts generated by the selector
|
|
84
85
|
*/
|
|
85
|
-
select: (ctx: AgenticaContext<Model>) => Promise<
|
|
86
|
+
select: (ctx: AgenticaContext<Model>) => Promise<AgenticaHistory<Model>[]>;
|
|
86
87
|
/**
|
|
87
88
|
* Function caller agent.
|
|
88
89
|
*
|
|
@@ -102,13 +103,14 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
|
|
|
102
103
|
* calling to the user as markdown content.
|
|
103
104
|
*
|
|
104
105
|
* @param ctx Context of the agent
|
|
106
|
+
* @param operation Lit of candidate operations to call
|
|
105
107
|
* @returns List of prompts generated by the caller
|
|
106
108
|
* @warning Recommend not to customize, due to its validation
|
|
107
109
|
* feedback strategy is working very well, and the `call`
|
|
108
110
|
* agent is the most general topic which can be universally
|
|
109
111
|
* applied to all domain fields.
|
|
110
112
|
*/
|
|
111
|
-
call: (ctx: AgenticaContext<Model>) => Promise<
|
|
113
|
+
call: (ctx: AgenticaContext<Model>, operations: AgenticaOperation<Model>[]) => Promise<AgenticaHistory<Model>[]>;
|
|
112
114
|
/**
|
|
113
115
|
* Describer agent of the function calling result.
|
|
114
116
|
*
|
|
@@ -119,7 +121,7 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
|
|
|
119
121
|
* @param executes List of function calling results
|
|
120
122
|
* @returns List of prompts generated by the describer
|
|
121
123
|
*/
|
|
122
|
-
describe: (ctx: AgenticaContext<Model>, executes:
|
|
124
|
+
describe: (ctx: AgenticaContext<Model>, executes: AgenticaExecuteHistory<Model>[]) => Promise<AgenticaHistory<Model>[]>;
|
|
123
125
|
/**
|
|
124
126
|
* Function canceler agent.
|
|
125
127
|
*
|
|
@@ -142,5 +144,5 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
|
|
|
142
144
|
* @param ctx Context of the agent
|
|
143
145
|
* @returns List of prompts generated by the canceler
|
|
144
146
|
*/
|
|
145
|
-
cancel: (ctx: AgenticaContext<Model>) => Promise<
|
|
147
|
+
cancel: (ctx: AgenticaContext<Model>) => Promise<AgenticaHistory<Model>[]>;
|
|
146
148
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
import type {
|
|
2
|
+
import type { IAgenticaHistoryJson } from "../json/IAgenticaHistoryJson";
|
|
3
3
|
import type { IAgenticaConfig } from "./IAgenticaConfig";
|
|
4
4
|
import type { IAgenticaController } from "./IAgenticaController";
|
|
5
5
|
import type { IAgenticaVendor } from "./IAgenticaVendor";
|
|
6
6
|
/**
|
|
7
|
-
* Properties of the
|
|
7
|
+
* Properties of the Agentica Agent.
|
|
8
8
|
*
|
|
9
9
|
* `IAgenticaProps` is an interface that defines the properties
|
|
10
10
|
* of the {@link Agentica.constructor}. In the `IAgenticaProps`,
|
|
@@ -59,5 +59,5 @@ export interface IAgenticaProps<Model extends ILlmSchema.Model> {
|
|
|
59
59
|
* If you're starting the conversation from an existing session,
|
|
60
60
|
* assign the previouis prompt histories to this property.
|
|
61
61
|
*/
|
|
62
|
-
histories?:
|
|
62
|
+
histories?: IAgenticaHistoryJson[];
|
|
63
63
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory";
|
|
3
|
+
import type { AgenticaHistory } from "../histories/AgenticaHistory";
|
|
4
4
|
import type { IAgenticaConfig } from "./IAgenticaConfig";
|
|
5
5
|
/**
|
|
6
|
-
* System prompt collection of the
|
|
6
|
+
* System prompt collection of the Agentic AI.
|
|
7
7
|
*
|
|
8
8
|
* `IAgenticaSystemPrompt` is a type represents a collection of system
|
|
9
9
|
* prompts that would be used by the A.I. chatbot of {@link Agentica}.
|
|
@@ -39,13 +39,13 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
39
39
|
*
|
|
40
40
|
* In that case, the `initialize` system prompt would be used. You can
|
|
41
41
|
* customize the `initialize` system prompt by assigning this function
|
|
42
|
-
* with the given {@link
|
|
42
|
+
* with the given {@link AgenticaHistory histories} parameter.
|
|
43
43
|
*
|
|
44
44
|
* @param histories Histories of the previous prompts
|
|
45
45
|
* @returns initialize system prompt
|
|
46
46
|
* @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/initialize.md
|
|
47
47
|
*/
|
|
48
|
-
initialize?: (histories:
|
|
48
|
+
initialize?: (histories: AgenticaHistory<Model>[]) => string;
|
|
49
49
|
/**
|
|
50
50
|
* Select system prompt.
|
|
51
51
|
*
|
|
@@ -55,7 +55,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
55
55
|
*
|
|
56
56
|
* In that case, this `select` system prompt would be used. You can
|
|
57
57
|
* customize it by assigning this function with the given
|
|
58
|
-
* {@link
|
|
58
|
+
* {@link AgenticaHistory histories} parameter.
|
|
59
59
|
*
|
|
60
60
|
* Note that, the `"select"` means only the function selection. It does
|
|
61
61
|
* not contain the filling argument or executing the function. It
|
|
@@ -65,7 +65,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
65
65
|
* @returns select system promopt
|
|
66
66
|
* @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/select.md
|
|
67
67
|
*/
|
|
68
|
-
select?: (histories:
|
|
68
|
+
select?: (histories: AgenticaHistory<Model>[]) => string;
|
|
69
69
|
/**
|
|
70
70
|
* Cancel system prompt.
|
|
71
71
|
*
|
|
@@ -75,13 +75,13 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
75
75
|
*
|
|
76
76
|
* In that case, this `cancel` system prompt would be used. You can
|
|
77
77
|
* customize it by assigning this function with the given
|
|
78
|
-
* {@link
|
|
78
|
+
* {@link AgenticaHistory histories} parameter.
|
|
79
79
|
*
|
|
80
80
|
* @param histories Histories of the previous prompts
|
|
81
81
|
* @returns cancel system prompt
|
|
82
82
|
* @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/cancel.md
|
|
83
83
|
*/
|
|
84
|
-
cancel?: (histories:
|
|
84
|
+
cancel?: (histories: AgenticaHistory<Model>[]) => string;
|
|
85
85
|
/**
|
|
86
86
|
* Execute system prompt.
|
|
87
87
|
*
|
|
@@ -92,13 +92,13 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
92
92
|
*
|
|
93
93
|
* In that case, this `execute` system prompt would be used. You can
|
|
94
94
|
* customize it by assigning this function with the given
|
|
95
|
-
* {@link
|
|
95
|
+
* {@link AgenticaHistory histories} parameter.
|
|
96
96
|
*
|
|
97
97
|
* @param histories Histories of the previous prompts
|
|
98
98
|
* @returns execute system prompt
|
|
99
99
|
* https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/execute.md
|
|
100
100
|
*/
|
|
101
|
-
execute?: (histories:
|
|
101
|
+
execute?: (histories: AgenticaHistory<Model>[]) => string;
|
|
102
102
|
/**
|
|
103
103
|
* Describe system prompt.
|
|
104
104
|
*
|
|
@@ -108,11 +108,11 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
|
108
108
|
*
|
|
109
109
|
* In that case, this `describe` system prompt would be used. You can
|
|
110
110
|
* customize it by assigning this function with the given
|
|
111
|
-
* {@link
|
|
111
|
+
* {@link AgenticaHistory histories} parameter.
|
|
112
112
|
*
|
|
113
113
|
* @param histories Histories of the previous prompts
|
|
114
114
|
* @returns describe system prompt
|
|
115
115
|
* @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/describe.md
|
|
116
116
|
*/
|
|
117
|
-
describe?: (histories:
|
|
117
|
+
describe?: (histories: AgenticaExecuteHistory<Model>[]) => string;
|
|
118
118
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
import type { IMicroAgenticaExecutor } from "./IMicroAgenticaExecutor";
|
|
3
|
+
import type { IMicroAgenticaSystemPrompt } from "./IMicroAgenticaSystemPrompt";
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for Micro Agentic Agent.
|
|
6
|
+
*
|
|
7
|
+
* `INicroAgenticaConfig` is an interface that defines the configuration
|
|
8
|
+
* properties of the {@link MicroAgentica}. With this configuration, you
|
|
9
|
+
* can set the user's {@link locale}, {@link timezone}, and some of
|
|
10
|
+
* {@link systemPrompt system prompts}.
|
|
11
|
+
*
|
|
12
|
+
* @author Samchon
|
|
13
|
+
*/
|
|
14
|
+
export interface IMicroAgenticaConfig<Model extends ILlmSchema.Model> {
|
|
15
|
+
/**
|
|
16
|
+
* Agent executor.
|
|
17
|
+
*
|
|
18
|
+
* Executor function of Agentic AI's iteration plan to internal agents
|
|
19
|
+
* running by the {@link Agentica.conversate} function.
|
|
20
|
+
*
|
|
21
|
+
* If you want to customize the agent execution plan, you can do it
|
|
22
|
+
* by assigning you logic function of entire or partial to this property.
|
|
23
|
+
* When customizing it, it would better to reference the
|
|
24
|
+
* {@link ChatGptAgent.execute} function.
|
|
25
|
+
*
|
|
26
|
+
* @param ctx Context of the agent
|
|
27
|
+
* @returns Lit of prompts generated by the executor
|
|
28
|
+
* @default ChatGptAgent.execute
|
|
29
|
+
*/
|
|
30
|
+
executor?: undefined | Partial<IMicroAgenticaExecutor<Model>>;
|
|
31
|
+
/**
|
|
32
|
+
* System prompt messages.
|
|
33
|
+
*
|
|
34
|
+
* System prompt messages if you want to customize the system prompt
|
|
35
|
+
* messages for each situation.
|
|
36
|
+
*/
|
|
37
|
+
systemPrompt?: IMicroAgenticaSystemPrompt<Model>;
|
|
38
|
+
/**
|
|
39
|
+
* Locale of the A.I. chatbot.
|
|
40
|
+
*
|
|
41
|
+
* If you configure this property, the A.I. chatbot will conversate with
|
|
42
|
+
* the given locale. You can get the locale value by
|
|
43
|
+
*
|
|
44
|
+
* - Browser: `navigator.language`
|
|
45
|
+
* - NodeJS: `process.env.LANG.split(".")[0]`
|
|
46
|
+
*
|
|
47
|
+
* @default your_locale
|
|
48
|
+
*/
|
|
49
|
+
locale?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Timezone of the A.I. chatbot.
|
|
52
|
+
*
|
|
53
|
+
* If you configure this property, the A.I. chatbot will consider the
|
|
54
|
+
* given timezone. You can get the timezone value by
|
|
55
|
+
* `Intl.DateTimeFormat().resolvedOptions().timeZone`.
|
|
56
|
+
*
|
|
57
|
+
* @default your_timezone
|
|
58
|
+
*/
|
|
59
|
+
timezone?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Retry count.
|
|
62
|
+
*
|
|
63
|
+
* If LLM function calling composed arguments are invalid,
|
|
64
|
+
* the A.I. chatbot will retry to call the function with
|
|
65
|
+
* the modified arguments.
|
|
66
|
+
*
|
|
67
|
+
* By the way, if you configure it to 0 or 1, the A.I. chatbot
|
|
68
|
+
* will not retry the LLM function calling for correcting the
|
|
69
|
+
* arguments.
|
|
70
|
+
*
|
|
71
|
+
* @default 3
|
|
72
|
+
*/
|
|
73
|
+
retry?: number;
|
|
74
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IMicroAgenticaConfig.js","sourceRoot":"","sources":["../../src/structures/IMicroAgenticaConfig.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
import type { MicroAgenticaContext } from "../context/MicroAgenticaContext";
|
|
3
|
+
import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory";
|
|
4
|
+
import type { MicroAgenticaHistory } from "../histories/MicroAgenticaHistory";
|
|
5
|
+
/**
|
|
6
|
+
* Executor of the Micro Agentic AI.
|
|
7
|
+
*
|
|
8
|
+
* `IMicroAgenticaExecutor` represents an executor of the
|
|
9
|
+
* {@link MicroAgentica}, composing its internal agents to accomplish
|
|
10
|
+
* the Agentic AI through the LLM (Large Language Model) function
|
|
11
|
+
* calling.
|
|
12
|
+
*
|
|
13
|
+
* You can customize one of these intnernal agents by configuring
|
|
14
|
+
* properties of the `IMicroAgenticaExecutor` type, and assigning
|
|
15
|
+
* it to the {@link IMicroAgenticaConfig.executor} property.
|
|
16
|
+
*
|
|
17
|
+
* @author Samchon
|
|
18
|
+
*/
|
|
19
|
+
export interface IMicroAgenticaExecutor<Model extends ILlmSchema.Model> {
|
|
20
|
+
/**
|
|
21
|
+
* Function caller agent.
|
|
22
|
+
*
|
|
23
|
+
* `Call` agent performs the LLM (Large Language Model) function
|
|
24
|
+
* calling from the candidate functions enrolled in the
|
|
25
|
+
* {@link AgenticaContext.stack}. And the scope of function calling
|
|
26
|
+
* is, not only just arguments filling, but also actual executing
|
|
27
|
+
* the function and returning the result.
|
|
28
|
+
*
|
|
29
|
+
* By the way, conversation context with user can be not enough to
|
|
30
|
+
* filling the arguments of the candidate functions. In that case,
|
|
31
|
+
* the `call` agent will ask the user to fill the missing arguments.
|
|
32
|
+
*
|
|
33
|
+
* Otherwise the cpnversation context is enough, so that succeeded
|
|
34
|
+
* to call some candidate functions, the `call` agent will step to
|
|
35
|
+
* the {@link describe} agent to explain the result of the function
|
|
36
|
+
* calling to the user as markdown content.
|
|
37
|
+
*
|
|
38
|
+
* @param ctx Context of the agent
|
|
39
|
+
* @returns List of prompts generated by the caller
|
|
40
|
+
* @warning Recommend not to customize, due to its validation
|
|
41
|
+
* feedback strategy is working very well, and the `call`
|
|
42
|
+
* agent is the most general topic which can be universally
|
|
43
|
+
* applied to all domain fields.
|
|
44
|
+
*/
|
|
45
|
+
call: (ctx: MicroAgenticaContext<Model>) => Promise<MicroAgenticaHistory<Model>[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Describer agent of the function calling result.
|
|
48
|
+
*
|
|
49
|
+
* `Describe` agent explains the results of the function callings
|
|
50
|
+
* to the user as markdown content.
|
|
51
|
+
*
|
|
52
|
+
* @param ctx Context of the agent
|
|
53
|
+
* @param executes List of function calling results
|
|
54
|
+
* @returns List of prompts generated by the describer
|
|
55
|
+
*/
|
|
56
|
+
describe: (ctx: MicroAgenticaContext<Model>, executes: AgenticaExecuteHistory<Model>[]) => Promise<MicroAgenticaHistory<Model>[]>;
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IMicroAgenticaExecutor.js","sourceRoot":"","sources":["../../src/structures/IMicroAgenticaExecutor.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
import type { IMicroAgenticaHistoryJson } from "../json/IMicroAgenticaHistoryJson";
|
|
3
|
+
import type { IAgenticaController } from "./IAgenticaController";
|
|
4
|
+
import type { IAgenticaVendor } from "./IAgenticaVendor";
|
|
5
|
+
import type { IMicroAgenticaConfig } from "./IMicroAgenticaConfig";
|
|
6
|
+
/**
|
|
7
|
+
* Properties of the Micro Agentica Agent.
|
|
8
|
+
*
|
|
9
|
+
* `IMicroAgenticaProps` is an interface that defines the properties
|
|
10
|
+
* of the {@link MicroAgentica.constructor}. In the `IMicroAgenticaProps`,
|
|
11
|
+
* there're everything to prepare to create a Micro A.I. chatbot
|
|
12
|
+
* performing the LLM (Large Language Model) function calling.
|
|
13
|
+
*
|
|
14
|
+
* At first, you have to specify the LLM service {@link vendor} 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,
|
|
19
|
+
* timezone, 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 IMicroAgenticaProps<Model extends ILlmSchema.Model> {
|
|
28
|
+
/**
|
|
29
|
+
* LLM schema model.
|
|
30
|
+
*/
|
|
31
|
+
model: Model;
|
|
32
|
+
/**
|
|
33
|
+
* LLM service vendor.
|
|
34
|
+
*/
|
|
35
|
+
vendor: IAgenticaVendor;
|
|
36
|
+
/**
|
|
37
|
+
* Controllers serving functions to call.
|
|
38
|
+
*/
|
|
39
|
+
controllers: IAgenticaController<Model>[];
|
|
40
|
+
/**
|
|
41
|
+
* Configuration of agent.
|
|
42
|
+
*
|
|
43
|
+
* Configuration of A.I. chatbot agent including the user's locale,
|
|
44
|
+
* timezone, and some of system prompts. Also, you can affect to the
|
|
45
|
+
* LLM function selecting/calling logic by configuring additional
|
|
46
|
+
* properties.
|
|
47
|
+
*
|
|
48
|
+
* If you don't configure this property, these values would be default.
|
|
49
|
+
*
|
|
50
|
+
* - `locale`: your system's locale and timezone
|
|
51
|
+
* - `timezone`: your system's timezone
|
|
52
|
+
* - `systemPrompt`: default prompts written in markdown
|
|
53
|
+
* - https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts
|
|
54
|
+
*/
|
|
55
|
+
config?: IMicroAgenticaConfig<Model>;
|
|
56
|
+
/**
|
|
57
|
+
* Prompt histories.
|
|
58
|
+
*
|
|
59
|
+
* If you're starting the conversation from an existing session,
|
|
60
|
+
* assign the previouis prompt histories to this property.
|
|
61
|
+
*/
|
|
62
|
+
histories?: IMicroAgenticaHistoryJson[];
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IMicroAgenticaProps.js","sourceRoot":"","sources":["../../src/structures/IMicroAgenticaProps.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory";
|
|
3
|
+
import type { MicroAgenticaHistory } from "../histories/MicroAgenticaHistory";
|
|
4
|
+
import type { IMicroAgenticaConfig } from "./IMicroAgenticaConfig";
|
|
5
|
+
/**
|
|
6
|
+
* System prompt collection of the Micro Agentic AI.
|
|
7
|
+
*
|
|
8
|
+
* `IMicroAgenticaSystemPrompt` is a type represents a collection of
|
|
9
|
+
* system prompts that would be used by the A.I. chatbot of
|
|
10
|
+
* {@link MicroAgentica}.
|
|
11
|
+
*
|
|
12
|
+
* You can customize the system prompt by configuring the
|
|
13
|
+
* {@link IAgenticaConfig.systemPrompt} property when creating a new
|
|
14
|
+
* {@link Agentica} instance.
|
|
15
|
+
*
|
|
16
|
+
* If you don't configure any system prompts, the default system prompts
|
|
17
|
+
* would be used which are written in the below directory as markdown
|
|
18
|
+
* documents.
|
|
19
|
+
*
|
|
20
|
+
* - https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts
|
|
21
|
+
*
|
|
22
|
+
* @author Samchon
|
|
23
|
+
*/
|
|
24
|
+
export interface IMicroAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
25
|
+
/**
|
|
26
|
+
* Common system prompt that would be used in every situation.
|
|
27
|
+
*
|
|
28
|
+
* @param config Configuration of the agent
|
|
29
|
+
* @returns The common system prompt
|
|
30
|
+
* @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/common.md
|
|
31
|
+
*/
|
|
32
|
+
common?: (config?: IMicroAgenticaConfig<Model> | undefined) => string;
|
|
33
|
+
/**
|
|
34
|
+
* Execute system prompt.
|
|
35
|
+
*
|
|
36
|
+
* The {@link Agentica} has a process filling the arguments of some
|
|
37
|
+
* selected candidate functions by the LLM (Large Language Model)
|
|
38
|
+
* function calling feature with the previous prompt histories, and
|
|
39
|
+
* executing the arguments filled function with validation feedback.
|
|
40
|
+
*
|
|
41
|
+
* In that case, this `execute` system prompt would be used. You can
|
|
42
|
+
* customize it by assigning this function with the given
|
|
43
|
+
* {@link AgenticaHistory histories} parameter.
|
|
44
|
+
*
|
|
45
|
+
* @param histories Histories of the previous prompts
|
|
46
|
+
* @returns execute system prompt
|
|
47
|
+
* https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/execute.md
|
|
48
|
+
*/
|
|
49
|
+
execute?: null | ((histories: MicroAgenticaHistory<Model>[]) => string);
|
|
50
|
+
/**
|
|
51
|
+
* Describe system prompt.
|
|
52
|
+
*
|
|
53
|
+
* The {@link Agentica} has a process describing the return values of
|
|
54
|
+
* the executed functions by requesting to the A.I. agent with the
|
|
55
|
+
* previous prompt histories.
|
|
56
|
+
*
|
|
57
|
+
* In that case, this `describe` system prompt would be used. You can
|
|
58
|
+
* customize it by assigning this function with the given
|
|
59
|
+
* {@link AgenticaHistory histories} parameter.
|
|
60
|
+
*
|
|
61
|
+
* @param histories Histories of the previous prompts
|
|
62
|
+
* @returns describe system prompt
|
|
63
|
+
* @default https://github.com/wrtnlabs/agentica/tree/main/packages/core/prompts/describe.md
|
|
64
|
+
*/
|
|
65
|
+
describe?: (histories: AgenticaExecuteHistory<Model>[]) => string;
|
|
66
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IMicroAgenticaSystemPrompt.js","sourceRoot":"","sources":["../../src/structures/IMicroAgenticaSystemPrompt.ts"],"names":[],"mappings":""}
|