@agentica/core 0.8.3 → 0.9.0-dev.20250302
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +419 -404
- package/lib/Agentica.d.ts +10 -9
- package/lib/Agentica.js.map +1 -1
- package/lib/chatgpt/ChatGptAgent.d.ts +2 -1
- package/lib/chatgpt/ChatGptAgent.js.map +1 -1
- package/lib/chatgpt/ChatGptCallFunctionAgent.d.ts +2 -1
- package/lib/chatgpt/ChatGptCallFunctionAgent.js +3 -1
- package/lib/chatgpt/ChatGptCallFunctionAgent.js.map +1 -1
- package/lib/chatgpt/ChatGptCancelFunctionAgent.d.ts +3 -2
- package/lib/chatgpt/ChatGptCancelFunctionAgent.js +55 -2
- package/lib/chatgpt/ChatGptCancelFunctionAgent.js.map +1 -1
- package/lib/chatgpt/ChatGptDescribeFunctionAgent.d.ts +2 -1
- package/lib/chatgpt/ChatGptDescribeFunctionAgent.js.map +1 -1
- package/lib/chatgpt/ChatGptHistoryDecoder.d.ts +2 -1
- package/lib/chatgpt/ChatGptHistoryDecoder.js.map +1 -1
- package/lib/chatgpt/ChatGptInitializeFunctionAgent.d.ts +2 -1
- package/lib/chatgpt/ChatGptInitializeFunctionAgent.js +63 -1
- package/lib/chatgpt/ChatGptInitializeFunctionAgent.js.map +1 -1
- package/lib/chatgpt/ChatGptSelectFunctionAgent.d.ts +2 -1
- package/lib/chatgpt/ChatGptSelectFunctionAgent.js +55 -2
- package/lib/chatgpt/ChatGptSelectFunctionAgent.js.map +1 -1
- package/lib/functional/createHttpLlmApplication.js +826 -798
- package/lib/functional/createHttpLlmApplication.js.map +1 -1
- package/lib/index.mjs +987 -804
- package/lib/index.mjs.map +1 -1
- package/lib/internal/AgenticaDefaultPrompt.d.ts +2 -1
- package/lib/internal/AgenticaDefaultPrompt.js.map +1 -1
- package/lib/internal/AgenticaOperationComposer.d.ts +5 -4
- package/lib/internal/AgenticaOperationComposer.js +1 -1
- package/lib/internal/AgenticaOperationComposer.js.map +1 -1
- package/lib/internal/AgenticaPromptFactory.d.ts +3 -2
- package/lib/internal/AgenticaPromptFactory.js.map +1 -1
- package/lib/internal/AgenticaPromptTransformer.d.ts +5 -4
- package/lib/internal/AgenticaPromptTransformer.js.map +1 -1
- package/lib/structures/IAgenticaConfig.d.ts +4 -3
- package/lib/structures/IAgenticaContext.d.ts +7 -6
- package/lib/structures/IAgenticaController.d.ts +8 -8
- package/lib/structures/IAgenticaEvent.d.ts +19 -18
- package/lib/structures/IAgenticaExecutor.d.ts +7 -6
- package/lib/structures/IAgenticaOperation.d.ts +4 -4
- package/lib/structures/IAgenticaOperationCollection.d.ts +6 -5
- package/lib/structures/IAgenticaOperationSelection.d.ts +4 -4
- package/lib/structures/IAgenticaPrompt.d.ts +11 -11
- package/lib/structures/IAgenticaProps.d.ts +9 -4
- package/lib/structures/IAgenticaProvider.d.ts +22 -27
- package/lib/structures/IAgenticaSystemPrompt.d.ts +8 -7
- package/package.json +6 -9
- package/prompts/cancel.md +4 -4
- package/prompts/common.md +2 -2
- package/prompts/describe.md +6 -6
- package/prompts/execute.md +6 -6
- package/prompts/initialize.md +2 -2
- package/prompts/select.md +6 -6
- package/src/Agentica.ts +323 -318
- package/src/chatgpt/ChatGptAgent.ts +75 -71
- package/src/chatgpt/ChatGptCallFunctionAgent.ts +448 -445
- package/src/chatgpt/ChatGptCancelFunctionAgent.ts +287 -283
- package/src/chatgpt/ChatGptDescribeFunctionAgent.ts +52 -51
- package/src/chatgpt/ChatGptHistoryDecoder.ts +88 -87
- package/src/chatgpt/ChatGptInitializeFunctionAgent.ts +88 -88
- package/src/chatgpt/ChatGptSelectFunctionAgent.ts +319 -318
- package/src/functional/createHttpLlmApplication.ts +63 -63
- package/src/index.ts +19 -19
- package/src/internal/AgenticaConstant.ts +4 -4
- package/src/internal/AgenticaDefaultPrompt.ts +43 -39
- package/src/internal/AgenticaOperationComposer.ts +87 -82
- package/src/internal/AgenticaPromptFactory.ts +32 -30
- package/src/internal/AgenticaPromptTransformer.ts +86 -83
- package/src/internal/AgenticaTokenUsageAggregator.ts +115 -115
- package/src/internal/MathUtil.ts +3 -3
- package/src/internal/Singleton.ts +22 -22
- package/src/internal/__map_take.ts +15 -15
- package/src/structures/IAgenticaConfig.ts +123 -121
- package/src/structures/IAgenticaContext.ts +129 -128
- package/src/structures/IAgenticaController.ts +132 -130
- package/src/structures/IAgenticaEvent.ts +229 -224
- package/src/structures/IAgenticaExecutor.ts +156 -152
- package/src/structures/IAgenticaOperation.ts +64 -64
- package/src/structures/IAgenticaOperationCollection.ts +52 -50
- package/src/structures/IAgenticaOperationSelection.ts +69 -69
- package/src/structures/IAgenticaPrompt.ts +178 -173
- package/src/structures/IAgenticaProps.ts +70 -64
- package/src/structures/IAgenticaProvider.ts +39 -45
- package/src/structures/IAgenticaSystemPrompt.ts +124 -122
- package/src/structures/IAgenticaTokenUsage.ts +107 -107
- package/src/structures/internal/__IChatCancelFunctionsApplication.ts +23 -23
- package/src/structures/internal/__IChatFunctionReference.ts +21 -21
- package/src/structures/internal/__IChatInitialApplication.ts +15 -15
- package/src/structures/internal/__IChatSelectFunctionsApplication.ts +24 -24
- package/src/typings/AgenticaSource.ts +6 -6
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
1
2
|
import { IAgenticaContext } from "./IAgenticaContext";
|
|
2
3
|
import { IAgenticaPrompt } from "./IAgenticaPrompt";
|
|
3
4
|
/**
|
|
@@ -23,7 +24,7 @@ import { IAgenticaPrompt } from "./IAgenticaPrompt";
|
|
|
23
24
|
* @reference https://github.com/wrtnlabs/agentica/blob/main/packages/agent/src/chatgpt/ChatGptAgent.ts
|
|
24
25
|
* @author Samchon
|
|
25
26
|
*/
|
|
26
|
-
export interface IAgenticaExecutor {
|
|
27
|
+
export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
|
|
27
28
|
/**
|
|
28
29
|
* Initializer agent listing up functions.
|
|
29
30
|
*
|
|
@@ -52,7 +53,7 @@ export interface IAgenticaExecutor {
|
|
|
52
53
|
* @param ctx Context of the agent
|
|
53
54
|
* @returns List of prompts generated by the initializer
|
|
54
55
|
*/
|
|
55
|
-
initialize: null | ((ctx: IAgenticaContext) => Promise<IAgenticaPrompt[]>);
|
|
56
|
+
initialize: null | ((ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>);
|
|
56
57
|
/**
|
|
57
58
|
* Function selector agent.
|
|
58
59
|
*
|
|
@@ -80,7 +81,7 @@ export interface IAgenticaExecutor {
|
|
|
80
81
|
* @param ctx Context of the agent
|
|
81
82
|
* @returns List of prompts generated by the selector
|
|
82
83
|
*/
|
|
83
|
-
select: (ctx: IAgenticaContext) => Promise<IAgenticaPrompt[]>;
|
|
84
|
+
select: (ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>;
|
|
84
85
|
/**
|
|
85
86
|
* Function caller agent.
|
|
86
87
|
*
|
|
@@ -106,7 +107,7 @@ export interface IAgenticaExecutor {
|
|
|
106
107
|
* agent is the most general topic which can be universally
|
|
107
108
|
* applied to all domain fields.
|
|
108
109
|
*/
|
|
109
|
-
call: (ctx: IAgenticaContext) => Promise<IAgenticaPrompt[]>;
|
|
110
|
+
call: (ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>;
|
|
110
111
|
/**
|
|
111
112
|
* Describer agent of the function calling result.
|
|
112
113
|
*
|
|
@@ -117,7 +118,7 @@ export interface IAgenticaExecutor {
|
|
|
117
118
|
* @param executes List of function calling results
|
|
118
119
|
* @returns List of prompts generated by the describer
|
|
119
120
|
*/
|
|
120
|
-
describe: (ctx: IAgenticaContext
|
|
121
|
+
describe: (ctx: IAgenticaContext<Model>, executes: IAgenticaPrompt.IExecute<Model>[]) => Promise<IAgenticaPrompt<Model>[]>;
|
|
121
122
|
/**
|
|
122
123
|
* Function canceler agent.
|
|
123
124
|
*
|
|
@@ -140,5 +141,5 @@ export interface IAgenticaExecutor {
|
|
|
140
141
|
* @param ctx Context of the agent
|
|
141
142
|
* @returns List of prompts generated by the canceler
|
|
142
143
|
*/
|
|
143
|
-
cancel: (ctx: IAgenticaContext) => Promise<IAgenticaPrompt[]>;
|
|
144
|
+
cancel: (ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>;
|
|
144
145
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IHttpLlmFunction } from "@samchon/openapi";
|
|
1
|
+
import { IHttpLlmFunction, ILlmSchema } from "@samchon/openapi";
|
|
2
2
|
import { ILlmFunctionOfValidate } from "typia";
|
|
3
3
|
import { IAgenticaController } from "./IAgenticaController";
|
|
4
4
|
/**
|
|
@@ -16,16 +16,16 @@ import { IAgenticaController } from "./IAgenticaController";
|
|
|
16
16
|
*
|
|
17
17
|
* @author Samchon
|
|
18
18
|
*/
|
|
19
|
-
export type IAgenticaOperation = IAgenticaOperation.IHttp | IAgenticaOperation.IClass
|
|
19
|
+
export type IAgenticaOperation<Model extends ILlmSchema.Model> = IAgenticaOperation.IHttp<Model> | IAgenticaOperation.IClass<Model>;
|
|
20
20
|
export declare namespace IAgenticaOperation {
|
|
21
21
|
/**
|
|
22
22
|
* HTTP API operation.
|
|
23
23
|
*/
|
|
24
|
-
export type IHttp = IBase<"http", IAgenticaController.IHttp
|
|
24
|
+
export type IHttp<Model extends ILlmSchema.Model> = IBase<"http", IAgenticaController.IHttp<Model>, IHttpLlmFunction<Model>>;
|
|
25
25
|
/**
|
|
26
26
|
* TypeScript class operation.
|
|
27
27
|
*/
|
|
28
|
-
export type IClass = IBase<"class", IAgenticaController.IClass
|
|
28
|
+
export type IClass<Model extends ILlmSchema.Model> = IBase<"class", IAgenticaController.IClass<Model>, ILlmFunctionOfValidate<Model>>;
|
|
29
29
|
interface IBase<Protocol, Application, Function> {
|
|
30
30
|
/**
|
|
31
31
|
* Protocol discriminator.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
1
2
|
import { IAgenticaOperation } from "./IAgenticaOperation";
|
|
2
3
|
/**
|
|
3
4
|
* Collection of operations used in the Nestia Agent.
|
|
@@ -8,11 +9,11 @@ import { IAgenticaOperation } from "./IAgenticaOperation";
|
|
|
8
9
|
*
|
|
9
10
|
* @author Samchon
|
|
10
11
|
*/
|
|
11
|
-
export interface IAgenticaOperationCollection {
|
|
12
|
+
export interface IAgenticaOperationCollection<Model extends ILlmSchema.Model> {
|
|
12
13
|
/**
|
|
13
14
|
* List of every operations.
|
|
14
15
|
*/
|
|
15
|
-
array: IAgenticaOperation[];
|
|
16
|
+
array: IAgenticaOperation<Model>[];
|
|
16
17
|
/**
|
|
17
18
|
* Divided operations.
|
|
18
19
|
*
|
|
@@ -28,13 +29,13 @@ export interface IAgenticaOperationCollection {
|
|
|
28
29
|
* Otherwise, if the {@link IAgenticaConfig.capacity} has not been
|
|
29
30
|
* configured, this `divided` property would be the `undefined` value.
|
|
30
31
|
*/
|
|
31
|
-
divided?: IAgenticaOperation[][] | undefined;
|
|
32
|
+
divided?: IAgenticaOperation<Model>[][] | undefined;
|
|
32
33
|
/**
|
|
33
34
|
* Flat dictionary of operations.
|
|
34
35
|
*
|
|
35
36
|
* Dictionary of operations with their {@link IAgenticaOperation.name}.
|
|
36
37
|
*/
|
|
37
|
-
flat: Map<string, IAgenticaOperation
|
|
38
|
+
flat: Map<string, IAgenticaOperation<Model>>;
|
|
38
39
|
/**
|
|
39
40
|
* Group dictionary of operations.
|
|
40
41
|
*
|
|
@@ -42,5 +43,5 @@ export interface IAgenticaOperationCollection {
|
|
|
42
43
|
* {@link IAgenticaOperation.controller.name} and
|
|
43
44
|
* {@link IAgenticaOperation.function.name}.
|
|
44
45
|
*/
|
|
45
|
-
group: Map<string, Map<string, IAgenticaOperation
|
|
46
|
+
group: Map<string, Map<string, IAgenticaOperation<Model>>>;
|
|
46
47
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IHttpLlmFunction } from "@samchon/openapi";
|
|
1
|
+
import { IHttpLlmFunction, ILlmSchema } from "@samchon/openapi";
|
|
2
2
|
import { ILlmFunctionOfValidate } from "typia";
|
|
3
3
|
import { IAgenticaController } from "./IAgenticaController";
|
|
4
4
|
/**
|
|
@@ -14,10 +14,10 @@ import { IAgenticaController } from "./IAgenticaController";
|
|
|
14
14
|
*
|
|
15
15
|
* @author Samchon
|
|
16
16
|
*/
|
|
17
|
-
export type IAgenticaOperationSelection = IAgenticaOperationSelection.IHttp | IAgenticaOperationSelection.IClass
|
|
17
|
+
export type IAgenticaOperationSelection<Model extends ILlmSchema.Model> = IAgenticaOperationSelection.IHttp<Model> | IAgenticaOperationSelection.IClass<Model>;
|
|
18
18
|
export declare namespace IAgenticaOperationSelection {
|
|
19
|
-
export type IHttp = IBase<"http", IAgenticaController.IHttp
|
|
20
|
-
export type IClass = IBase<"class", IAgenticaController.IClass
|
|
19
|
+
export type IHttp<Model extends ILlmSchema.Model> = IBase<"http", IAgenticaController.IHttp<Model>, IHttpLlmFunction<Model>>;
|
|
20
|
+
export type IClass<Model extends ILlmSchema.Model> = IBase<"class", IAgenticaController.IClass<Model>, ILlmFunctionOfValidate<Model>>;
|
|
21
21
|
interface IBase<Protocol, Controller, Function> {
|
|
22
22
|
/**
|
|
23
23
|
* Discriminator protocol.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IHttpLlmFunction, IHttpResponse } from "@samchon/openapi";
|
|
1
|
+
import { IHttpLlmFunction, IHttpResponse, ILlmSchema } from "@samchon/openapi";
|
|
2
2
|
import { ILlmFunctionOfValidate } from "typia";
|
|
3
3
|
import { IAgenticaController } from "./IAgenticaController";
|
|
4
4
|
import { IAgenticaOperationSelection } from "./IAgenticaOperationSelection";
|
|
@@ -18,14 +18,14 @@ import { IAgenticaOperationSelection } from "./IAgenticaOperationSelection";
|
|
|
18
18
|
*
|
|
19
19
|
* @author Samchon
|
|
20
20
|
*/
|
|
21
|
-
export type IAgenticaPrompt = IAgenticaPrompt.IText | IAgenticaPrompt.ISelect | IAgenticaPrompt.ICancel | IAgenticaPrompt.IExecute | IAgenticaPrompt.IDescribe
|
|
21
|
+
export type IAgenticaPrompt<Model extends ILlmSchema.Model> = IAgenticaPrompt.IText | IAgenticaPrompt.ISelect<Model> | IAgenticaPrompt.ICancel<Model> | IAgenticaPrompt.IExecute<Model> | IAgenticaPrompt.IDescribe<Model>;
|
|
22
22
|
export declare namespace IAgenticaPrompt {
|
|
23
23
|
/**
|
|
24
24
|
* Select prompt.
|
|
25
25
|
*
|
|
26
26
|
* Selection prompt about candidate functions to call.
|
|
27
27
|
*/
|
|
28
|
-
export interface ISelect extends IBase<"select"> {
|
|
28
|
+
export interface ISelect<Model extends ILlmSchema.Model> extends IBase<"select"> {
|
|
29
29
|
/**
|
|
30
30
|
* ID of the LLM tool call result.
|
|
31
31
|
*/
|
|
@@ -33,14 +33,14 @@ export declare namespace IAgenticaPrompt {
|
|
|
33
33
|
/**
|
|
34
34
|
* Operations that have been selected.
|
|
35
35
|
*/
|
|
36
|
-
operations: IAgenticaOperationSelection[];
|
|
36
|
+
operations: IAgenticaOperationSelection<Model>[];
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Cancel prompt.
|
|
40
40
|
*
|
|
41
41
|
* Cancellation prompt about the candidate functions to be discarded.
|
|
42
42
|
*/
|
|
43
|
-
export interface ICancel extends IBase<"cancel"> {
|
|
43
|
+
export interface ICancel<Model extends ILlmSchema.Model> extends IBase<"cancel"> {
|
|
44
44
|
/**
|
|
45
45
|
* ID of the LLM tool call result.
|
|
46
46
|
*/
|
|
@@ -48,17 +48,17 @@ export declare namespace IAgenticaPrompt {
|
|
|
48
48
|
/**
|
|
49
49
|
* Operations that have been cancelled.
|
|
50
50
|
*/
|
|
51
|
-
operations: IAgenticaOperationSelection[];
|
|
51
|
+
operations: IAgenticaOperationSelection<Model>[];
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Execute prompt.
|
|
55
55
|
*
|
|
56
56
|
* Execution prompt about the LLM function calling.
|
|
57
57
|
*/
|
|
58
|
-
export type IExecute = IExecute.IHttp | IExecute.IClass
|
|
58
|
+
export type IExecute<Model extends ILlmSchema.Model> = IExecute.IHttp<Model> | IExecute.IClass<Model>;
|
|
59
59
|
export namespace IExecute {
|
|
60
|
-
export type IHttp = IBase<"http", IAgenticaController.IHttp
|
|
61
|
-
export type IClass = IBase<"class", IAgenticaController.IClass
|
|
60
|
+
export type IHttp<Model extends ILlmSchema.Model> = IBase<"http", IAgenticaController.IHttp<Model>, IHttpLlmFunction<Model>, IHttpResponse>;
|
|
61
|
+
export type IClass<Model extends ILlmSchema.Model> = IBase<"class", IAgenticaController.IClass<Model>, ILlmFunctionOfValidate<Model>, any>;
|
|
62
62
|
interface IBase<Protocol, Controller, Function, Value> {
|
|
63
63
|
/**
|
|
64
64
|
* Discriminator type.
|
|
@@ -104,13 +104,13 @@ export declare namespace IAgenticaPrompt {
|
|
|
104
104
|
*
|
|
105
105
|
* Description prompt about the return value of the LLM function calling.
|
|
106
106
|
*/
|
|
107
|
-
export interface IDescribe extends IBase<"describe"> {
|
|
107
|
+
export interface IDescribe<Model extends ILlmSchema.Model> extends IBase<"describe"> {
|
|
108
108
|
/**
|
|
109
109
|
* Executions of the LLM function calling.
|
|
110
110
|
*
|
|
111
111
|
* This prompt describes the return value of them.
|
|
112
112
|
*/
|
|
113
|
-
executions: IExecute[];
|
|
113
|
+
executions: IExecute<Model>[];
|
|
114
114
|
/**
|
|
115
115
|
* Description text.
|
|
116
116
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
1
2
|
import { Primitive } from "typia";
|
|
2
3
|
import { IAgenticaConfig } from "./IAgenticaConfig";
|
|
3
4
|
import { IAgenticaController } from "./IAgenticaController";
|
|
@@ -24,7 +25,11 @@ import { IAgenticaProvider } from "./IAgenticaProvider";
|
|
|
24
25
|
*
|
|
25
26
|
* @author Samchon
|
|
26
27
|
*/
|
|
27
|
-
export interface IAgenticaProps {
|
|
28
|
+
export interface IAgenticaProps<Model extends ILlmSchema.Model> {
|
|
29
|
+
/**
|
|
30
|
+
* LLM schema model.
|
|
31
|
+
*/
|
|
32
|
+
model: Model;
|
|
28
33
|
/**
|
|
29
34
|
* LLM service provider.
|
|
30
35
|
*/
|
|
@@ -32,7 +37,7 @@ export interface IAgenticaProps {
|
|
|
32
37
|
/**
|
|
33
38
|
* Controllers serving functions to call.
|
|
34
39
|
*/
|
|
35
|
-
controllers: IAgenticaController[];
|
|
40
|
+
controllers: IAgenticaController<Model>[];
|
|
36
41
|
/**
|
|
37
42
|
* Configuration of agent.
|
|
38
43
|
*
|
|
@@ -48,12 +53,12 @@ export interface IAgenticaProps {
|
|
|
48
53
|
* - `systemPrompt`: default prompts written in markdown
|
|
49
54
|
* - https://github.com/samchon/nestia/tree/master/packages/agent/prompts
|
|
50
55
|
*/
|
|
51
|
-
config?: IAgenticaConfig
|
|
56
|
+
config?: IAgenticaConfig<Model>;
|
|
52
57
|
/**
|
|
53
58
|
* Prompt histories.
|
|
54
59
|
*
|
|
55
60
|
* If you're starting the conversation from an existing session,
|
|
56
61
|
* assign the previouis prompt histories to this property.
|
|
57
62
|
*/
|
|
58
|
-
histories?: Primitive<IAgenticaPrompt
|
|
63
|
+
histories?: Primitive<IAgenticaPrompt<Model>>[];
|
|
59
64
|
}
|
|
@@ -5,37 +5,32 @@ import OpenAI from "openai";
|
|
|
5
5
|
* `IAgenticaProvider` is a type represents an LLM
|
|
6
6
|
* (Large Language Model) provider of the {@link Agentica}.
|
|
7
7
|
*
|
|
8
|
-
* Currently, {@link Agentica}
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* Currently, {@link Agentica} supports OpenAI SDK. However, it does
|
|
9
|
+
* not mean that you can use only OpenAI's GPT model in the
|
|
10
|
+
* {@link Agentica}. The OpenAI SDK is just a connection tool to the
|
|
11
|
+
* LLM provider's API, and you can use other LLM providers by configuring
|
|
12
|
+
* its `baseURL` and API key.
|
|
12
13
|
*
|
|
13
|
-
*
|
|
14
|
-
* please
|
|
14
|
+
* Therefore, if you want to use another LLM provider like Claude or
|
|
15
|
+
* Gemini, please configure the `baseURL` to the {@link api}, and
|
|
16
|
+
* set {@link IAgenticaController}'s schema model as "cluade" or
|
|
17
|
+
* "gemini".
|
|
15
18
|
*
|
|
16
19
|
* @author Samchon
|
|
17
20
|
*/
|
|
18
|
-
export
|
|
19
|
-
export declare namespace IAgenticaProvider {
|
|
21
|
+
export interface IAgenticaProvider {
|
|
20
22
|
/**
|
|
21
|
-
* OpenAI
|
|
23
|
+
* OpenAI API instance.
|
|
22
24
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*/
|
|
35
|
-
model: OpenAI.ChatModel;
|
|
36
|
-
/**
|
|
37
|
-
* Options for the request.
|
|
38
|
-
*/
|
|
39
|
-
options?: OpenAI.RequestOptions | undefined;
|
|
40
|
-
}
|
|
25
|
+
api: OpenAI;
|
|
26
|
+
/**
|
|
27
|
+
* Chat model to be used.
|
|
28
|
+
*
|
|
29
|
+
* `({}) & string` means to support third party hosting cloud(eg. openRouter, aws)
|
|
30
|
+
*/
|
|
31
|
+
model: OpenAI.ChatModel | ({} & string);
|
|
32
|
+
/**
|
|
33
|
+
* Options for the request.
|
|
34
|
+
*/
|
|
35
|
+
options?: OpenAI.RequestOptions | undefined;
|
|
41
36
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
1
2
|
import { IAgenticaConfig } from "./IAgenticaConfig";
|
|
2
3
|
import { IAgenticaPrompt } from "./IAgenticaPrompt";
|
|
3
4
|
/**
|
|
@@ -18,7 +19,7 @@ import { IAgenticaPrompt } from "./IAgenticaPrompt";
|
|
|
18
19
|
*
|
|
19
20
|
* @author Samchon
|
|
20
21
|
*/
|
|
21
|
-
export interface IAgenticaSystemPrompt {
|
|
22
|
+
export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
|
|
22
23
|
/**
|
|
23
24
|
* Common system prompt that would be used in every situation.
|
|
24
25
|
*
|
|
@@ -26,7 +27,7 @@ export interface IAgenticaSystemPrompt {
|
|
|
26
27
|
* @returns The common system prompt
|
|
27
28
|
* @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/common.md
|
|
28
29
|
*/
|
|
29
|
-
common?: (config?: IAgenticaConfig | undefined) => string;
|
|
30
|
+
common?: (config?: IAgenticaConfig<Model> | undefined) => string;
|
|
30
31
|
/**
|
|
31
32
|
* Initialize system prompt.
|
|
32
33
|
*
|
|
@@ -43,7 +44,7 @@ export interface IAgenticaSystemPrompt {
|
|
|
43
44
|
* @returns initialize system prompt
|
|
44
45
|
* @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/initialize.md
|
|
45
46
|
*/
|
|
46
|
-
initialize?: (histories: IAgenticaPrompt[]) => string;
|
|
47
|
+
initialize?: (histories: IAgenticaPrompt<Model>[]) => string;
|
|
47
48
|
/**
|
|
48
49
|
* Select system prompt.
|
|
49
50
|
*
|
|
@@ -63,7 +64,7 @@ export interface IAgenticaSystemPrompt {
|
|
|
63
64
|
* @returns select system promopt
|
|
64
65
|
* @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/select.md
|
|
65
66
|
*/
|
|
66
|
-
select?: (histories: IAgenticaPrompt[]) => string;
|
|
67
|
+
select?: (histories: IAgenticaPrompt<Model>[]) => string;
|
|
67
68
|
/**
|
|
68
69
|
* Cancel system prompt.
|
|
69
70
|
*
|
|
@@ -79,7 +80,7 @@ export interface IAgenticaSystemPrompt {
|
|
|
79
80
|
* @returns cancel system prompt
|
|
80
81
|
* @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/cancel.md
|
|
81
82
|
*/
|
|
82
|
-
cancel?: (histories: IAgenticaPrompt[]) => string;
|
|
83
|
+
cancel?: (histories: IAgenticaPrompt<Model>[]) => string;
|
|
83
84
|
/**
|
|
84
85
|
* Execute system prompt.
|
|
85
86
|
*
|
|
@@ -96,7 +97,7 @@ export interface IAgenticaSystemPrompt {
|
|
|
96
97
|
* @returns execute system prompt
|
|
97
98
|
* https://github.com/samchon/nestia/blob/master/packages/agent/prompts/execute.md
|
|
98
99
|
*/
|
|
99
|
-
execute?: (histories: IAgenticaPrompt[]) => string;
|
|
100
|
+
execute?: (histories: IAgenticaPrompt<Model>[]) => string;
|
|
100
101
|
/**
|
|
101
102
|
* Describe system prompt.
|
|
102
103
|
*
|
|
@@ -112,5 +113,5 @@ export interface IAgenticaSystemPrompt {
|
|
|
112
113
|
* @returns describe system prompt
|
|
113
114
|
* @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/describe.md
|
|
114
115
|
*/
|
|
115
|
-
describe?: (histories: IAgenticaPrompt.IExecute[]) => string;
|
|
116
|
+
describe?: (histories: IAgenticaPrompt.IExecute<Model>[]) => string;
|
|
116
117
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentica/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0-dev.20250302",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"description": "Agentic AI Library specialized in LLM Function Calling",
|
|
6
6
|
"scripts": {
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
"@nestia/e2e": "^0.8.2",
|
|
46
46
|
"@rollup/plugin-terser": "^0.4.4",
|
|
47
47
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
48
|
-
"@samchon/openapi": "^2.4.2",
|
|
49
48
|
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
|
50
49
|
"@types/node": "^22.13.4",
|
|
51
50
|
"@types/uuid": "^10.0.0",
|
|
@@ -57,18 +56,16 @@
|
|
|
57
56
|
"ts-node": "^10.9.2",
|
|
58
57
|
"ts-patch": "^3.3.0",
|
|
59
58
|
"typedoc": "^0.27.7",
|
|
60
|
-
"typescript": "~5.
|
|
61
|
-
"typia": "^7.6.4"
|
|
59
|
+
"typescript": "~5.8.2"
|
|
62
60
|
},
|
|
63
61
|
"dependencies": {
|
|
64
|
-
"@samchon/openapi": "^
|
|
65
|
-
"typia": "^
|
|
62
|
+
"@samchon/openapi": "^3.0.0",
|
|
63
|
+
"typia": "^8.0.0",
|
|
66
64
|
"uuid": "^11.0.4"
|
|
67
65
|
},
|
|
68
66
|
"peerDependencies": {
|
|
69
|
-
"@samchon/openapi": ">=
|
|
70
|
-
"openai": ">=
|
|
71
|
-
"typia": ">= 7.6.4"
|
|
67
|
+
"@samchon/openapi": ">=3.0.0 <4.0.0",
|
|
68
|
+
"openai": ">=4.80.0"
|
|
72
69
|
},
|
|
73
70
|
"module": "lib/index.mjs",
|
|
74
71
|
"typings": "lib/index.d.ts"
|
package/prompts/cancel.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
You are a helpful assistant for cancelling functions which are prepared to call.
|
|
2
|
-
|
|
3
|
-
Use the supplied tools to select some functions to cancel of `getApiFunctions()` returned.
|
|
4
|
-
|
|
1
|
+
You are a helpful assistant for cancelling functions which are prepared to call.
|
|
2
|
+
|
|
3
|
+
Use the supplied tools to select some functions to cancel of `getApiFunctions()` returned.
|
|
4
|
+
|
|
5
5
|
If you can't find any proper function to select, don't talk, don't do anything.
|
package/prompts/common.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
At first, the user's language locale code is "${locale}". When you are conversating with the user or describing the function calling result, consider it and always translate to the target locale language. Never conversate with different locale language text with the user.
|
|
2
|
-
|
|
1
|
+
At first, the user's language locale code is "${locale}". When you are conversating with the user or describing the function calling result, consider it and always translate to the target locale language. Never conversate with different locale language text with the user.
|
|
2
|
+
|
|
3
3
|
At second, the user's timezone is "${timezone}", and ISO datetime is ${datetime}. When you are conversating with the user, consider current time and user belonged timezone.
|
package/prompts/describe.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
You are a helpful assistant describing return values of function calls.
|
|
2
|
-
|
|
3
|
-
Above messages are the list of function call histories. When describing the return values, please do not too much shortly summarize them. Instead, provide detailed descriptions as much as.
|
|
4
|
-
|
|
5
|
-
Also, its content format must be markdown. If required, utilize the mermaid syntax for drawing some diagrams. When image contents are, just put them through the markdown image syntax.
|
|
6
|
-
|
|
1
|
+
You are a helpful assistant describing return values of function calls.
|
|
2
|
+
|
|
3
|
+
Above messages are the list of function call histories. When describing the return values, please do not too much shortly summarize them. Instead, provide detailed descriptions as much as.
|
|
4
|
+
|
|
5
|
+
Also, its content format must be markdown. If required, utilize the mermaid syntax for drawing some diagrams. When image contents are, just put them through the markdown image syntax.
|
|
6
|
+
|
|
7
7
|
At last, if user's language locale code is different with your description, please translate it to the user's language.
|
package/prompts/execute.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
You are a helpful assistant for tool calling.
|
|
2
|
-
|
|
3
|
-
Use the supplied tools to assist the user.
|
|
4
|
-
|
|
5
|
-
If previous messages are not enough to compose the arguments, you can ask the user to write more information. By the way, when asking the user to write more information, make the text concise and clear.
|
|
6
|
-
|
|
1
|
+
You are a helpful assistant for tool calling.
|
|
2
|
+
|
|
3
|
+
Use the supplied tools to assist the user.
|
|
4
|
+
|
|
5
|
+
If previous messages are not enough to compose the arguments, you can ask the user to write more information. By the way, when asking the user to write more information, make the text concise and clear.
|
|
6
|
+
|
|
7
7
|
For reference, in the "tool" role message content, the `function` property means metadata of the API operation. In other words, it is the function schema describing its purpose, parameters and return value types. And then the `data` property is the return value from the target function calling.
|
package/prompts/initialize.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
You are a helpful assistant.
|
|
2
|
-
|
|
1
|
+
You are a helpful assistant.
|
|
2
|
+
|
|
3
3
|
Use the supplied tools to assist the user.
|
package/prompts/select.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
You are a helpful assistant for selecting functions to call.
|
|
2
|
-
|
|
3
|
-
Use the supplied tools to select some functions of `getApiFunctions()` returned.
|
|
4
|
-
|
|
5
|
-
When selecting functions to call, pay attention to the relationship between functions. In particular, check the prerequisites between each function.
|
|
6
|
-
|
|
1
|
+
You are a helpful assistant for selecting functions to call.
|
|
2
|
+
|
|
3
|
+
Use the supplied tools to select some functions of `getApiFunctions()` returned.
|
|
4
|
+
|
|
5
|
+
When selecting functions to call, pay attention to the relationship between functions. In particular, check the prerequisites between each function.
|
|
6
|
+
|
|
7
7
|
If you can't find any proper function to select, just type your own message. By the way, when typing your own message, please consider the user's language locale code. If your message is different with the user's language, please translate it to the user's.
|