@agentica/core 0.8.3-dev.20250227 → 0.8.3
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 -404
- package/package.json +1 -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 +318 -318
- 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 +87 -87
- package/src/chatgpt/ChatGptInitializeFunctionAgent.ts +88 -88
- package/src/chatgpt/ChatGptSelectFunctionAgent.ts +318 -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 +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/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 +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 +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,128 +1,128 @@
|
|
|
1
|
-
import OpenAI from "openai";
|
|
2
|
-
|
|
3
|
-
import { AgenticaSource } from "../typings/AgenticaSource";
|
|
4
|
-
import { IAgenticaConfig } from "./IAgenticaConfig";
|
|
5
|
-
import { IAgenticaEvent } from "./IAgenticaEvent";
|
|
6
|
-
import { IAgenticaOperationCollection } from "./IAgenticaOperationCollection";
|
|
7
|
-
import { IAgenticaOperationSelection } from "./IAgenticaOperationSelection";
|
|
8
|
-
import { IAgenticaPrompt } from "./IAgenticaPrompt";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Context of the Nestia A.I. agent.
|
|
12
|
-
*
|
|
13
|
-
* `IAgenticaContext` is a structure defining the context of the
|
|
14
|
-
* internal agents composing the {@link Agentica}, like function
|
|
15
|
-
* selector, executor, and describer, and so on. For example, if an
|
|
16
|
-
* agent has been configured to utilize the OpenAI, the context will
|
|
17
|
-
* be delivered to the below components.
|
|
18
|
-
*
|
|
19
|
-
* - {@link ChatGptAgent}
|
|
20
|
-
* - {@link ChatGptInitializeFunctionAgent}
|
|
21
|
-
* - {@link ChatGptSelectFunctionAgent}
|
|
22
|
-
* - {@link ChatGptExecuteFunctionAgent}
|
|
23
|
-
* - {@link ChatGptDescribeFunctionAgent}
|
|
24
|
-
* - {@link ChatGptCancelFunctionAgent}
|
|
25
|
-
*
|
|
26
|
-
* Also, as its name is context, it contains every information that
|
|
27
|
-
* is required to interact with the AI provider like OpenAI. It
|
|
28
|
-
* contains every operations for LLM function calling, and
|
|
29
|
-
* configuration used for the agent construction. And it contains
|
|
30
|
-
* the prompt histories, and facade controller functions for
|
|
31
|
-
* interacting with the {@link Agentica} like {@link dispatch}.
|
|
32
|
-
*
|
|
33
|
-
* In such reasons, if you're planning to customize some internal
|
|
34
|
-
* agents, or add new agents with new process routine, you have to
|
|
35
|
-
* understand this context structure. Otherwise you don't have any
|
|
36
|
-
* plan to customize the internal agents, this context information is
|
|
37
|
-
* not important for you.
|
|
38
|
-
*
|
|
39
|
-
* @author Samchon
|
|
40
|
-
*/
|
|
41
|
-
export interface IAgenticaContext {
|
|
42
|
-
//----
|
|
43
|
-
// APPLICATION
|
|
44
|
-
//----
|
|
45
|
-
/**
|
|
46
|
-
* Collection of operations.
|
|
47
|
-
*
|
|
48
|
-
* Collection of operations from every controllers, and their
|
|
49
|
-
* groups composed by the divide and conquer rule for the
|
|
50
|
-
* efficient operation selection if configured.
|
|
51
|
-
*/
|
|
52
|
-
operations: IAgenticaOperationCollection;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Configuration of the agent.
|
|
56
|
-
*
|
|
57
|
-
* Configuration of the agent, that is used when constructing the
|
|
58
|
-
* {@link Agentica} instance.
|
|
59
|
-
*
|
|
60
|
-
* @todo Write detaily after supporting the agent customization feature
|
|
61
|
-
*/
|
|
62
|
-
config: IAgenticaConfig | undefined;
|
|
63
|
-
|
|
64
|
-
//----
|
|
65
|
-
// STATES
|
|
66
|
-
//----
|
|
67
|
-
/**
|
|
68
|
-
* Prompt histories.
|
|
69
|
-
*/
|
|
70
|
-
histories: IAgenticaPrompt[];
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Stacked operations.
|
|
74
|
-
*
|
|
75
|
-
* In other words, list of candidate operations for the LLM function calling.
|
|
76
|
-
*/
|
|
77
|
-
stack: IAgenticaOperationSelection[];
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Text prompt of the user.
|
|
81
|
-
*
|
|
82
|
-
* Text conversation written the by user through the
|
|
83
|
-
* {@link Agentica.conversate} function.
|
|
84
|
-
*/
|
|
85
|
-
prompt: IAgenticaPrompt.IText<"user">;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Whether the agent is ready.
|
|
89
|
-
*
|
|
90
|
-
* Returns a boolean value indicates whether the agent is ready to
|
|
91
|
-
* perform the function calling.
|
|
92
|
-
*
|
|
93
|
-
* If the agent has called the {@link IAgenticaContext.initialize},
|
|
94
|
-
* it returns `true`. Otherwise the {@link initialize} has never been
|
|
95
|
-
* called, returns `false`.
|
|
96
|
-
*/
|
|
97
|
-
ready: () => boolean;
|
|
98
|
-
|
|
99
|
-
//----
|
|
100
|
-
// HANDLERS
|
|
101
|
-
//----
|
|
102
|
-
/**
|
|
103
|
-
* Dispatch event.
|
|
104
|
-
*
|
|
105
|
-
* Dispatch event so that the agent can be handle the event
|
|
106
|
-
* through the {@link Agentica.on} function.
|
|
107
|
-
*
|
|
108
|
-
* @param event Event to deliver
|
|
109
|
-
*/
|
|
110
|
-
dispatch: (event: IAgenticaEvent) => Promise<void>;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Request to the OpenAI server.
|
|
114
|
-
*
|
|
115
|
-
* @param source The source agent of the agent
|
|
116
|
-
* @param body The request body to the OpenAI server
|
|
117
|
-
* @returns Response from the OpenAI server
|
|
118
|
-
*/
|
|
119
|
-
request: (
|
|
120
|
-
source: AgenticaSource,
|
|
121
|
-
body: Omit<OpenAI.ChatCompletionCreateParamsNonStreaming, "model">,
|
|
122
|
-
) => Promise<OpenAI.ChatCompletion>;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Initialize the agent.
|
|
126
|
-
*/
|
|
127
|
-
initialize: () => Promise<void>;
|
|
128
|
-
}
|
|
1
|
+
import OpenAI from "openai";
|
|
2
|
+
|
|
3
|
+
import { AgenticaSource } from "../typings/AgenticaSource";
|
|
4
|
+
import { IAgenticaConfig } from "./IAgenticaConfig";
|
|
5
|
+
import { IAgenticaEvent } from "./IAgenticaEvent";
|
|
6
|
+
import { IAgenticaOperationCollection } from "./IAgenticaOperationCollection";
|
|
7
|
+
import { IAgenticaOperationSelection } from "./IAgenticaOperationSelection";
|
|
8
|
+
import { IAgenticaPrompt } from "./IAgenticaPrompt";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Context of the Nestia A.I. agent.
|
|
12
|
+
*
|
|
13
|
+
* `IAgenticaContext` is a structure defining the context of the
|
|
14
|
+
* internal agents composing the {@link Agentica}, like function
|
|
15
|
+
* selector, executor, and describer, and so on. For example, if an
|
|
16
|
+
* agent has been configured to utilize the OpenAI, the context will
|
|
17
|
+
* be delivered to the below components.
|
|
18
|
+
*
|
|
19
|
+
* - {@link ChatGptAgent}
|
|
20
|
+
* - {@link ChatGptInitializeFunctionAgent}
|
|
21
|
+
* - {@link ChatGptSelectFunctionAgent}
|
|
22
|
+
* - {@link ChatGptExecuteFunctionAgent}
|
|
23
|
+
* - {@link ChatGptDescribeFunctionAgent}
|
|
24
|
+
* - {@link ChatGptCancelFunctionAgent}
|
|
25
|
+
*
|
|
26
|
+
* Also, as its name is context, it contains every information that
|
|
27
|
+
* is required to interact with the AI provider like OpenAI. It
|
|
28
|
+
* contains every operations for LLM function calling, and
|
|
29
|
+
* configuration used for the agent construction. And it contains
|
|
30
|
+
* the prompt histories, and facade controller functions for
|
|
31
|
+
* interacting with the {@link Agentica} like {@link dispatch}.
|
|
32
|
+
*
|
|
33
|
+
* In such reasons, if you're planning to customize some internal
|
|
34
|
+
* agents, or add new agents with new process routine, you have to
|
|
35
|
+
* understand this context structure. Otherwise you don't have any
|
|
36
|
+
* plan to customize the internal agents, this context information is
|
|
37
|
+
* not important for you.
|
|
38
|
+
*
|
|
39
|
+
* @author Samchon
|
|
40
|
+
*/
|
|
41
|
+
export interface IAgenticaContext {
|
|
42
|
+
//----
|
|
43
|
+
// APPLICATION
|
|
44
|
+
//----
|
|
45
|
+
/**
|
|
46
|
+
* Collection of operations.
|
|
47
|
+
*
|
|
48
|
+
* Collection of operations from every controllers, and their
|
|
49
|
+
* groups composed by the divide and conquer rule for the
|
|
50
|
+
* efficient operation selection if configured.
|
|
51
|
+
*/
|
|
52
|
+
operations: IAgenticaOperationCollection;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Configuration of the agent.
|
|
56
|
+
*
|
|
57
|
+
* Configuration of the agent, that is used when constructing the
|
|
58
|
+
* {@link Agentica} instance.
|
|
59
|
+
*
|
|
60
|
+
* @todo Write detaily after supporting the agent customization feature
|
|
61
|
+
*/
|
|
62
|
+
config: IAgenticaConfig | undefined;
|
|
63
|
+
|
|
64
|
+
//----
|
|
65
|
+
// STATES
|
|
66
|
+
//----
|
|
67
|
+
/**
|
|
68
|
+
* Prompt histories.
|
|
69
|
+
*/
|
|
70
|
+
histories: IAgenticaPrompt[];
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Stacked operations.
|
|
74
|
+
*
|
|
75
|
+
* In other words, list of candidate operations for the LLM function calling.
|
|
76
|
+
*/
|
|
77
|
+
stack: IAgenticaOperationSelection[];
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Text prompt of the user.
|
|
81
|
+
*
|
|
82
|
+
* Text conversation written the by user through the
|
|
83
|
+
* {@link Agentica.conversate} function.
|
|
84
|
+
*/
|
|
85
|
+
prompt: IAgenticaPrompt.IText<"user">;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Whether the agent is ready.
|
|
89
|
+
*
|
|
90
|
+
* Returns a boolean value indicates whether the agent is ready to
|
|
91
|
+
* perform the function calling.
|
|
92
|
+
*
|
|
93
|
+
* If the agent has called the {@link IAgenticaContext.initialize},
|
|
94
|
+
* it returns `true`. Otherwise the {@link initialize} has never been
|
|
95
|
+
* called, returns `false`.
|
|
96
|
+
*/
|
|
97
|
+
ready: () => boolean;
|
|
98
|
+
|
|
99
|
+
//----
|
|
100
|
+
// HANDLERS
|
|
101
|
+
//----
|
|
102
|
+
/**
|
|
103
|
+
* Dispatch event.
|
|
104
|
+
*
|
|
105
|
+
* Dispatch event so that the agent can be handle the event
|
|
106
|
+
* through the {@link Agentica.on} function.
|
|
107
|
+
*
|
|
108
|
+
* @param event Event to deliver
|
|
109
|
+
*/
|
|
110
|
+
dispatch: (event: IAgenticaEvent) => Promise<void>;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Request to the OpenAI server.
|
|
114
|
+
*
|
|
115
|
+
* @param source The source agent of the agent
|
|
116
|
+
* @param body The request body to the OpenAI server
|
|
117
|
+
* @returns Response from the OpenAI server
|
|
118
|
+
*/
|
|
119
|
+
request: (
|
|
120
|
+
source: AgenticaSource,
|
|
121
|
+
body: Omit<OpenAI.ChatCompletionCreateParamsNonStreaming, "model">,
|
|
122
|
+
) => Promise<OpenAI.ChatCompletion>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Initialize the agent.
|
|
126
|
+
*/
|
|
127
|
+
initialize: () => Promise<void>;
|
|
128
|
+
}
|
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IHttpConnection,
|
|
3
|
-
IHttpLlmApplication,
|
|
4
|
-
IHttpLlmFunction,
|
|
5
|
-
IHttpResponse,
|
|
6
|
-
} from "@samchon/openapi";
|
|
7
|
-
import { ILlmApplicationOfValidate, ILlmFunctionOfValidate } from "typia";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Controller of the Nestia Agent.
|
|
11
|
-
*
|
|
12
|
-
* `IAgenticaController` is a type represents a controller of the
|
|
13
|
-
* {@link Agentica}, which serves a set of functions to be called
|
|
14
|
-
* by A.I. chatbot from LLM function calling.
|
|
15
|
-
*
|
|
16
|
-
* Also, `IAgenticaController` is an union type which can specify
|
|
17
|
-
* a subtype by checking the {@link protocol} property.
|
|
18
|
-
*
|
|
19
|
-
* - HTTP server: {@link IAgenticaController..IHttp}
|
|
20
|
-
* - TypeScript class: {@link IAgenticaController.IClass}
|
|
21
|
-
*
|
|
22
|
-
* @author Samchon
|
|
23
|
-
*/
|
|
24
|
-
export type IAgenticaController =
|
|
25
|
-
| IAgenticaController.IHttp
|
|
26
|
-
| IAgenticaController.IClass;
|
|
27
|
-
export namespace IAgenticaController {
|
|
28
|
-
/**
|
|
29
|
-
* HTTP controller.
|
|
30
|
-
*
|
|
31
|
-
* You can make it by {@link createHttpLlmApplication} function with
|
|
32
|
-
* the Swagger or OpenAPI document.
|
|
33
|
-
*/
|
|
34
|
-
export interface IHttp extends IBase<"http", IHttpLlmApplication<"chatgpt">> {
|
|
35
|
-
/**
|
|
36
|
-
* Connection to the server.
|
|
37
|
-
*
|
|
38
|
-
* Connection to the API server including the URL and headers.
|
|
39
|
-
*/
|
|
40
|
-
connection: IHttpConnection;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Executor of the API function.
|
|
44
|
-
*
|
|
45
|
-
* @param props Properties of the API function call
|
|
46
|
-
* @returns HTTP response of the API function call
|
|
47
|
-
*/
|
|
48
|
-
execute?: (props: {
|
|
49
|
-
/**
|
|
50
|
-
* Connection to the server.
|
|
51
|
-
*/
|
|
52
|
-
connection: IHttpConnection;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Application schema.
|
|
56
|
-
*/
|
|
57
|
-
application: IHttpLlmApplication<"chatgpt">;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Function schema.
|
|
61
|
-
*/
|
|
62
|
-
function: IHttpLlmFunction<"chatgpt">;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Arguments of the function calling.
|
|
66
|
-
*
|
|
67
|
-
* It is an object of key-value pairs of the API function's parameters.
|
|
68
|
-
* The property keys are composed by below rules:
|
|
69
|
-
*
|
|
70
|
-
* - parameter names
|
|
71
|
-
* - query parameter as an object type if exists
|
|
72
|
-
* - body parameter if exists
|
|
73
|
-
*/
|
|
74
|
-
arguments: object;
|
|
75
|
-
}) => Promise<IHttpResponse>;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* TypeScript class controller.
|
|
80
|
-
*
|
|
81
|
-
* You can make it by `typia.llm.application<App, Model>()` function.
|
|
82
|
-
*
|
|
83
|
-
* - https://typia.io/docs/llm/application
|
|
84
|
-
*/
|
|
85
|
-
export interface IClass
|
|
86
|
-
extends IBase<"class", ILlmApplicationOfValidate<"chatgpt">> {
|
|
87
|
-
/**
|
|
88
|
-
* Executor of the class function.
|
|
89
|
-
*
|
|
90
|
-
* Executor of the class function, by target class instance
|
|
91
|
-
* or callback function with given schema and arguments
|
|
92
|
-
* information.
|
|
93
|
-
*/
|
|
94
|
-
execute:
|
|
95
|
-
| object
|
|
96
|
-
| ((props: {
|
|
97
|
-
/**
|
|
98
|
-
* Target application schema.
|
|
99
|
-
*/
|
|
100
|
-
application: ILlmApplicationOfValidate<"chatgpt">;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Target function schema.
|
|
104
|
-
*/
|
|
105
|
-
function: ILlmFunctionOfValidate<"chatgpt">;
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Arguments of the function calling.
|
|
109
|
-
*/
|
|
110
|
-
arguments: object;
|
|
111
|
-
}) => Promise<unknown>);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
interface IBase<Protocol, Application> {
|
|
115
|
-
/**
|
|
116
|
-
* Protocol discrminator.
|
|
117
|
-
*/
|
|
118
|
-
protocol: Protocol;
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Name of the controller.
|
|
122
|
-
*/
|
|
123
|
-
name: string;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Application schema of function calling.
|
|
127
|
-
*/
|
|
128
|
-
application: Application;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
IHttpConnection,
|
|
3
|
+
IHttpLlmApplication,
|
|
4
|
+
IHttpLlmFunction,
|
|
5
|
+
IHttpResponse,
|
|
6
|
+
} from "@samchon/openapi";
|
|
7
|
+
import { ILlmApplicationOfValidate, ILlmFunctionOfValidate } from "typia";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Controller of the Nestia Agent.
|
|
11
|
+
*
|
|
12
|
+
* `IAgenticaController` is a type represents a controller of the
|
|
13
|
+
* {@link Agentica}, which serves a set of functions to be called
|
|
14
|
+
* by A.I. chatbot from LLM function calling.
|
|
15
|
+
*
|
|
16
|
+
* Also, `IAgenticaController` is an union type which can specify
|
|
17
|
+
* a subtype by checking the {@link protocol} property.
|
|
18
|
+
*
|
|
19
|
+
* - HTTP server: {@link IAgenticaController..IHttp}
|
|
20
|
+
* - TypeScript class: {@link IAgenticaController.IClass}
|
|
21
|
+
*
|
|
22
|
+
* @author Samchon
|
|
23
|
+
*/
|
|
24
|
+
export type IAgenticaController =
|
|
25
|
+
| IAgenticaController.IHttp
|
|
26
|
+
| IAgenticaController.IClass;
|
|
27
|
+
export namespace IAgenticaController {
|
|
28
|
+
/**
|
|
29
|
+
* HTTP controller.
|
|
30
|
+
*
|
|
31
|
+
* You can make it by {@link createHttpLlmApplication} function with
|
|
32
|
+
* the Swagger or OpenAPI document.
|
|
33
|
+
*/
|
|
34
|
+
export interface IHttp extends IBase<"http", IHttpLlmApplication<"chatgpt">> {
|
|
35
|
+
/**
|
|
36
|
+
* Connection to the server.
|
|
37
|
+
*
|
|
38
|
+
* Connection to the API server including the URL and headers.
|
|
39
|
+
*/
|
|
40
|
+
connection: IHttpConnection;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Executor of the API function.
|
|
44
|
+
*
|
|
45
|
+
* @param props Properties of the API function call
|
|
46
|
+
* @returns HTTP response of the API function call
|
|
47
|
+
*/
|
|
48
|
+
execute?: (props: {
|
|
49
|
+
/**
|
|
50
|
+
* Connection to the server.
|
|
51
|
+
*/
|
|
52
|
+
connection: IHttpConnection;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Application schema.
|
|
56
|
+
*/
|
|
57
|
+
application: IHttpLlmApplication<"chatgpt">;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Function schema.
|
|
61
|
+
*/
|
|
62
|
+
function: IHttpLlmFunction<"chatgpt">;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Arguments of the function calling.
|
|
66
|
+
*
|
|
67
|
+
* It is an object of key-value pairs of the API function's parameters.
|
|
68
|
+
* The property keys are composed by below rules:
|
|
69
|
+
*
|
|
70
|
+
* - parameter names
|
|
71
|
+
* - query parameter as an object type if exists
|
|
72
|
+
* - body parameter if exists
|
|
73
|
+
*/
|
|
74
|
+
arguments: object;
|
|
75
|
+
}) => Promise<IHttpResponse>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* TypeScript class controller.
|
|
80
|
+
*
|
|
81
|
+
* You can make it by `typia.llm.application<App, Model>()` function.
|
|
82
|
+
*
|
|
83
|
+
* - https://typia.io/docs/llm/application
|
|
84
|
+
*/
|
|
85
|
+
export interface IClass
|
|
86
|
+
extends IBase<"class", ILlmApplicationOfValidate<"chatgpt">> {
|
|
87
|
+
/**
|
|
88
|
+
* Executor of the class function.
|
|
89
|
+
*
|
|
90
|
+
* Executor of the class function, by target class instance
|
|
91
|
+
* or callback function with given schema and arguments
|
|
92
|
+
* information.
|
|
93
|
+
*/
|
|
94
|
+
execute:
|
|
95
|
+
| object
|
|
96
|
+
| ((props: {
|
|
97
|
+
/**
|
|
98
|
+
* Target application schema.
|
|
99
|
+
*/
|
|
100
|
+
application: ILlmApplicationOfValidate<"chatgpt">;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Target function schema.
|
|
104
|
+
*/
|
|
105
|
+
function: ILlmFunctionOfValidate<"chatgpt">;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Arguments of the function calling.
|
|
109
|
+
*/
|
|
110
|
+
arguments: object;
|
|
111
|
+
}) => Promise<unknown>);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
interface IBase<Protocol, Application> {
|
|
115
|
+
/**
|
|
116
|
+
* Protocol discrminator.
|
|
117
|
+
*/
|
|
118
|
+
protocol: Protocol;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Name of the controller.
|
|
122
|
+
*/
|
|
123
|
+
name: string;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Application schema of function calling.
|
|
127
|
+
*/
|
|
128
|
+
application: Application;
|
|
129
|
+
}
|
|
130
|
+
}
|