@agentica/core 0.12.2-dev.20250314 → 0.12.4
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 +461 -461
- package/lib/context/AgenticaTokenUsage.d.ts +6 -6
- 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 +359 -359
- package/src/chatgpt/ChatGptAgent.ts +76 -76
- package/src/chatgpt/ChatGptCallFunctionAgent.ts +466 -466
- package/src/chatgpt/ChatGptCancelFunctionAgent.ts +280 -280
- package/src/chatgpt/ChatGptCompletionMessageUtil.ts +166 -166
- package/src/chatgpt/ChatGptDescribeFunctionAgent.ts +122 -122
- package/src/chatgpt/ChatGptHistoryDecoder.ts +88 -88
- package/src/chatgpt/ChatGptInitializeFunctionAgent.ts +96 -96
- package/src/chatgpt/ChatGptSelectFunctionAgent.ts +311 -311
- package/src/chatgpt/ChatGptUsageAggregator.ts +62 -62
- package/src/context/AgenticaCancelPrompt.ts +32 -32
- package/src/context/AgenticaClassOperation.ts +23 -23
- package/src/context/AgenticaContext.ts +130 -130
- package/src/context/AgenticaHttpOperation.ts +27 -27
- package/src/context/AgenticaOperation.ts +66 -66
- package/src/context/AgenticaOperationBase.ts +57 -57
- package/src/context/AgenticaOperationCollection.ts +52 -52
- package/src/context/AgenticaOperationSelection.ts +27 -27
- package/src/context/AgenticaTokenUsage.ts +170 -170
- package/src/context/internal/AgenticaTokenUsageAggregator.ts +66 -66
- package/src/context/internal/__IChatCancelFunctionsApplication.ts +23 -23
- package/src/context/internal/__IChatFunctionReference.ts +21 -21
- package/src/context/internal/__IChatInitialApplication.ts +15 -15
- package/src/context/internal/__IChatSelectFunctionsApplication.ts +24 -24
- package/src/events/AgenticaCallEvent.ts +36 -36
- package/src/events/AgenticaCancelEvent.ts +28 -28
- package/src/events/AgenticaDescribeEvent.ts +66 -66
- package/src/events/AgenticaEvent.ts +36 -36
- package/src/events/AgenticaEventBase.ts +7 -7
- package/src/events/AgenticaEventSource.ts +6 -6
- package/src/events/AgenticaExecuteEvent.ts +50 -50
- package/src/events/AgenticaInitializeEvent.ts +14 -14
- package/src/events/AgenticaRequestEvent.ts +45 -45
- package/src/events/AgenticaResponseEvent.ts +48 -48
- package/src/events/AgenticaSelectEvent.ts +37 -37
- package/src/events/AgenticaTextEvent.ts +62 -62
- package/src/functional/assertHttpLlmApplication.ts +55 -55
- package/src/functional/validateHttpLlmApplication.ts +66 -66
- package/src/index.ts +44 -44
- package/src/internal/AgenticaConstant.ts +4 -4
- package/src/internal/AgenticaDefaultPrompt.ts +43 -43
- package/src/internal/AgenticaOperationComposer.ts +96 -96
- package/src/internal/ByteArrayUtil.ts +5 -5
- package/src/internal/MPSCUtil.ts +111 -111
- package/src/internal/MathUtil.ts +3 -3
- package/src/internal/Singleton.ts +22 -22
- package/src/internal/StreamUtil.ts +64 -64
- package/src/internal/__map_take.ts +15 -15
- package/src/json/IAgenticaEventJson.ts +178 -178
- package/src/json/IAgenticaOperationJson.ts +36 -36
- package/src/json/IAgenticaOperationSelectionJson.ts +19 -19
- package/src/json/IAgenticaPromptJson.ts +130 -130
- package/src/json/IAgenticaTokenUsageJson.ts +107 -107
- package/src/prompts/AgenticaCancelPrompt.ts +32 -32
- package/src/prompts/AgenticaDescribePrompt.ts +41 -41
- package/src/prompts/AgenticaExecutePrompt.ts +52 -52
- package/src/prompts/AgenticaPrompt.ts +14 -14
- package/src/prompts/AgenticaPromptBase.ts +27 -27
- package/src/prompts/AgenticaSelectPrompt.ts +32 -32
- package/src/prompts/AgenticaTextPrompt.ts +31 -31
- package/src/structures/IAgenticaConfig.ts +123 -123
- package/src/structures/IAgenticaController.ts +133 -133
- package/src/structures/IAgenticaExecutor.ts +157 -157
- package/src/structures/IAgenticaProps.ts +69 -69
- package/src/structures/IAgenticaSystemPrompt.ts +125 -125
- package/src/structures/IAgenticaVendor.ts +39 -39
- package/src/transformers/AgenticaEventTransformer.ts +165 -165
- package/src/transformers/AgenticaPromptTransformer.ts +134 -134
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
|
|
3
|
-
import { AgenticaOperation } from "../context/AgenticaOperation";
|
|
4
|
-
import { IAgenticaEventJson } from "../json/IAgenticaEventJson";
|
|
5
|
-
import { AgenticaEventBase } from "./AgenticaEventBase";
|
|
6
|
-
|
|
7
|
-
export class AgenticaCallEvent<
|
|
8
|
-
Model extends ILlmSchema.Model,
|
|
9
|
-
> extends AgenticaEventBase<"call"> {
|
|
10
|
-
public readonly id: string;
|
|
11
|
-
public readonly operation: AgenticaOperation<Model>;
|
|
12
|
-
public arguments: Record<string, any>;
|
|
13
|
-
|
|
14
|
-
public constructor(props: AgenticaCallEvent.IProps<Model>) {
|
|
15
|
-
super("call");
|
|
16
|
-
this.id = props.id;
|
|
17
|
-
this.operation = props.operation;
|
|
18
|
-
this.arguments = props.arguments;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public toJSON(): IAgenticaEventJson.ICall {
|
|
22
|
-
return {
|
|
23
|
-
type: "call",
|
|
24
|
-
id: this.id,
|
|
25
|
-
operation: this.operation.toJSON(),
|
|
26
|
-
arguments: this.arguments,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
export namespace AgenticaCallEvent {
|
|
31
|
-
export interface IProps<Model extends ILlmSchema.Model> {
|
|
32
|
-
id: string;
|
|
33
|
-
operation: AgenticaOperation<Model>;
|
|
34
|
-
arguments: Record<string, any>;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
|
|
3
|
+
import { AgenticaOperation } from "../context/AgenticaOperation";
|
|
4
|
+
import { IAgenticaEventJson } from "../json/IAgenticaEventJson";
|
|
5
|
+
import { AgenticaEventBase } from "./AgenticaEventBase";
|
|
6
|
+
|
|
7
|
+
export class AgenticaCallEvent<
|
|
8
|
+
Model extends ILlmSchema.Model,
|
|
9
|
+
> extends AgenticaEventBase<"call"> {
|
|
10
|
+
public readonly id: string;
|
|
11
|
+
public readonly operation: AgenticaOperation<Model>;
|
|
12
|
+
public arguments: Record<string, any>;
|
|
13
|
+
|
|
14
|
+
public constructor(props: AgenticaCallEvent.IProps<Model>) {
|
|
15
|
+
super("call");
|
|
16
|
+
this.id = props.id;
|
|
17
|
+
this.operation = props.operation;
|
|
18
|
+
this.arguments = props.arguments;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public toJSON(): IAgenticaEventJson.ICall {
|
|
22
|
+
return {
|
|
23
|
+
type: "call",
|
|
24
|
+
id: this.id,
|
|
25
|
+
operation: this.operation.toJSON(),
|
|
26
|
+
arguments: this.arguments,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export namespace AgenticaCallEvent {
|
|
31
|
+
export interface IProps<Model extends ILlmSchema.Model> {
|
|
32
|
+
id: string;
|
|
33
|
+
operation: AgenticaOperation<Model>;
|
|
34
|
+
arguments: Record<string, any>;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
|
|
3
|
-
import { AgenticaOperationSelection } from "../context/AgenticaOperationSelection";
|
|
4
|
-
import { IAgenticaEventJson } from "../json/IAgenticaEventJson";
|
|
5
|
-
import { AgenticaEventBase } from "./AgenticaEventBase";
|
|
6
|
-
|
|
7
|
-
export class AgenticaCancelEvent<
|
|
8
|
-
Model extends ILlmSchema.Model,
|
|
9
|
-
> extends AgenticaEventBase<"cancel"> {
|
|
10
|
-
public readonly selection: AgenticaOperationSelection<Model>;
|
|
11
|
-
|
|
12
|
-
public constructor(props: AgenticaCancelEvent.IProps<Model>) {
|
|
13
|
-
super("cancel");
|
|
14
|
-
this.selection = props.selection;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public toJSON(): IAgenticaEventJson.ICancel {
|
|
18
|
-
return {
|
|
19
|
-
type: "cancel",
|
|
20
|
-
selection: this.selection.toJSON(),
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export namespace AgenticaCancelEvent {
|
|
25
|
-
export interface IProps<Model extends ILlmSchema.Model> {
|
|
26
|
-
selection: AgenticaOperationSelection<Model>;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
|
|
3
|
+
import { AgenticaOperationSelection } from "../context/AgenticaOperationSelection";
|
|
4
|
+
import { IAgenticaEventJson } from "../json/IAgenticaEventJson";
|
|
5
|
+
import { AgenticaEventBase } from "./AgenticaEventBase";
|
|
6
|
+
|
|
7
|
+
export class AgenticaCancelEvent<
|
|
8
|
+
Model extends ILlmSchema.Model,
|
|
9
|
+
> extends AgenticaEventBase<"cancel"> {
|
|
10
|
+
public readonly selection: AgenticaOperationSelection<Model>;
|
|
11
|
+
|
|
12
|
+
public constructor(props: AgenticaCancelEvent.IProps<Model>) {
|
|
13
|
+
super("cancel");
|
|
14
|
+
this.selection = props.selection;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public toJSON(): IAgenticaEventJson.ICancel {
|
|
18
|
+
return {
|
|
19
|
+
type: "cancel",
|
|
20
|
+
selection: this.selection.toJSON(),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export namespace AgenticaCancelEvent {
|
|
25
|
+
export interface IProps<Model extends ILlmSchema.Model> {
|
|
26
|
+
selection: AgenticaOperationSelection<Model>;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
|
|
3
|
-
import { IAgenticaEventJson } from "../json/IAgenticaEventJson";
|
|
4
|
-
import { AgenticaDescribePrompt } from "../prompts/AgenticaDescribePrompt";
|
|
5
|
-
import { AgenticaExecutePrompt } from "../prompts/AgenticaExecutePrompt";
|
|
6
|
-
import { AgenticaEventBase } from "./AgenticaEventBase";
|
|
7
|
-
|
|
8
|
-
export class AgenticaDescribeEvent<
|
|
9
|
-
Model extends ILlmSchema.Model,
|
|
10
|
-
> extends AgenticaEventBase<"describe"> {
|
|
11
|
-
public readonly executes: AgenticaExecutePrompt<Model>[];
|
|
12
|
-
public readonly stream: ReadableStream<string>;
|
|
13
|
-
public get text(): string {
|
|
14
|
-
return this.get_();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Check if the join method can return a response immediately.
|
|
19
|
-
* Returns true if the response is ready to be returned by the join method.
|
|
20
|
-
*/
|
|
21
|
-
public get done(): boolean {
|
|
22
|
-
return this.done_();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public constructor(props: AgenticaDescribeEvent.IProps<Model>) {
|
|
26
|
-
super("describe");
|
|
27
|
-
this.stream = props.stream;
|
|
28
|
-
this.executes = props.executes;
|
|
29
|
-
this.done_ = props.done;
|
|
30
|
-
this.get_ = props.get;
|
|
31
|
-
this.join_ = props.join;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public join(): Promise<string> {
|
|
35
|
-
return this.join_();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public toJSON(): IAgenticaEventJson.IDescribe {
|
|
39
|
-
return {
|
|
40
|
-
type: "describe",
|
|
41
|
-
executes: this.executes.map((e) => e.toJSON()),
|
|
42
|
-
text: this.text,
|
|
43
|
-
done: this.done,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public toPrompt(): AgenticaDescribePrompt<Model> {
|
|
48
|
-
return new AgenticaDescribePrompt({
|
|
49
|
-
executes: this.executes,
|
|
50
|
-
text: this.text,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
private readonly done_: () => boolean;
|
|
55
|
-
private readonly get_: () => string;
|
|
56
|
-
private readonly join_: () => Promise<string>;
|
|
57
|
-
}
|
|
58
|
-
export namespace AgenticaDescribeEvent {
|
|
59
|
-
export interface IProps<Model extends ILlmSchema.Model> {
|
|
60
|
-
executes: AgenticaExecutePrompt<Model>[];
|
|
61
|
-
stream: ReadableStream<string>;
|
|
62
|
-
done: () => boolean;
|
|
63
|
-
get: () => string;
|
|
64
|
-
join: () => Promise<string>;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
|
|
3
|
+
import { IAgenticaEventJson } from "../json/IAgenticaEventJson";
|
|
4
|
+
import { AgenticaDescribePrompt } from "../prompts/AgenticaDescribePrompt";
|
|
5
|
+
import { AgenticaExecutePrompt } from "../prompts/AgenticaExecutePrompt";
|
|
6
|
+
import { AgenticaEventBase } from "./AgenticaEventBase";
|
|
7
|
+
|
|
8
|
+
export class AgenticaDescribeEvent<
|
|
9
|
+
Model extends ILlmSchema.Model,
|
|
10
|
+
> extends AgenticaEventBase<"describe"> {
|
|
11
|
+
public readonly executes: AgenticaExecutePrompt<Model>[];
|
|
12
|
+
public readonly stream: ReadableStream<string>;
|
|
13
|
+
public get text(): string {
|
|
14
|
+
return this.get_();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Check if the join method can return a response immediately.
|
|
19
|
+
* Returns true if the response is ready to be returned by the join method.
|
|
20
|
+
*/
|
|
21
|
+
public get done(): boolean {
|
|
22
|
+
return this.done_();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public constructor(props: AgenticaDescribeEvent.IProps<Model>) {
|
|
26
|
+
super("describe");
|
|
27
|
+
this.stream = props.stream;
|
|
28
|
+
this.executes = props.executes;
|
|
29
|
+
this.done_ = props.done;
|
|
30
|
+
this.get_ = props.get;
|
|
31
|
+
this.join_ = props.join;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public join(): Promise<string> {
|
|
35
|
+
return this.join_();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public toJSON(): IAgenticaEventJson.IDescribe {
|
|
39
|
+
return {
|
|
40
|
+
type: "describe",
|
|
41
|
+
executes: this.executes.map((e) => e.toJSON()),
|
|
42
|
+
text: this.text,
|
|
43
|
+
done: this.done,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public toPrompt(): AgenticaDescribePrompt<Model> {
|
|
48
|
+
return new AgenticaDescribePrompt({
|
|
49
|
+
executes: this.executes,
|
|
50
|
+
text: this.text,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private readonly done_: () => boolean;
|
|
55
|
+
private readonly get_: () => string;
|
|
56
|
+
private readonly join_: () => Promise<string>;
|
|
57
|
+
}
|
|
58
|
+
export namespace AgenticaDescribeEvent {
|
|
59
|
+
export interface IProps<Model extends ILlmSchema.Model> {
|
|
60
|
+
executes: AgenticaExecutePrompt<Model>[];
|
|
61
|
+
stream: ReadableStream<string>;
|
|
62
|
+
done: () => boolean;
|
|
63
|
+
get: () => string;
|
|
64
|
+
join: () => Promise<string>;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
|
|
3
|
-
import { AgenticaCallEvent } from "./AgenticaCallEvent";
|
|
4
|
-
import { AgenticaCancelEvent } from "./AgenticaCancelEvent";
|
|
5
|
-
import { AgenticaDescribeEvent } from "./AgenticaDescribeEvent";
|
|
6
|
-
import { AgenticaExecuteEvent } from "./AgenticaExecuteEvent";
|
|
7
|
-
import { AgenticaInitializeEvent } from "./AgenticaInitializeEvent";
|
|
8
|
-
import { AgenticaRequestEvent } from "./AgenticaRequestEvent";
|
|
9
|
-
import { AgenticaResponseEvent } from "./AgenticaResponseEvent";
|
|
10
|
-
import { AgenticaSelectEvent } from "./AgenticaSelectEvent";
|
|
11
|
-
import { AgenticaTextEvent } from "./AgenticaTextEvent";
|
|
12
|
-
|
|
13
|
-
export type AgenticaEvent<Model extends ILlmSchema.Model> =
|
|
14
|
-
| AgenticaCallEvent<Model>
|
|
15
|
-
| AgenticaCancelEvent<Model>
|
|
16
|
-
| AgenticaDescribeEvent<Model>
|
|
17
|
-
| AgenticaExecuteEvent<Model>
|
|
18
|
-
| AgenticaInitializeEvent
|
|
19
|
-
| AgenticaRequestEvent
|
|
20
|
-
| AgenticaResponseEvent
|
|
21
|
-
| AgenticaSelectEvent<Model>
|
|
22
|
-
| AgenticaTextEvent;
|
|
23
|
-
export namespace AgenticaEvent {
|
|
24
|
-
export type Type = AgenticaEvent<any>["type"];
|
|
25
|
-
export type Mapper<Model extends ILlmSchema.Model> = {
|
|
26
|
-
call: AgenticaCallEvent<Model>;
|
|
27
|
-
cancel: AgenticaCancelEvent<Model>;
|
|
28
|
-
describe: AgenticaDescribeEvent<Model>;
|
|
29
|
-
execute: AgenticaExecuteEvent<Model>;
|
|
30
|
-
initialize: AgenticaInitializeEvent;
|
|
31
|
-
request: AgenticaRequestEvent;
|
|
32
|
-
response: AgenticaResponseEvent;
|
|
33
|
-
select: AgenticaSelectEvent<Model>;
|
|
34
|
-
text: AgenticaTextEvent;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
|
|
3
|
+
import { AgenticaCallEvent } from "./AgenticaCallEvent";
|
|
4
|
+
import { AgenticaCancelEvent } from "./AgenticaCancelEvent";
|
|
5
|
+
import { AgenticaDescribeEvent } from "./AgenticaDescribeEvent";
|
|
6
|
+
import { AgenticaExecuteEvent } from "./AgenticaExecuteEvent";
|
|
7
|
+
import { AgenticaInitializeEvent } from "./AgenticaInitializeEvent";
|
|
8
|
+
import { AgenticaRequestEvent } from "./AgenticaRequestEvent";
|
|
9
|
+
import { AgenticaResponseEvent } from "./AgenticaResponseEvent";
|
|
10
|
+
import { AgenticaSelectEvent } from "./AgenticaSelectEvent";
|
|
11
|
+
import { AgenticaTextEvent } from "./AgenticaTextEvent";
|
|
12
|
+
|
|
13
|
+
export type AgenticaEvent<Model extends ILlmSchema.Model> =
|
|
14
|
+
| AgenticaCallEvent<Model>
|
|
15
|
+
| AgenticaCancelEvent<Model>
|
|
16
|
+
| AgenticaDescribeEvent<Model>
|
|
17
|
+
| AgenticaExecuteEvent<Model>
|
|
18
|
+
| AgenticaInitializeEvent
|
|
19
|
+
| AgenticaRequestEvent
|
|
20
|
+
| AgenticaResponseEvent
|
|
21
|
+
| AgenticaSelectEvent<Model>
|
|
22
|
+
| AgenticaTextEvent;
|
|
23
|
+
export namespace AgenticaEvent {
|
|
24
|
+
export type Type = AgenticaEvent<any>["type"];
|
|
25
|
+
export type Mapper<Model extends ILlmSchema.Model> = {
|
|
26
|
+
call: AgenticaCallEvent<Model>;
|
|
27
|
+
cancel: AgenticaCancelEvent<Model>;
|
|
28
|
+
describe: AgenticaDescribeEvent<Model>;
|
|
29
|
+
execute: AgenticaExecuteEvent<Model>;
|
|
30
|
+
initialize: AgenticaInitializeEvent;
|
|
31
|
+
request: AgenticaRequestEvent;
|
|
32
|
+
response: AgenticaResponseEvent;
|
|
33
|
+
select: AgenticaSelectEvent<Model>;
|
|
34
|
+
text: AgenticaTextEvent;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export abstract class AgenticaEventBase<Type extends string> {
|
|
2
|
-
public readonly type: Type;
|
|
3
|
-
|
|
4
|
-
public constructor(type: Type) {
|
|
5
|
-
this.type = type;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
1
|
+
export abstract class AgenticaEventBase<Type extends string> {
|
|
2
|
+
public readonly type: Type;
|
|
3
|
+
|
|
4
|
+
public constructor(type: Type) {
|
|
5
|
+
this.type = type;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type AgenticaEventSource =
|
|
2
|
-
| "initialize"
|
|
3
|
-
| "select"
|
|
4
|
-
| "cancel"
|
|
5
|
-
| "call"
|
|
6
|
-
| "describe";
|
|
1
|
+
export type AgenticaEventSource =
|
|
2
|
+
| "initialize"
|
|
3
|
+
| "select"
|
|
4
|
+
| "cancel"
|
|
5
|
+
| "call"
|
|
6
|
+
| "describe";
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
|
|
3
|
-
import { AgenticaOperation } from "../context/AgenticaOperation";
|
|
4
|
-
import { IAgenticaEventJson } from "../json/IAgenticaEventJson";
|
|
5
|
-
import { AgenticaExecutePrompt } from "../prompts/AgenticaExecutePrompt";
|
|
6
|
-
import { AgenticaEventBase } from "./AgenticaEventBase";
|
|
7
|
-
|
|
8
|
-
export class AgenticaExecuteEvent<
|
|
9
|
-
Model extends ILlmSchema.Model,
|
|
10
|
-
> extends AgenticaEventBase<"execute"> {
|
|
11
|
-
public readonly id: string;
|
|
12
|
-
public readonly operation: AgenticaOperation<Model>;
|
|
13
|
-
public readonly arguments: Record<string, any>;
|
|
14
|
-
public readonly value: any;
|
|
15
|
-
|
|
16
|
-
public constructor(props: AgenticaExecuteEvent.IProps<Model>) {
|
|
17
|
-
super("execute");
|
|
18
|
-
this.id = props.id;
|
|
19
|
-
this.operation = props.operation;
|
|
20
|
-
this.arguments = props.arguments;
|
|
21
|
-
this.value = props.value;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public toJSON(): IAgenticaEventJson.IExecute {
|
|
25
|
-
return {
|
|
26
|
-
type: "execute",
|
|
27
|
-
id: this.id,
|
|
28
|
-
operation: this.operation.toJSON(),
|
|
29
|
-
arguments: this.arguments,
|
|
30
|
-
value: this.value,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public toPrompt(): AgenticaExecutePrompt<Model> {
|
|
35
|
-
return new AgenticaExecutePrompt({
|
|
36
|
-
id: this.id,
|
|
37
|
-
operation: this.operation,
|
|
38
|
-
arguments: this.arguments,
|
|
39
|
-
value: this.value,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
export namespace AgenticaExecuteEvent {
|
|
44
|
-
export interface IProps<Model extends ILlmSchema.Model> {
|
|
45
|
-
id: string;
|
|
46
|
-
operation: AgenticaOperation<Model>;
|
|
47
|
-
arguments: Record<string, any>;
|
|
48
|
-
value: any;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
|
|
3
|
+
import { AgenticaOperation } from "../context/AgenticaOperation";
|
|
4
|
+
import { IAgenticaEventJson } from "../json/IAgenticaEventJson";
|
|
5
|
+
import { AgenticaExecutePrompt } from "../prompts/AgenticaExecutePrompt";
|
|
6
|
+
import { AgenticaEventBase } from "./AgenticaEventBase";
|
|
7
|
+
|
|
8
|
+
export class AgenticaExecuteEvent<
|
|
9
|
+
Model extends ILlmSchema.Model,
|
|
10
|
+
> extends AgenticaEventBase<"execute"> {
|
|
11
|
+
public readonly id: string;
|
|
12
|
+
public readonly operation: AgenticaOperation<Model>;
|
|
13
|
+
public readonly arguments: Record<string, any>;
|
|
14
|
+
public readonly value: any;
|
|
15
|
+
|
|
16
|
+
public constructor(props: AgenticaExecuteEvent.IProps<Model>) {
|
|
17
|
+
super("execute");
|
|
18
|
+
this.id = props.id;
|
|
19
|
+
this.operation = props.operation;
|
|
20
|
+
this.arguments = props.arguments;
|
|
21
|
+
this.value = props.value;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public toJSON(): IAgenticaEventJson.IExecute {
|
|
25
|
+
return {
|
|
26
|
+
type: "execute",
|
|
27
|
+
id: this.id,
|
|
28
|
+
operation: this.operation.toJSON(),
|
|
29
|
+
arguments: this.arguments,
|
|
30
|
+
value: this.value,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public toPrompt(): AgenticaExecutePrompt<Model> {
|
|
35
|
+
return new AgenticaExecutePrompt({
|
|
36
|
+
id: this.id,
|
|
37
|
+
operation: this.operation,
|
|
38
|
+
arguments: this.arguments,
|
|
39
|
+
value: this.value,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export namespace AgenticaExecuteEvent {
|
|
44
|
+
export interface IProps<Model extends ILlmSchema.Model> {
|
|
45
|
+
id: string;
|
|
46
|
+
operation: AgenticaOperation<Model>;
|
|
47
|
+
arguments: Record<string, any>;
|
|
48
|
+
value: any;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { IAgenticaEventJson } from "../json/IAgenticaEventJson";
|
|
2
|
-
import { AgenticaEventBase } from "./AgenticaEventBase";
|
|
3
|
-
|
|
4
|
-
export class AgenticaInitializeEvent extends AgenticaEventBase<"initialize"> {
|
|
5
|
-
public constructor() {
|
|
6
|
-
super("initialize");
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
public toJSON(): IAgenticaEventJson.IInitialize {
|
|
10
|
-
return {
|
|
11
|
-
type: "initialize",
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
import { IAgenticaEventJson } from "../json/IAgenticaEventJson";
|
|
2
|
+
import { AgenticaEventBase } from "./AgenticaEventBase";
|
|
3
|
+
|
|
4
|
+
export class AgenticaInitializeEvent extends AgenticaEventBase<"initialize"> {
|
|
5
|
+
public constructor() {
|
|
6
|
+
super("initialize");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
public toJSON(): IAgenticaEventJson.IInitialize {
|
|
10
|
+
return {
|
|
11
|
+
type: "initialize",
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import OpenAI from "openai";
|
|
2
|
-
|
|
3
|
-
import { IAgenticaEventJson } from "../json/IAgenticaEventJson";
|
|
4
|
-
import { AgenticaEventBase } from "./AgenticaEventBase";
|
|
5
|
-
import { AgenticaEventSource } from "./AgenticaEventSource";
|
|
6
|
-
|
|
7
|
-
export class AgenticaRequestEvent extends AgenticaEventBase<"request"> {
|
|
8
|
-
public readonly source: AgenticaEventSource;
|
|
9
|
-
public readonly body: OpenAI.ChatCompletionCreateParamsStreaming;
|
|
10
|
-
public readonly options?: OpenAI.RequestOptions | undefined;
|
|
11
|
-
|
|
12
|
-
public constructor(props: AgenticaRequestEvent.IProps) {
|
|
13
|
-
super("request");
|
|
14
|
-
this.source = props.source;
|
|
15
|
-
this.body = props.body;
|
|
16
|
-
this.options = props.options;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public toJSON(): IAgenticaEventJson.IRequest {
|
|
20
|
-
return {
|
|
21
|
-
type: "request",
|
|
22
|
-
source: this.source,
|
|
23
|
-
body: this.body,
|
|
24
|
-
options: this.options,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export namespace AgenticaRequestEvent {
|
|
29
|
-
export interface IProps {
|
|
30
|
-
/**
|
|
31
|
-
* The source agent of the request.
|
|
32
|
-
*/
|
|
33
|
-
source: AgenticaEventSource;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Request body.
|
|
37
|
-
*/
|
|
38
|
-
body: OpenAI.ChatCompletionCreateParamsStreaming;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Options for the request.
|
|
42
|
-
*/
|
|
43
|
-
options?: OpenAI.RequestOptions | undefined;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
1
|
+
import OpenAI from "openai";
|
|
2
|
+
|
|
3
|
+
import { IAgenticaEventJson } from "../json/IAgenticaEventJson";
|
|
4
|
+
import { AgenticaEventBase } from "./AgenticaEventBase";
|
|
5
|
+
import { AgenticaEventSource } from "./AgenticaEventSource";
|
|
6
|
+
|
|
7
|
+
export class AgenticaRequestEvent extends AgenticaEventBase<"request"> {
|
|
8
|
+
public readonly source: AgenticaEventSource;
|
|
9
|
+
public readonly body: OpenAI.ChatCompletionCreateParamsStreaming;
|
|
10
|
+
public readonly options?: OpenAI.RequestOptions | undefined;
|
|
11
|
+
|
|
12
|
+
public constructor(props: AgenticaRequestEvent.IProps) {
|
|
13
|
+
super("request");
|
|
14
|
+
this.source = props.source;
|
|
15
|
+
this.body = props.body;
|
|
16
|
+
this.options = props.options;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public toJSON(): IAgenticaEventJson.IRequest {
|
|
20
|
+
return {
|
|
21
|
+
type: "request",
|
|
22
|
+
source: this.source,
|
|
23
|
+
body: this.body,
|
|
24
|
+
options: this.options,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export namespace AgenticaRequestEvent {
|
|
29
|
+
export interface IProps {
|
|
30
|
+
/**
|
|
31
|
+
* The source agent of the request.
|
|
32
|
+
*/
|
|
33
|
+
source: AgenticaEventSource;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Request body.
|
|
37
|
+
*/
|
|
38
|
+
body: OpenAI.ChatCompletionCreateParamsStreaming;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Options for the request.
|
|
42
|
+
*/
|
|
43
|
+
options?: OpenAI.RequestOptions | undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|