@agentica/core 0.8.3-dev.20250227 → 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/README.md +25 -10
- 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/src/Agentica.ts +24 -19
- package/src/chatgpt/ChatGptAgent.ts +9 -5
- package/src/chatgpt/ChatGptCallFunctionAgent.ts +25 -22
- package/src/chatgpt/ChatGptCancelFunctionAgent.ts +26 -22
- package/src/chatgpt/ChatGptDescribeFunctionAgent.ts +7 -6
- package/src/chatgpt/ChatGptHistoryDecoder.ts +3 -2
- package/src/chatgpt/ChatGptInitializeFunctionAgent.ts +5 -5
- package/src/chatgpt/ChatGptSelectFunctionAgent.ts +33 -32
- package/src/internal/AgenticaDefaultPrompt.ts +5 -1
- package/src/internal/AgenticaOperationComposer.ts +20 -15
- package/src/internal/AgenticaPromptFactory.ts +10 -8
- package/src/internal/AgenticaPromptTransformer.ts +19 -16
- package/src/structures/IAgenticaConfig.ts +6 -4
- package/src/structures/IAgenticaContext.ts +7 -6
- package/src/structures/IAgenticaController.ts +12 -10
- package/src/structures/IAgenticaEvent.ts +28 -23
- package/src/structures/IAgenticaExecutor.ts +12 -8
- package/src/structures/IAgenticaOperation.ts +10 -10
- package/src/structures/IAgenticaOperationCollection.ts +7 -5
- package/src/structures/IAgenticaOperationSelection.ts +10 -10
- package/src/structures/IAgenticaPrompt.ts +24 -19
- package/src/structures/IAgenticaProps.ts +10 -4
- package/src/structures/IAgenticaProvider.ts +22 -28
- package/src/structures/IAgenticaSystemPrompt.ts +9 -7
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
1
2
|
import { Primitive } from "typia";
|
|
2
3
|
|
|
3
4
|
import { IAgenticaOperation } from "../structures/IAgenticaOperation";
|
|
@@ -5,10 +6,10 @@ import { IAgenticaPrompt } from "../structures/IAgenticaPrompt";
|
|
|
5
6
|
import { AgenticaPromptFactory } from "./AgenticaPromptFactory";
|
|
6
7
|
|
|
7
8
|
export namespace AgenticaPromptTransformer {
|
|
8
|
-
export const transform = (props: {
|
|
9
|
-
operations: Map<string, Map<string, IAgenticaOperation
|
|
10
|
-
input: Primitive<IAgenticaPrompt
|
|
11
|
-
}): IAgenticaPrompt => {
|
|
9
|
+
export const transform = <Model extends ILlmSchema.Model>(props: {
|
|
10
|
+
operations: Map<string, Map<string, IAgenticaOperation<Model>>>;
|
|
11
|
+
input: Primitive<IAgenticaPrompt<Model>>;
|
|
12
|
+
}): IAgenticaPrompt<Model> => {
|
|
12
13
|
// TEXT
|
|
13
14
|
if (props.input.type === "text") return props.input;
|
|
14
15
|
// SELECT & CANCEL
|
|
@@ -24,13 +25,15 @@ export namespace AgenticaPromptTransformer {
|
|
|
24
25
|
reason: func.reason,
|
|
25
26
|
}),
|
|
26
27
|
),
|
|
27
|
-
} satisfies
|
|
28
|
+
} satisfies
|
|
29
|
+
| IAgenticaPrompt.ISelect<Model>
|
|
30
|
+
| IAgenticaPrompt.ICancel<Model>;
|
|
28
31
|
// EXECUTE
|
|
29
32
|
else if (props.input.type === "execute")
|
|
30
33
|
return transformExecute({
|
|
31
34
|
operations: props.operations,
|
|
32
35
|
input: props.input,
|
|
33
|
-
}) satisfies IAgenticaPrompt.IExecute
|
|
36
|
+
}) satisfies IAgenticaPrompt.IExecute<Model>;
|
|
34
37
|
// DESCRIBE
|
|
35
38
|
return {
|
|
36
39
|
type: "describe",
|
|
@@ -41,13 +44,13 @@ export namespace AgenticaPromptTransformer {
|
|
|
41
44
|
input: next,
|
|
42
45
|
}),
|
|
43
46
|
),
|
|
44
|
-
} satisfies IAgenticaPrompt.IDescribe
|
|
47
|
+
} satisfies IAgenticaPrompt.IDescribe<Model>;
|
|
45
48
|
};
|
|
46
49
|
|
|
47
|
-
const transformExecute = (props: {
|
|
48
|
-
operations: Map<string, Map<string, IAgenticaOperation
|
|
49
|
-
input: Primitive<IAgenticaPrompt.IExecute
|
|
50
|
-
}): IAgenticaPrompt.IExecute => {
|
|
50
|
+
const transformExecute = <Model extends ILlmSchema.Model>(props: {
|
|
51
|
+
operations: Map<string, Map<string, IAgenticaOperation<Model>>>;
|
|
52
|
+
input: Primitive<IAgenticaPrompt.IExecute<Model>>;
|
|
53
|
+
}): IAgenticaPrompt.IExecute<Model> => {
|
|
51
54
|
const operation = findOperation({
|
|
52
55
|
operations: props.operations,
|
|
53
56
|
input: props.input,
|
|
@@ -64,20 +67,20 @@ export namespace AgenticaPromptTransformer {
|
|
|
64
67
|
});
|
|
65
68
|
};
|
|
66
69
|
|
|
67
|
-
const findOperation = (props: {
|
|
68
|
-
operations: Map<string, Map<string, IAgenticaOperation
|
|
70
|
+
const findOperation = <Model extends ILlmSchema.Model>(props: {
|
|
71
|
+
operations: Map<string, Map<string, IAgenticaOperation<Model>>>;
|
|
69
72
|
input: {
|
|
70
73
|
controller: string;
|
|
71
74
|
function: string;
|
|
72
75
|
};
|
|
73
|
-
}): IAgenticaOperation.IHttp => {
|
|
74
|
-
const found: IAgenticaOperation | undefined = props.operations
|
|
76
|
+
}): IAgenticaOperation.IHttp<Model> => {
|
|
77
|
+
const found: IAgenticaOperation<Model> | undefined = props.operations
|
|
75
78
|
.get(props.input.controller)
|
|
76
79
|
?.get(props.input.function);
|
|
77
80
|
if (found === undefined)
|
|
78
81
|
throw new Error(
|
|
79
82
|
`No operation found: (controller: ${props.input.controller}, function: ${props.input.function})`,
|
|
80
83
|
);
|
|
81
|
-
return found as IAgenticaOperation.IHttp
|
|
84
|
+
return found as IAgenticaOperation.IHttp<Model>;
|
|
82
85
|
};
|
|
83
86
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
|
|
1
3
|
import { IAgenticaContext } from "./IAgenticaContext";
|
|
2
4
|
import { IAgenticaExecutor } from "./IAgenticaExecutor";
|
|
3
5
|
import { IAgenticaPrompt } from "./IAgenticaPrompt";
|
|
@@ -19,7 +21,7 @@ import { IAgenticaSystemPrompt } from "./IAgenticaSystemPrompt";
|
|
|
19
21
|
*
|
|
20
22
|
* @author Samchon
|
|
21
23
|
*/
|
|
22
|
-
export interface IAgenticaConfig {
|
|
24
|
+
export interface IAgenticaConfig<Model extends ILlmSchema.Model> {
|
|
23
25
|
/**
|
|
24
26
|
* Locale of the A.I. chatbot.
|
|
25
27
|
*
|
|
@@ -98,7 +100,7 @@ export interface IAgenticaConfig {
|
|
|
98
100
|
* System prompt messages if you want to customize the system prompt
|
|
99
101
|
* messages for each situation.
|
|
100
102
|
*/
|
|
101
|
-
systemPrompt?: IAgenticaSystemPrompt
|
|
103
|
+
systemPrompt?: IAgenticaSystemPrompt<Model>;
|
|
102
104
|
|
|
103
105
|
/**
|
|
104
106
|
* Agent executor.
|
|
@@ -116,6 +118,6 @@ export interface IAgenticaConfig {
|
|
|
116
118
|
* @default ChatGptAgent.execute
|
|
117
119
|
*/
|
|
118
120
|
executor?:
|
|
119
|
-
| Partial<IAgenticaExecutor
|
|
120
|
-
| ((ctx: IAgenticaContext) => Promise<IAgenticaPrompt[]>);
|
|
121
|
+
| Partial<IAgenticaExecutor<Model>>
|
|
122
|
+
| ((ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>);
|
|
121
123
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
1
2
|
import OpenAI from "openai";
|
|
2
3
|
|
|
3
4
|
import { AgenticaSource } from "../typings/AgenticaSource";
|
|
@@ -38,7 +39,7 @@ import { IAgenticaPrompt } from "./IAgenticaPrompt";
|
|
|
38
39
|
*
|
|
39
40
|
* @author Samchon
|
|
40
41
|
*/
|
|
41
|
-
export interface IAgenticaContext {
|
|
42
|
+
export interface IAgenticaContext<Model extends ILlmSchema.Model> {
|
|
42
43
|
//----
|
|
43
44
|
// APPLICATION
|
|
44
45
|
//----
|
|
@@ -49,7 +50,7 @@ export interface IAgenticaContext {
|
|
|
49
50
|
* groups composed by the divide and conquer rule for the
|
|
50
51
|
* efficient operation selection if configured.
|
|
51
52
|
*/
|
|
52
|
-
operations: IAgenticaOperationCollection
|
|
53
|
+
operations: IAgenticaOperationCollection<Model>;
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
56
|
* Configuration of the agent.
|
|
@@ -59,7 +60,7 @@ export interface IAgenticaContext {
|
|
|
59
60
|
*
|
|
60
61
|
* @todo Write detaily after supporting the agent customization feature
|
|
61
62
|
*/
|
|
62
|
-
config: IAgenticaConfig | undefined;
|
|
63
|
+
config: IAgenticaConfig<Model> | undefined;
|
|
63
64
|
|
|
64
65
|
//----
|
|
65
66
|
// STATES
|
|
@@ -67,14 +68,14 @@ export interface IAgenticaContext {
|
|
|
67
68
|
/**
|
|
68
69
|
* Prompt histories.
|
|
69
70
|
*/
|
|
70
|
-
histories: IAgenticaPrompt[];
|
|
71
|
+
histories: IAgenticaPrompt<Model>[];
|
|
71
72
|
|
|
72
73
|
/**
|
|
73
74
|
* Stacked operations.
|
|
74
75
|
*
|
|
75
76
|
* In other words, list of candidate operations for the LLM function calling.
|
|
76
77
|
*/
|
|
77
|
-
stack: IAgenticaOperationSelection[];
|
|
78
|
+
stack: IAgenticaOperationSelection<Model>[];
|
|
78
79
|
|
|
79
80
|
/**
|
|
80
81
|
* Text prompt of the user.
|
|
@@ -107,7 +108,7 @@ export interface IAgenticaContext {
|
|
|
107
108
|
*
|
|
108
109
|
* @param event Event to deliver
|
|
109
110
|
*/
|
|
110
|
-
dispatch: (event: IAgenticaEvent) => Promise<void>;
|
|
111
|
+
dispatch: (event: IAgenticaEvent<Model>) => Promise<void>;
|
|
111
112
|
|
|
112
113
|
/**
|
|
113
114
|
* Request to the OpenAI server.
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
IHttpLlmApplication,
|
|
4
4
|
IHttpLlmFunction,
|
|
5
5
|
IHttpResponse,
|
|
6
|
+
ILlmSchema,
|
|
6
7
|
} from "@samchon/openapi";
|
|
7
8
|
import { ILlmApplicationOfValidate, ILlmFunctionOfValidate } from "typia";
|
|
8
9
|
|
|
@@ -21,9 +22,9 @@ import { ILlmApplicationOfValidate, ILlmFunctionOfValidate } from "typia";
|
|
|
21
22
|
*
|
|
22
23
|
* @author Samchon
|
|
23
24
|
*/
|
|
24
|
-
export type IAgenticaController =
|
|
25
|
-
| IAgenticaController.IHttp
|
|
26
|
-
| IAgenticaController.IClass
|
|
25
|
+
export type IAgenticaController<Model extends ILlmSchema.Model> =
|
|
26
|
+
| IAgenticaController.IHttp<Model>
|
|
27
|
+
| IAgenticaController.IClass<Model>;
|
|
27
28
|
export namespace IAgenticaController {
|
|
28
29
|
/**
|
|
29
30
|
* HTTP controller.
|
|
@@ -31,7 +32,8 @@ export namespace IAgenticaController {
|
|
|
31
32
|
* You can make it by {@link createHttpLlmApplication} function with
|
|
32
33
|
* the Swagger or OpenAPI document.
|
|
33
34
|
*/
|
|
34
|
-
export interface IHttp extends
|
|
35
|
+
export interface IHttp<Model extends ILlmSchema.Model>
|
|
36
|
+
extends IBase<"http", IHttpLlmApplication<Model>> {
|
|
35
37
|
/**
|
|
36
38
|
* Connection to the server.
|
|
37
39
|
*
|
|
@@ -54,12 +56,12 @@ export namespace IAgenticaController {
|
|
|
54
56
|
/**
|
|
55
57
|
* Application schema.
|
|
56
58
|
*/
|
|
57
|
-
application: IHttpLlmApplication<
|
|
59
|
+
application: IHttpLlmApplication<Model>;
|
|
58
60
|
|
|
59
61
|
/**
|
|
60
62
|
* Function schema.
|
|
61
63
|
*/
|
|
62
|
-
function: IHttpLlmFunction<
|
|
64
|
+
function: IHttpLlmFunction<Model>;
|
|
63
65
|
|
|
64
66
|
/**
|
|
65
67
|
* Arguments of the function calling.
|
|
@@ -82,8 +84,8 @@ export namespace IAgenticaController {
|
|
|
82
84
|
*
|
|
83
85
|
* - https://typia.io/docs/llm/application
|
|
84
86
|
*/
|
|
85
|
-
export interface IClass
|
|
86
|
-
extends IBase<"class", ILlmApplicationOfValidate<
|
|
87
|
+
export interface IClass<Model extends ILlmSchema.Model>
|
|
88
|
+
extends IBase<"class", ILlmApplicationOfValidate<Model>> {
|
|
87
89
|
/**
|
|
88
90
|
* Executor of the class function.
|
|
89
91
|
*
|
|
@@ -97,12 +99,12 @@ export namespace IAgenticaController {
|
|
|
97
99
|
/**
|
|
98
100
|
* Target application schema.
|
|
99
101
|
*/
|
|
100
|
-
application: ILlmApplicationOfValidate<
|
|
102
|
+
application: ILlmApplicationOfValidate<Model>;
|
|
101
103
|
|
|
102
104
|
/**
|
|
103
105
|
* Target function schema.
|
|
104
106
|
*/
|
|
105
|
-
function: ILlmFunctionOfValidate<
|
|
107
|
+
function: ILlmFunctionOfValidate<Model>;
|
|
106
108
|
|
|
107
109
|
/**
|
|
108
110
|
* Arguments of the function calling.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
1
2
|
import OpenAI from "openai";
|
|
2
3
|
|
|
3
4
|
import { AgenticaSource } from "../typings/AgenticaSource";
|
|
@@ -13,25 +14,25 @@ import { IAgenticaPrompt } from "./IAgenticaPrompt";
|
|
|
13
14
|
*
|
|
14
15
|
* @author Samchon
|
|
15
16
|
*/
|
|
16
|
-
export type IAgenticaEvent =
|
|
17
|
+
export type IAgenticaEvent<Model extends ILlmSchema.Model> =
|
|
17
18
|
| IAgenticaEvent.IInitialize
|
|
18
|
-
| IAgenticaEvent.ISelect
|
|
19
|
-
| IAgenticaEvent.ICancel
|
|
20
|
-
| IAgenticaEvent.ICall
|
|
21
|
-
| IAgenticaEvent.IExecute
|
|
22
|
-
| IAgenticaEvent.IDescribe
|
|
19
|
+
| IAgenticaEvent.ISelect<Model>
|
|
20
|
+
| IAgenticaEvent.ICancel<Model>
|
|
21
|
+
| IAgenticaEvent.ICall<Model>
|
|
22
|
+
| IAgenticaEvent.IExecute<Model>
|
|
23
|
+
| IAgenticaEvent.IDescribe<Model>
|
|
23
24
|
| IAgenticaEvent.IText
|
|
24
25
|
| IAgenticaEvent.IRequest
|
|
25
26
|
| IAgenticaEvent.IResponse;
|
|
26
27
|
export namespace IAgenticaEvent {
|
|
27
|
-
export type Type = IAgenticaEvent["type"];
|
|
28
|
-
export type Mapper = {
|
|
28
|
+
export type Type = IAgenticaEvent<any>["type"];
|
|
29
|
+
export type Mapper<Model extends ILlmSchema.Model> = {
|
|
29
30
|
initialize: IInitialize;
|
|
30
|
-
select: ISelect
|
|
31
|
-
cancel: ICancel
|
|
32
|
-
call: ICall
|
|
33
|
-
execute: IExecute
|
|
34
|
-
describe: IDescribe
|
|
31
|
+
select: ISelect<Model>;
|
|
32
|
+
cancel: ICancel<Model>;
|
|
33
|
+
call: ICall<Model>;
|
|
34
|
+
execute: IExecute<Model>;
|
|
35
|
+
describe: IDescribe<Model>;
|
|
35
36
|
text: IText;
|
|
36
37
|
request: IRequest;
|
|
37
38
|
response: IResponse;
|
|
@@ -45,13 +46,14 @@ export namespace IAgenticaEvent {
|
|
|
45
46
|
/**
|
|
46
47
|
* Event of selecting a function to call.
|
|
47
48
|
*/
|
|
48
|
-
export interface ISelect extends
|
|
49
|
+
export interface ISelect<Model extends ILlmSchema.Model>
|
|
50
|
+
extends IBase<"select"> {
|
|
49
51
|
/**
|
|
50
52
|
* Selected operation.
|
|
51
53
|
*
|
|
52
54
|
* Operation that has been selected to prepare LLM function calling.
|
|
53
55
|
*/
|
|
54
|
-
operation: IAgenticaOperation
|
|
56
|
+
operation: IAgenticaOperation<Model>;
|
|
55
57
|
|
|
56
58
|
/**
|
|
57
59
|
* Reason of selecting the function.
|
|
@@ -65,14 +67,15 @@ export namespace IAgenticaEvent {
|
|
|
65
67
|
/**
|
|
66
68
|
* Event of canceling a function calling.
|
|
67
69
|
*/
|
|
68
|
-
export interface ICancel extends
|
|
70
|
+
export interface ICancel<Model extends ILlmSchema.Model>
|
|
71
|
+
extends IBase<"cancel"> {
|
|
69
72
|
/**
|
|
70
73
|
* Selected operation to cancel.
|
|
71
74
|
*
|
|
72
75
|
* Operation that has been selected to prepare LLM function calling,
|
|
73
76
|
* but canceled due to no more required.
|
|
74
77
|
*/
|
|
75
|
-
operation: IAgenticaOperation
|
|
78
|
+
operation: IAgenticaOperation<Model>;
|
|
76
79
|
|
|
77
80
|
/**
|
|
78
81
|
* Reason of selecting the function.
|
|
@@ -90,7 +93,7 @@ export namespace IAgenticaEvent {
|
|
|
90
93
|
/**
|
|
91
94
|
* Event of calling a function.
|
|
92
95
|
*/
|
|
93
|
-
export interface ICall extends IBase<"call"> {
|
|
96
|
+
export interface ICall<Model extends ILlmSchema.Model> extends IBase<"call"> {
|
|
94
97
|
/**
|
|
95
98
|
* ID of the tool calling.
|
|
96
99
|
*/
|
|
@@ -99,7 +102,7 @@ export namespace IAgenticaEvent {
|
|
|
99
102
|
/**
|
|
100
103
|
* Target operation to call.
|
|
101
104
|
*/
|
|
102
|
-
operation: IAgenticaOperation
|
|
105
|
+
operation: IAgenticaOperation<Model>;
|
|
103
106
|
|
|
104
107
|
/**
|
|
105
108
|
* Arguments of the function calling.
|
|
@@ -114,7 +117,8 @@ export namespace IAgenticaEvent {
|
|
|
114
117
|
/**
|
|
115
118
|
* Event of function calling execution.
|
|
116
119
|
*/
|
|
117
|
-
export interface IExecute extends
|
|
120
|
+
export interface IExecute<Model extends ILlmSchema.Model>
|
|
121
|
+
extends IBase<"execute"> {
|
|
118
122
|
/**
|
|
119
123
|
* ID of the tool calling.
|
|
120
124
|
*/
|
|
@@ -123,7 +127,7 @@ export namespace IAgenticaEvent {
|
|
|
123
127
|
/**
|
|
124
128
|
* Target operation had called.
|
|
125
129
|
*/
|
|
126
|
-
operation: IAgenticaOperation
|
|
130
|
+
operation: IAgenticaOperation<Model>;
|
|
127
131
|
|
|
128
132
|
/**
|
|
129
133
|
* Arguments of the function calling.
|
|
@@ -141,13 +145,14 @@ export namespace IAgenticaEvent {
|
|
|
141
145
|
*
|
|
142
146
|
* Event describing return values of LLM function callings.
|
|
143
147
|
*/
|
|
144
|
-
export interface IDescribe extends
|
|
148
|
+
export interface IDescribe<Model extends ILlmSchema.Model>
|
|
149
|
+
extends IBase<"describe"> {
|
|
145
150
|
/**
|
|
146
151
|
* Executions of the LLM function calling.
|
|
147
152
|
*
|
|
148
153
|
* This prompt describes the return value of them.
|
|
149
154
|
*/
|
|
150
|
-
executions: IAgenticaPrompt.IExecute[];
|
|
155
|
+
executions: IAgenticaPrompt.IExecute<Model>[];
|
|
151
156
|
|
|
152
157
|
/**
|
|
153
158
|
* Description text.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
|
|
1
3
|
import { IAgenticaContext } from "./IAgenticaContext";
|
|
2
4
|
import { IAgenticaPrompt } from "./IAgenticaPrompt";
|
|
3
5
|
|
|
@@ -24,7 +26,7 @@ import { IAgenticaPrompt } from "./IAgenticaPrompt";
|
|
|
24
26
|
* @reference https://github.com/wrtnlabs/agentica/blob/main/packages/agent/src/chatgpt/ChatGptAgent.ts
|
|
25
27
|
* @author Samchon
|
|
26
28
|
*/
|
|
27
|
-
export interface IAgenticaExecutor {
|
|
29
|
+
export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
|
|
28
30
|
/**
|
|
29
31
|
* Initializer agent listing up functions.
|
|
30
32
|
*
|
|
@@ -53,7 +55,9 @@ export interface IAgenticaExecutor {
|
|
|
53
55
|
* @param ctx Context of the agent
|
|
54
56
|
* @returns List of prompts generated by the initializer
|
|
55
57
|
*/
|
|
56
|
-
initialize:
|
|
58
|
+
initialize:
|
|
59
|
+
| null
|
|
60
|
+
| ((ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>);
|
|
57
61
|
|
|
58
62
|
/**
|
|
59
63
|
* Function selector agent.
|
|
@@ -82,7 +86,7 @@ export interface IAgenticaExecutor {
|
|
|
82
86
|
* @param ctx Context of the agent
|
|
83
87
|
* @returns List of prompts generated by the selector
|
|
84
88
|
*/
|
|
85
|
-
select: (ctx: IAgenticaContext) => Promise<IAgenticaPrompt[]>;
|
|
89
|
+
select: (ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>;
|
|
86
90
|
|
|
87
91
|
/**
|
|
88
92
|
* Function caller agent.
|
|
@@ -109,7 +113,7 @@ export interface IAgenticaExecutor {
|
|
|
109
113
|
* agent is the most general topic which can be universally
|
|
110
114
|
* applied to all domain fields.
|
|
111
115
|
*/
|
|
112
|
-
call: (ctx: IAgenticaContext) => Promise<IAgenticaPrompt[]>;
|
|
116
|
+
call: (ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>;
|
|
113
117
|
|
|
114
118
|
/**
|
|
115
119
|
* Describer agent of the function calling result.
|
|
@@ -122,9 +126,9 @@ export interface IAgenticaExecutor {
|
|
|
122
126
|
* @returns List of prompts generated by the describer
|
|
123
127
|
*/
|
|
124
128
|
describe: (
|
|
125
|
-
ctx: IAgenticaContext
|
|
126
|
-
executes: IAgenticaPrompt.IExecute[],
|
|
127
|
-
) => Promise<IAgenticaPrompt[]>;
|
|
129
|
+
ctx: IAgenticaContext<Model>,
|
|
130
|
+
executes: IAgenticaPrompt.IExecute<Model>[],
|
|
131
|
+
) => Promise<IAgenticaPrompt<Model>[]>;
|
|
128
132
|
|
|
129
133
|
/**
|
|
130
134
|
* Function canceler agent.
|
|
@@ -148,5 +152,5 @@ export interface IAgenticaExecutor {
|
|
|
148
152
|
* @param ctx Context of the agent
|
|
149
153
|
* @returns List of prompts generated by the canceler
|
|
150
154
|
*/
|
|
151
|
-
cancel: (ctx: IAgenticaContext) => Promise<IAgenticaPrompt[]>;
|
|
155
|
+
cancel: (ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>;
|
|
152
156
|
}
|
|
@@ -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
|
|
|
4
4
|
import { IAgenticaController } from "./IAgenticaController";
|
|
@@ -18,26 +18,26 @@ import { IAgenticaController } from "./IAgenticaController";
|
|
|
18
18
|
*
|
|
19
19
|
* @author Samchon
|
|
20
20
|
*/
|
|
21
|
-
export type IAgenticaOperation =
|
|
22
|
-
| IAgenticaOperation.IHttp
|
|
23
|
-
| IAgenticaOperation.IClass
|
|
21
|
+
export type IAgenticaOperation<Model extends ILlmSchema.Model> =
|
|
22
|
+
| IAgenticaOperation.IHttp<Model>
|
|
23
|
+
| IAgenticaOperation.IClass<Model>;
|
|
24
24
|
export namespace IAgenticaOperation {
|
|
25
25
|
/**
|
|
26
26
|
* HTTP API operation.
|
|
27
27
|
*/
|
|
28
|
-
export type IHttp = IBase<
|
|
28
|
+
export type IHttp<Model extends ILlmSchema.Model> = IBase<
|
|
29
29
|
"http",
|
|
30
|
-
IAgenticaController.IHttp
|
|
31
|
-
IHttpLlmFunction<
|
|
30
|
+
IAgenticaController.IHttp<Model>,
|
|
31
|
+
IHttpLlmFunction<Model>
|
|
32
32
|
>;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* TypeScript class operation.
|
|
36
36
|
*/
|
|
37
|
-
export type IClass = IBase<
|
|
37
|
+
export type IClass<Model extends ILlmSchema.Model> = IBase<
|
|
38
38
|
"class",
|
|
39
|
-
IAgenticaController.IClass
|
|
40
|
-
ILlmFunctionOfValidate<
|
|
39
|
+
IAgenticaController.IClass<Model>,
|
|
40
|
+
ILlmFunctionOfValidate<Model>
|
|
41
41
|
>;
|
|
42
42
|
|
|
43
43
|
interface IBase<Protocol, Application, Function> {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
|
|
1
3
|
import { IAgenticaOperation } from "./IAgenticaOperation";
|
|
2
4
|
|
|
3
5
|
/**
|
|
@@ -9,11 +11,11 @@ import { IAgenticaOperation } from "./IAgenticaOperation";
|
|
|
9
11
|
*
|
|
10
12
|
* @author Samchon
|
|
11
13
|
*/
|
|
12
|
-
export interface IAgenticaOperationCollection {
|
|
14
|
+
export interface IAgenticaOperationCollection<Model extends ILlmSchema.Model> {
|
|
13
15
|
/**
|
|
14
16
|
* List of every operations.
|
|
15
17
|
*/
|
|
16
|
-
array: IAgenticaOperation[];
|
|
18
|
+
array: IAgenticaOperation<Model>[];
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* Divided operations.
|
|
@@ -30,14 +32,14 @@ export interface IAgenticaOperationCollection {
|
|
|
30
32
|
* Otherwise, if the {@link IAgenticaConfig.capacity} has not been
|
|
31
33
|
* configured, this `divided` property would be the `undefined` value.
|
|
32
34
|
*/
|
|
33
|
-
divided?: IAgenticaOperation[][] | undefined;
|
|
35
|
+
divided?: IAgenticaOperation<Model>[][] | undefined;
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
38
|
* Flat dictionary of operations.
|
|
37
39
|
*
|
|
38
40
|
* Dictionary of operations with their {@link IAgenticaOperation.name}.
|
|
39
41
|
*/
|
|
40
|
-
flat: Map<string, IAgenticaOperation
|
|
42
|
+
flat: Map<string, IAgenticaOperation<Model>>;
|
|
41
43
|
|
|
42
44
|
/**
|
|
43
45
|
* Group dictionary of operations.
|
|
@@ -46,5 +48,5 @@ export interface IAgenticaOperationCollection {
|
|
|
46
48
|
* {@link IAgenticaOperation.controller.name} and
|
|
47
49
|
* {@link IAgenticaOperation.function.name}.
|
|
48
50
|
*/
|
|
49
|
-
group: Map<string, Map<string, IAgenticaOperation
|
|
51
|
+
group: Map<string, Map<string, IAgenticaOperation<Model>>>;
|
|
50
52
|
}
|
|
@@ -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
|
|
|
4
4
|
import { IAgenticaController } from "./IAgenticaController";
|
|
@@ -16,20 +16,20 @@ import { IAgenticaController } from "./IAgenticaController";
|
|
|
16
16
|
*
|
|
17
17
|
* @author Samchon
|
|
18
18
|
*/
|
|
19
|
-
export type IAgenticaOperationSelection =
|
|
20
|
-
| IAgenticaOperationSelection.IHttp
|
|
21
|
-
| IAgenticaOperationSelection.IClass
|
|
19
|
+
export type IAgenticaOperationSelection<Model extends ILlmSchema.Model> =
|
|
20
|
+
| IAgenticaOperationSelection.IHttp<Model>
|
|
21
|
+
| IAgenticaOperationSelection.IClass<Model>;
|
|
22
22
|
export namespace IAgenticaOperationSelection {
|
|
23
|
-
export type IHttp = IBase<
|
|
23
|
+
export type IHttp<Model extends ILlmSchema.Model> = IBase<
|
|
24
24
|
"http",
|
|
25
|
-
IAgenticaController.IHttp
|
|
26
|
-
IHttpLlmFunction<
|
|
25
|
+
IAgenticaController.IHttp<Model>,
|
|
26
|
+
IHttpLlmFunction<Model>
|
|
27
27
|
>;
|
|
28
28
|
|
|
29
|
-
export type IClass = IBase<
|
|
29
|
+
export type IClass<Model extends ILlmSchema.Model> = IBase<
|
|
30
30
|
"class",
|
|
31
|
-
IAgenticaController.IClass
|
|
32
|
-
ILlmFunctionOfValidate<
|
|
31
|
+
IAgenticaController.IClass<Model>,
|
|
32
|
+
ILlmFunctionOfValidate<Model>
|
|
33
33
|
>;
|
|
34
34
|
|
|
35
35
|
interface IBase<Protocol, Controller, Function> {
|
|
@@ -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
|
|
|
4
4
|
import { IAgenticaController } from "./IAgenticaController";
|
|
@@ -20,19 +20,20 @@ import { IAgenticaOperationSelection } from "./IAgenticaOperationSelection";
|
|
|
20
20
|
*
|
|
21
21
|
* @author Samchon
|
|
22
22
|
*/
|
|
23
|
-
export type IAgenticaPrompt =
|
|
23
|
+
export type IAgenticaPrompt<Model extends ILlmSchema.Model> =
|
|
24
24
|
| IAgenticaPrompt.IText
|
|
25
|
-
| IAgenticaPrompt.ISelect
|
|
26
|
-
| IAgenticaPrompt.ICancel
|
|
27
|
-
| IAgenticaPrompt.IExecute
|
|
28
|
-
| IAgenticaPrompt.IDescribe
|
|
25
|
+
| IAgenticaPrompt.ISelect<Model>
|
|
26
|
+
| IAgenticaPrompt.ICancel<Model>
|
|
27
|
+
| IAgenticaPrompt.IExecute<Model>
|
|
28
|
+
| IAgenticaPrompt.IDescribe<Model>;
|
|
29
29
|
export namespace IAgenticaPrompt {
|
|
30
30
|
/**
|
|
31
31
|
* Select prompt.
|
|
32
32
|
*
|
|
33
33
|
* Selection prompt about candidate functions to call.
|
|
34
34
|
*/
|
|
35
|
-
export interface ISelect extends
|
|
35
|
+
export interface ISelect<Model extends ILlmSchema.Model>
|
|
36
|
+
extends IBase<"select"> {
|
|
36
37
|
/**
|
|
37
38
|
* ID of the LLM tool call result.
|
|
38
39
|
*/
|
|
@@ -41,7 +42,7 @@ export namespace IAgenticaPrompt {
|
|
|
41
42
|
/**
|
|
42
43
|
* Operations that have been selected.
|
|
43
44
|
*/
|
|
44
|
-
operations: IAgenticaOperationSelection[];
|
|
45
|
+
operations: IAgenticaOperationSelection<Model>[];
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
/**
|
|
@@ -49,7 +50,8 @@ export namespace IAgenticaPrompt {
|
|
|
49
50
|
*
|
|
50
51
|
* Cancellation prompt about the candidate functions to be discarded.
|
|
51
52
|
*/
|
|
52
|
-
export interface ICancel extends
|
|
53
|
+
export interface ICancel<Model extends ILlmSchema.Model>
|
|
54
|
+
extends IBase<"cancel"> {
|
|
53
55
|
/**
|
|
54
56
|
* ID of the LLM tool call result.
|
|
55
57
|
*/
|
|
@@ -58,7 +60,7 @@ export namespace IAgenticaPrompt {
|
|
|
58
60
|
/**
|
|
59
61
|
* Operations that have been cancelled.
|
|
60
62
|
*/
|
|
61
|
-
operations: IAgenticaOperationSelection[];
|
|
63
|
+
operations: IAgenticaOperationSelection<Model>[];
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
/**
|
|
@@ -66,18 +68,20 @@ export namespace IAgenticaPrompt {
|
|
|
66
68
|
*
|
|
67
69
|
* Execution prompt about the LLM function calling.
|
|
68
70
|
*/
|
|
69
|
-
export type IExecute
|
|
71
|
+
export type IExecute<Model extends ILlmSchema.Model> =
|
|
72
|
+
| IExecute.IHttp<Model>
|
|
73
|
+
| IExecute.IClass<Model>;
|
|
70
74
|
export namespace IExecute {
|
|
71
|
-
export type IHttp = IBase<
|
|
75
|
+
export type IHttp<Model extends ILlmSchema.Model> = IBase<
|
|
72
76
|
"http",
|
|
73
|
-
IAgenticaController.IHttp
|
|
74
|
-
IHttpLlmFunction<
|
|
77
|
+
IAgenticaController.IHttp<Model>,
|
|
78
|
+
IHttpLlmFunction<Model>,
|
|
75
79
|
IHttpResponse
|
|
76
80
|
>;
|
|
77
|
-
export type IClass = IBase<
|
|
81
|
+
export type IClass<Model extends ILlmSchema.Model> = IBase<
|
|
78
82
|
"class",
|
|
79
|
-
IAgenticaController.IClass
|
|
80
|
-
ILlmFunctionOfValidate<
|
|
83
|
+
IAgenticaController.IClass<Model>,
|
|
84
|
+
ILlmFunctionOfValidate<Model>,
|
|
81
85
|
any
|
|
82
86
|
>;
|
|
83
87
|
interface IBase<Protocol, Controller, Function, Value> {
|
|
@@ -133,13 +137,14 @@ export namespace IAgenticaPrompt {
|
|
|
133
137
|
*
|
|
134
138
|
* Description prompt about the return value of the LLM function calling.
|
|
135
139
|
*/
|
|
136
|
-
export interface IDescribe extends
|
|
140
|
+
export interface IDescribe<Model extends ILlmSchema.Model>
|
|
141
|
+
extends IBase<"describe"> {
|
|
137
142
|
/**
|
|
138
143
|
* Executions of the LLM function calling.
|
|
139
144
|
*
|
|
140
145
|
* This prompt describes the return value of them.
|
|
141
146
|
*/
|
|
142
|
-
executions: IExecute[];
|
|
147
|
+
executions: IExecute<Model>[];
|
|
143
148
|
|
|
144
149
|
/**
|
|
145
150
|
* Description text.
|