@agentica/core 0.7.0-dev.20250224-5 → 0.7.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/LICENSE +21 -21
- package/README.md +404 -464
- package/package.json +2 -1
- 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 +322 -322
- package/src/chatgpt/ChatGptAgent.ts +71 -71
- package/src/chatgpt/ChatGptCallFunctionAgent.ts +445 -445
- package/src/chatgpt/ChatGptCancelFunctionAgent.ts +283 -283
- package/src/chatgpt/ChatGptDescribeFunctionAgent.ts +51 -51
- package/src/chatgpt/ChatGptHistoryDecoder.ts +86 -86
- package/src/chatgpt/ChatGptInitializeFunctionAgent.ts +88 -88
- package/src/chatgpt/ChatGptSelectFunctionAgent.ts +316 -316
- package/src/functional/createHttpLlmApplication.ts +63 -63
- package/src/index.ts +19 -19
- package/src/internal/AgenticaConstant.ts +4 -4
- package/src/internal/AgenticaCostAggregator.ts +35 -35
- package/src/internal/AgenticaDefaultPrompt.ts +39 -39
- package/src/internal/AgenticaOperationComposer.ts +82 -82
- package/src/internal/AgenticaPromptFactory.ts +30 -30
- package/src/internal/AgenticaPromptTransformer.ts +83 -83
- 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 +121 -121
- package/src/structures/IAgenticaContext.ts +128 -128
- package/src/structures/IAgenticaController.ts +130 -130
- package/src/structures/IAgenticaEvent.ts +224 -224
- package/src/structures/IAgenticaExecutor.ts +152 -152
- package/src/structures/IAgenticaOperation.ts +64 -64
- package/src/structures/IAgenticaOperationCollection.ts +50 -50
- package/src/structures/IAgenticaOperationSelection.ts +69 -69
- package/src/structures/IAgenticaPrompt.ts +173 -173
- package/src/structures/IAgenticaProps.ts +64 -64
- package/src/structures/IAgenticaProvider.ts +45 -45
- package/src/structures/IAgenticaSystemPrompt.ts +122 -122
- package/src/structures/IAgenticaTokenUsage.ts +52 -52
- 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,45 +1,45 @@
|
|
|
1
|
-
import OpenAI from "openai";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* LLM Provider for Nestia Chat.
|
|
5
|
-
*
|
|
6
|
-
* `IAgenticaProvider` is a type represents an LLM
|
|
7
|
-
* (Large Language Model) provider of the {@link Agentica}.
|
|
8
|
-
*
|
|
9
|
-
* Currently, {@link Agentica} is supporting only one provider OpenAI.
|
|
10
|
-
* You can specify the provider by configuring the `type` property as
|
|
11
|
-
* `"chatgpt"`. Also, you have to assign the OpenAI API client instance
|
|
12
|
-
* to the `api` property, and specify the `model` to use.
|
|
13
|
-
*
|
|
14
|
-
* If you want to use another LLM provider like Claude or Gemini,
|
|
15
|
-
* please write an issue or contribute to `nestia` please.
|
|
16
|
-
*
|
|
17
|
-
* @author Samchon
|
|
18
|
-
*/
|
|
19
|
-
export type IAgenticaProvider = IAgenticaProvider.IChatGpt;
|
|
20
|
-
export namespace IAgenticaProvider {
|
|
21
|
-
/**
|
|
22
|
-
* OpenAI provider.
|
|
23
|
-
*/
|
|
24
|
-
export interface IChatGpt {
|
|
25
|
-
/**
|
|
26
|
-
* Discriminator type.
|
|
27
|
-
*/
|
|
28
|
-
type: "chatgpt";
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* OpenAI API instance.
|
|
32
|
-
*/
|
|
33
|
-
api: OpenAI;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Chat model to be used.
|
|
37
|
-
*/
|
|
38
|
-
model: OpenAI.ChatModel;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Options for the request.
|
|
42
|
-
*/
|
|
43
|
-
options?: OpenAI.RequestOptions | undefined;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
1
|
+
import OpenAI from "openai";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* LLM Provider for Nestia Chat.
|
|
5
|
+
*
|
|
6
|
+
* `IAgenticaProvider` is a type represents an LLM
|
|
7
|
+
* (Large Language Model) provider of the {@link Agentica}.
|
|
8
|
+
*
|
|
9
|
+
* Currently, {@link Agentica} is supporting only one provider OpenAI.
|
|
10
|
+
* You can specify the provider by configuring the `type` property as
|
|
11
|
+
* `"chatgpt"`. Also, you have to assign the OpenAI API client instance
|
|
12
|
+
* to the `api` property, and specify the `model` to use.
|
|
13
|
+
*
|
|
14
|
+
* If you want to use another LLM provider like Claude or Gemini,
|
|
15
|
+
* please write an issue or contribute to `nestia` please.
|
|
16
|
+
*
|
|
17
|
+
* @author Samchon
|
|
18
|
+
*/
|
|
19
|
+
export type IAgenticaProvider = IAgenticaProvider.IChatGpt;
|
|
20
|
+
export namespace IAgenticaProvider {
|
|
21
|
+
/**
|
|
22
|
+
* OpenAI provider.
|
|
23
|
+
*/
|
|
24
|
+
export interface IChatGpt {
|
|
25
|
+
/**
|
|
26
|
+
* Discriminator type.
|
|
27
|
+
*/
|
|
28
|
+
type: "chatgpt";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* OpenAI API instance.
|
|
32
|
+
*/
|
|
33
|
+
api: OpenAI;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Chat model to be used.
|
|
37
|
+
*/
|
|
38
|
+
model: OpenAI.ChatModel;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Options for the request.
|
|
42
|
+
*/
|
|
43
|
+
options?: OpenAI.RequestOptions | undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
import { IAgenticaConfig } from "./IAgenticaConfig";
|
|
2
|
-
import { IAgenticaPrompt } from "./IAgenticaPrompt";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* System prompt collection of the A.I. chatbot.
|
|
6
|
-
*
|
|
7
|
-
* `IAgenticaSystemPrompt` is a type represents a collection of system
|
|
8
|
-
* prompts that would be used by the A.I. chatbot of {@link Agentica}.
|
|
9
|
-
*
|
|
10
|
-
* You can customize the system prompt by configuring the
|
|
11
|
-
* {@link IAgenticaConfig.systemPrompt} property when creating a new
|
|
12
|
-
* {@link Agentica} instance.
|
|
13
|
-
*
|
|
14
|
-
* If you don't configure any system prompts, the default system prompts
|
|
15
|
-
* would be used which are written in the below directory as markdown
|
|
16
|
-
* documents.
|
|
17
|
-
*
|
|
18
|
-
* - https://github.com/samchon/nestia/tree/master/packages/agent/prompts
|
|
19
|
-
*
|
|
20
|
-
* @author Samchon
|
|
21
|
-
*/
|
|
22
|
-
export interface IAgenticaSystemPrompt {
|
|
23
|
-
/**
|
|
24
|
-
* Common system prompt that would be used in every situation.
|
|
25
|
-
*
|
|
26
|
-
* @param config Configuration of the agent
|
|
27
|
-
* @returns The common system prompt
|
|
28
|
-
* @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/common.md
|
|
29
|
-
*/
|
|
30
|
-
common?: (config?: IAgenticaConfig | undefined) => string;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Initialize system prompt.
|
|
34
|
-
*
|
|
35
|
-
* When the A.I. chatbot has not informed any functions to the agent
|
|
36
|
-
* yet because the user has not implied any function calling request yet,
|
|
37
|
-
* {@link Agentica} says that it is a circumstance that nothing has
|
|
38
|
-
* been initialized yet.
|
|
39
|
-
*
|
|
40
|
-
* In that case, the `initialize` system prompt would be used. You can
|
|
41
|
-
* customize the `initialize` system prompt by assigning this function
|
|
42
|
-
* with the given {@link IAgenticaPrompt histories} parameter.
|
|
43
|
-
*
|
|
44
|
-
* @param histories Histories of the previous prompts
|
|
45
|
-
* @returns initialize system prompt
|
|
46
|
-
* @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/initialize.md
|
|
47
|
-
*/
|
|
48
|
-
initialize?: (histories: IAgenticaPrompt[]) => string;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Select system prompt.
|
|
52
|
-
*
|
|
53
|
-
* The {@link Agentica} has a process selecting some candidate
|
|
54
|
-
* functions to call by asking to the A.I. agent with the previous
|
|
55
|
-
* prompt histories.
|
|
56
|
-
*
|
|
57
|
-
* In that case, this `select` system prompt would be used. You can
|
|
58
|
-
* customize it by assigning this function with the given
|
|
59
|
-
* {@link IAgenticaPrompt histories} parameter.
|
|
60
|
-
*
|
|
61
|
-
* Note that, the `"select"` means only the function selection. It does
|
|
62
|
-
* not contain the filling argument or executing the function. It
|
|
63
|
-
* literally contains only the selection process.
|
|
64
|
-
*
|
|
65
|
-
* @param histories Histories of the previous prompts
|
|
66
|
-
* @returns select system promopt
|
|
67
|
-
* @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/select.md
|
|
68
|
-
*/
|
|
69
|
-
select?: (histories: IAgenticaPrompt[]) => string;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Cancel system prompt.
|
|
73
|
-
*
|
|
74
|
-
* The {@link Agentica} has a process canceling some candidate
|
|
75
|
-
* functions to call by asking to the A.I. agent with the previous
|
|
76
|
-
* prompt histories.
|
|
77
|
-
*
|
|
78
|
-
* In that case, this `cancel` system prompt would be used. You can
|
|
79
|
-
* customize it by assigning this function with the given
|
|
80
|
-
* {@link IAgenticaPrompt histories} parameter.
|
|
81
|
-
*
|
|
82
|
-
* @param histories Histories of the previous prompts
|
|
83
|
-
* @returns cancel system prompt
|
|
84
|
-
* @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/cancel.md
|
|
85
|
-
*/
|
|
86
|
-
cancel?: (histories: IAgenticaPrompt[]) => string;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Execute system prompt.
|
|
90
|
-
*
|
|
91
|
-
* The {@link Agentica} has a process filling the arguments of some
|
|
92
|
-
* selected candidate functions by the LLM (Large Language Model)
|
|
93
|
-
* function calling feature with the previous prompt histories, and
|
|
94
|
-
* executing the arguments filled function with validation feedback.
|
|
95
|
-
*
|
|
96
|
-
* In that case, this `execute` system prompt would be used. You can
|
|
97
|
-
* customize it by assigning this function with the given
|
|
98
|
-
* {@link IAgenticaPrompt histories} parameter.
|
|
99
|
-
*
|
|
100
|
-
* @param histories Histories of the previous prompts
|
|
101
|
-
* @returns execute system prompt
|
|
102
|
-
* https://github.com/samchon/nestia/blob/master/packages/agent/prompts/execute.md
|
|
103
|
-
*/
|
|
104
|
-
execute?: (histories: IAgenticaPrompt[]) => string;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Describe system prompt.
|
|
108
|
-
*
|
|
109
|
-
* The {@link Agentica} has a process describing the return values of
|
|
110
|
-
* the executed functions by requesting to the A.I. agent with the
|
|
111
|
-
* previous prompt histories.
|
|
112
|
-
*
|
|
113
|
-
* In that case, this `describe` system prompt would be used. You can
|
|
114
|
-
* customize it by assigning this function with the given
|
|
115
|
-
* {@link IAgenticaPrompt histories} parameter.
|
|
116
|
-
*
|
|
117
|
-
* @param histories Histories of the previous prompts
|
|
118
|
-
* @returns describe system prompt
|
|
119
|
-
* @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/describe.md
|
|
120
|
-
*/
|
|
121
|
-
describe?: (histories: IAgenticaPrompt.IExecute[]) => string;
|
|
122
|
-
}
|
|
1
|
+
import { IAgenticaConfig } from "./IAgenticaConfig";
|
|
2
|
+
import { IAgenticaPrompt } from "./IAgenticaPrompt";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* System prompt collection of the A.I. chatbot.
|
|
6
|
+
*
|
|
7
|
+
* `IAgenticaSystemPrompt` is a type represents a collection of system
|
|
8
|
+
* prompts that would be used by the A.I. chatbot of {@link Agentica}.
|
|
9
|
+
*
|
|
10
|
+
* You can customize the system prompt by configuring the
|
|
11
|
+
* {@link IAgenticaConfig.systemPrompt} property when creating a new
|
|
12
|
+
* {@link Agentica} instance.
|
|
13
|
+
*
|
|
14
|
+
* If you don't configure any system prompts, the default system prompts
|
|
15
|
+
* would be used which are written in the below directory as markdown
|
|
16
|
+
* documents.
|
|
17
|
+
*
|
|
18
|
+
* - https://github.com/samchon/nestia/tree/master/packages/agent/prompts
|
|
19
|
+
*
|
|
20
|
+
* @author Samchon
|
|
21
|
+
*/
|
|
22
|
+
export interface IAgenticaSystemPrompt {
|
|
23
|
+
/**
|
|
24
|
+
* Common system prompt that would be used in every situation.
|
|
25
|
+
*
|
|
26
|
+
* @param config Configuration of the agent
|
|
27
|
+
* @returns The common system prompt
|
|
28
|
+
* @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/common.md
|
|
29
|
+
*/
|
|
30
|
+
common?: (config?: IAgenticaConfig | undefined) => string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Initialize system prompt.
|
|
34
|
+
*
|
|
35
|
+
* When the A.I. chatbot has not informed any functions to the agent
|
|
36
|
+
* yet because the user has not implied any function calling request yet,
|
|
37
|
+
* {@link Agentica} says that it is a circumstance that nothing has
|
|
38
|
+
* been initialized yet.
|
|
39
|
+
*
|
|
40
|
+
* In that case, the `initialize` system prompt would be used. You can
|
|
41
|
+
* customize the `initialize` system prompt by assigning this function
|
|
42
|
+
* with the given {@link IAgenticaPrompt histories} parameter.
|
|
43
|
+
*
|
|
44
|
+
* @param histories Histories of the previous prompts
|
|
45
|
+
* @returns initialize system prompt
|
|
46
|
+
* @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/initialize.md
|
|
47
|
+
*/
|
|
48
|
+
initialize?: (histories: IAgenticaPrompt[]) => string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Select system prompt.
|
|
52
|
+
*
|
|
53
|
+
* The {@link Agentica} has a process selecting some candidate
|
|
54
|
+
* functions to call by asking to the A.I. agent with the previous
|
|
55
|
+
* prompt histories.
|
|
56
|
+
*
|
|
57
|
+
* In that case, this `select` system prompt would be used. You can
|
|
58
|
+
* customize it by assigning this function with the given
|
|
59
|
+
* {@link IAgenticaPrompt histories} parameter.
|
|
60
|
+
*
|
|
61
|
+
* Note that, the `"select"` means only the function selection. It does
|
|
62
|
+
* not contain the filling argument or executing the function. It
|
|
63
|
+
* literally contains only the selection process.
|
|
64
|
+
*
|
|
65
|
+
* @param histories Histories of the previous prompts
|
|
66
|
+
* @returns select system promopt
|
|
67
|
+
* @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/select.md
|
|
68
|
+
*/
|
|
69
|
+
select?: (histories: IAgenticaPrompt[]) => string;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Cancel system prompt.
|
|
73
|
+
*
|
|
74
|
+
* The {@link Agentica} has a process canceling some candidate
|
|
75
|
+
* functions to call by asking to the A.I. agent with the previous
|
|
76
|
+
* prompt histories.
|
|
77
|
+
*
|
|
78
|
+
* In that case, this `cancel` system prompt would be used. You can
|
|
79
|
+
* customize it by assigning this function with the given
|
|
80
|
+
* {@link IAgenticaPrompt histories} parameter.
|
|
81
|
+
*
|
|
82
|
+
* @param histories Histories of the previous prompts
|
|
83
|
+
* @returns cancel system prompt
|
|
84
|
+
* @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/cancel.md
|
|
85
|
+
*/
|
|
86
|
+
cancel?: (histories: IAgenticaPrompt[]) => string;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Execute system prompt.
|
|
90
|
+
*
|
|
91
|
+
* The {@link Agentica} has a process filling the arguments of some
|
|
92
|
+
* selected candidate functions by the LLM (Large Language Model)
|
|
93
|
+
* function calling feature with the previous prompt histories, and
|
|
94
|
+
* executing the arguments filled function with validation feedback.
|
|
95
|
+
*
|
|
96
|
+
* In that case, this `execute` system prompt would be used. You can
|
|
97
|
+
* customize it by assigning this function with the given
|
|
98
|
+
* {@link IAgenticaPrompt histories} parameter.
|
|
99
|
+
*
|
|
100
|
+
* @param histories Histories of the previous prompts
|
|
101
|
+
* @returns execute system prompt
|
|
102
|
+
* https://github.com/samchon/nestia/blob/master/packages/agent/prompts/execute.md
|
|
103
|
+
*/
|
|
104
|
+
execute?: (histories: IAgenticaPrompt[]) => string;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Describe system prompt.
|
|
108
|
+
*
|
|
109
|
+
* The {@link Agentica} has a process describing the return values of
|
|
110
|
+
* the executed functions by requesting to the A.I. agent with the
|
|
111
|
+
* previous prompt histories.
|
|
112
|
+
*
|
|
113
|
+
* In that case, this `describe` system prompt would be used. You can
|
|
114
|
+
* customize it by assigning this function with the given
|
|
115
|
+
* {@link IAgenticaPrompt histories} parameter.
|
|
116
|
+
*
|
|
117
|
+
* @param histories Histories of the previous prompts
|
|
118
|
+
* @returns describe system prompt
|
|
119
|
+
* @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/describe.md
|
|
120
|
+
*/
|
|
121
|
+
describe?: (histories: IAgenticaPrompt.IExecute[]) => string;
|
|
122
|
+
}
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Token usage information from the A.I. chatbot.
|
|
3
|
-
*
|
|
4
|
-
* `IAgenticaTokenUsage` is a structure representing the token usage
|
|
5
|
-
* information from the {@link Agentica} class. And you can get the
|
|
6
|
-
* token usage information by calling the {@link Agentica.getTokenUsage}
|
|
7
|
-
* method.
|
|
8
|
-
*
|
|
9
|
-
* For reference, `IAgenticaTokenUsage` provides only the token usage
|
|
10
|
-
* information, and does not contain any price or cost information. It is
|
|
11
|
-
* because the price or cost can be changed by below reasons.
|
|
12
|
-
*
|
|
13
|
-
* - Type of {@link IAgenticaProps.provider LLM provider}
|
|
14
|
-
* - {@link IAgenticaProvider.model} in the LLM provider.
|
|
15
|
-
* - Just by a policy change of the LLM provider company.
|
|
16
|
-
*
|
|
17
|
-
* @author Samchon
|
|
18
|
-
*/
|
|
19
|
-
export interface IAgenticaTokenUsage {
|
|
20
|
-
/**
|
|
21
|
-
* Total token usage.
|
|
22
|
-
*/
|
|
23
|
-
total: number;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Token usage in the prompt.
|
|
27
|
-
*
|
|
28
|
-
* In other words, it is called as the input token.
|
|
29
|
-
*/
|
|
30
|
-
prompt: IAgenticaTokenUsage.IPrompt;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Token usage in the completion.
|
|
34
|
-
*
|
|
35
|
-
* In other words, it is called as the output token.
|
|
36
|
-
*/
|
|
37
|
-
completion: IAgenticaTokenUsage.ICompletion;
|
|
38
|
-
}
|
|
39
|
-
export namespace IAgenticaTokenUsage {
|
|
40
|
-
export interface IPrompt {
|
|
41
|
-
total: number;
|
|
42
|
-
audio: number;
|
|
43
|
-
cached: number;
|
|
44
|
-
}
|
|
45
|
-
export interface ICompletion {
|
|
46
|
-
total: number;
|
|
47
|
-
accepted_prediction: number;
|
|
48
|
-
audio: number;
|
|
49
|
-
reasoning: number;
|
|
50
|
-
rejected_prediction: number;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Token usage information from the A.I. chatbot.
|
|
3
|
+
*
|
|
4
|
+
* `IAgenticaTokenUsage` is a structure representing the token usage
|
|
5
|
+
* information from the {@link Agentica} class. And you can get the
|
|
6
|
+
* token usage information by calling the {@link Agentica.getTokenUsage}
|
|
7
|
+
* method.
|
|
8
|
+
*
|
|
9
|
+
* For reference, `IAgenticaTokenUsage` provides only the token usage
|
|
10
|
+
* information, and does not contain any price or cost information. It is
|
|
11
|
+
* because the price or cost can be changed by below reasons.
|
|
12
|
+
*
|
|
13
|
+
* - Type of {@link IAgenticaProps.provider LLM provider}
|
|
14
|
+
* - {@link IAgenticaProvider.model} in the LLM provider.
|
|
15
|
+
* - Just by a policy change of the LLM provider company.
|
|
16
|
+
*
|
|
17
|
+
* @author Samchon
|
|
18
|
+
*/
|
|
19
|
+
export interface IAgenticaTokenUsage {
|
|
20
|
+
/**
|
|
21
|
+
* Total token usage.
|
|
22
|
+
*/
|
|
23
|
+
total: number;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Token usage in the prompt.
|
|
27
|
+
*
|
|
28
|
+
* In other words, it is called as the input token.
|
|
29
|
+
*/
|
|
30
|
+
prompt: IAgenticaTokenUsage.IPrompt;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Token usage in the completion.
|
|
34
|
+
*
|
|
35
|
+
* In other words, it is called as the output token.
|
|
36
|
+
*/
|
|
37
|
+
completion: IAgenticaTokenUsage.ICompletion;
|
|
38
|
+
}
|
|
39
|
+
export namespace IAgenticaTokenUsage {
|
|
40
|
+
export interface IPrompt {
|
|
41
|
+
total: number;
|
|
42
|
+
audio: number;
|
|
43
|
+
cached: number;
|
|
44
|
+
}
|
|
45
|
+
export interface ICompletion {
|
|
46
|
+
total: number;
|
|
47
|
+
accepted_prediction: number;
|
|
48
|
+
audio: number;
|
|
49
|
+
reasoning: number;
|
|
50
|
+
rejected_prediction: number;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { __IChatFunctionReference } from "./__IChatFunctionReference";
|
|
2
|
-
|
|
3
|
-
export interface __IChatCancelFunctionsApplication {
|
|
4
|
-
/**
|
|
5
|
-
* Cancel a function from the candidate list to call.
|
|
6
|
-
*
|
|
7
|
-
* If you A.I. agent has understood that the user wants to cancel
|
|
8
|
-
* some candidate functions to call from the conversation, please cancel
|
|
9
|
-
* them through this function.
|
|
10
|
-
*
|
|
11
|
-
* Also, when you A.I. find a function that has been selected by the candidate
|
|
12
|
-
* pooling, cancel the function by calling this function. For reference, the
|
|
13
|
-
* candidate pooling means that user wants only one function to call, but you A.I.
|
|
14
|
-
* agent selects multiple candidate functions because the A.I. agent can't specify
|
|
15
|
-
* only one thing due to lack of specificity or homogeneity of candidate functions.
|
|
16
|
-
*
|
|
17
|
-
* Additionally, if you A.I. agent wants to cancel same function multiply, you can
|
|
18
|
-
* do it by assigning the same function name multiply in the `functions` property.
|
|
19
|
-
*
|
|
20
|
-
* @param props Properties of the function
|
|
21
|
-
*/
|
|
22
|
-
cancelFunctions(props: __IChatFunctionReference.IProps): Promise<void>;
|
|
23
|
-
}
|
|
1
|
+
import { __IChatFunctionReference } from "./__IChatFunctionReference";
|
|
2
|
+
|
|
3
|
+
export interface __IChatCancelFunctionsApplication {
|
|
4
|
+
/**
|
|
5
|
+
* Cancel a function from the candidate list to call.
|
|
6
|
+
*
|
|
7
|
+
* If you A.I. agent has understood that the user wants to cancel
|
|
8
|
+
* some candidate functions to call from the conversation, please cancel
|
|
9
|
+
* them through this function.
|
|
10
|
+
*
|
|
11
|
+
* Also, when you A.I. find a function that has been selected by the candidate
|
|
12
|
+
* pooling, cancel the function by calling this function. For reference, the
|
|
13
|
+
* candidate pooling means that user wants only one function to call, but you A.I.
|
|
14
|
+
* agent selects multiple candidate functions because the A.I. agent can't specify
|
|
15
|
+
* only one thing due to lack of specificity or homogeneity of candidate functions.
|
|
16
|
+
*
|
|
17
|
+
* Additionally, if you A.I. agent wants to cancel same function multiply, you can
|
|
18
|
+
* do it by assigning the same function name multiply in the `functions` property.
|
|
19
|
+
*
|
|
20
|
+
* @param props Properties of the function
|
|
21
|
+
*/
|
|
22
|
+
cancelFunctions(props: __IChatFunctionReference.IProps): Promise<void>;
|
|
23
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export interface __IChatFunctionReference {
|
|
2
|
-
/**
|
|
3
|
-
* The reason of the function selection.
|
|
4
|
-
*
|
|
5
|
-
* Just write the reason why you've determined to select this function.
|
|
6
|
-
*/
|
|
7
|
-
reason: string;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Name of the target function to call.
|
|
11
|
-
*/
|
|
12
|
-
name: string;
|
|
13
|
-
}
|
|
14
|
-
export namespace __IChatFunctionReference {
|
|
15
|
-
export interface IProps {
|
|
16
|
-
/**
|
|
17
|
-
* List of target functions.
|
|
18
|
-
*/
|
|
19
|
-
functions: __IChatFunctionReference[];
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
export interface __IChatFunctionReference {
|
|
2
|
+
/**
|
|
3
|
+
* The reason of the function selection.
|
|
4
|
+
*
|
|
5
|
+
* Just write the reason why you've determined to select this function.
|
|
6
|
+
*/
|
|
7
|
+
reason: string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Name of the target function to call.
|
|
11
|
+
*/
|
|
12
|
+
name: string;
|
|
13
|
+
}
|
|
14
|
+
export namespace __IChatFunctionReference {
|
|
15
|
+
export interface IProps {
|
|
16
|
+
/**
|
|
17
|
+
* List of target functions.
|
|
18
|
+
*/
|
|
19
|
+
functions: __IChatFunctionReference[];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { IHttpLlmFunction } from "@samchon/openapi";
|
|
2
|
-
|
|
3
|
-
export interface __IChatInitialApplication {
|
|
4
|
-
/**
|
|
5
|
-
* Get list of API functions.
|
|
6
|
-
*
|
|
7
|
-
* If user seems like to request some function calling except this one,
|
|
8
|
-
* call this `getApiFunctions()` to get the list of candidate API functions
|
|
9
|
-
* provided from this application.
|
|
10
|
-
*
|
|
11
|
-
* Also, user just wants to list up every remote API functions that can be
|
|
12
|
-
* called from the backend server, utilize this function too.
|
|
13
|
-
*/
|
|
14
|
-
getApiFunctions({}): Promise<Array<IHttpLlmFunction<"chatgpt">>>;
|
|
15
|
-
}
|
|
1
|
+
import { IHttpLlmFunction } from "@samchon/openapi";
|
|
2
|
+
|
|
3
|
+
export interface __IChatInitialApplication {
|
|
4
|
+
/**
|
|
5
|
+
* Get list of API functions.
|
|
6
|
+
*
|
|
7
|
+
* If user seems like to request some function calling except this one,
|
|
8
|
+
* call this `getApiFunctions()` to get the list of candidate API functions
|
|
9
|
+
* provided from this application.
|
|
10
|
+
*
|
|
11
|
+
* Also, user just wants to list up every remote API functions that can be
|
|
12
|
+
* called from the backend server, utilize this function too.
|
|
13
|
+
*/
|
|
14
|
+
getApiFunctions({}): Promise<Array<IHttpLlmFunction<"chatgpt">>>;
|
|
15
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { __IChatFunctionReference } from "./__IChatFunctionReference";
|
|
2
|
-
|
|
3
|
-
export interface __IChatSelectFunctionsApplication {
|
|
4
|
-
/**
|
|
5
|
-
* Select proper API functions to call.
|
|
6
|
-
*
|
|
7
|
-
* If you A.I. agent has found some proper API functions to call
|
|
8
|
-
* from the conversation with user, please select the API functions
|
|
9
|
-
* just by calling this function.
|
|
10
|
-
*
|
|
11
|
-
* When user wants to call a same function multiply, you A.I. agent must
|
|
12
|
-
* list up it multiply in the `functions` property. Otherwise the user has
|
|
13
|
-
* requested to call many different functions, you A.I. agent have to assign
|
|
14
|
-
* them all into the `functions` property.
|
|
15
|
-
*
|
|
16
|
-
* Also, if you A.I. agent can't specify a specific function to call due to lack
|
|
17
|
-
* of specificity or homogeneity of candidate functions, just assign all of them
|
|
18
|
-
* by in the` functions` property` too. Instead, when you A.I. agent can specify
|
|
19
|
-
* a specific function to call, the others would be eliminated.
|
|
20
|
-
*
|
|
21
|
-
* @param props Properties of the function
|
|
22
|
-
*/
|
|
23
|
-
selectFunctions(props: __IChatFunctionReference.IProps): Promise<void>;
|
|
24
|
-
}
|
|
1
|
+
import { __IChatFunctionReference } from "./__IChatFunctionReference";
|
|
2
|
+
|
|
3
|
+
export interface __IChatSelectFunctionsApplication {
|
|
4
|
+
/**
|
|
5
|
+
* Select proper API functions to call.
|
|
6
|
+
*
|
|
7
|
+
* If you A.I. agent has found some proper API functions to call
|
|
8
|
+
* from the conversation with user, please select the API functions
|
|
9
|
+
* just by calling this function.
|
|
10
|
+
*
|
|
11
|
+
* When user wants to call a same function multiply, you A.I. agent must
|
|
12
|
+
* list up it multiply in the `functions` property. Otherwise the user has
|
|
13
|
+
* requested to call many different functions, you A.I. agent have to assign
|
|
14
|
+
* them all into the `functions` property.
|
|
15
|
+
*
|
|
16
|
+
* Also, if you A.I. agent can't specify a specific function to call due to lack
|
|
17
|
+
* of specificity or homogeneity of candidate functions, just assign all of them
|
|
18
|
+
* by in the` functions` property` too. Instead, when you A.I. agent can specify
|
|
19
|
+
* a specific function to call, the others would be eliminated.
|
|
20
|
+
*
|
|
21
|
+
* @param props Properties of the function
|
|
22
|
+
*/
|
|
23
|
+
selectFunctions(props: __IChatFunctionReference.IProps): Promise<void>;
|
|
24
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type AgenticaSource =
|
|
2
|
-
| "initialize"
|
|
3
|
-
| "select"
|
|
4
|
-
| "cancel"
|
|
5
|
-
| "execute"
|
|
6
|
-
| "describe";
|
|
1
|
+
export type AgenticaSource =
|
|
2
|
+
| "initialize"
|
|
3
|
+
| "select"
|
|
4
|
+
| "cancel"
|
|
5
|
+
| "execute"
|
|
6
|
+
| "describe";
|