@agentica/core 0.10.4 → 0.11.1
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/lib/Agentica.d.ts +14 -14
- package/lib/Agentica.js +54 -31
- package/lib/Agentica.js.map +1 -1
- package/lib/chatgpt/ChatGptAgent.d.ts +3 -3
- package/lib/chatgpt/ChatGptAgent.js +1 -1
- package/lib/chatgpt/ChatGptAgent.js.map +1 -1
- package/lib/chatgpt/ChatGptCallFunctionAgent.d.ts +3 -3
- package/lib/chatgpt/ChatGptCallFunctionAgent.js +61 -63
- package/lib/chatgpt/ChatGptCallFunctionAgent.js.map +1 -1
- package/lib/chatgpt/ChatGptCancelFunctionAgent.d.ts +6 -6
- package/lib/chatgpt/ChatGptCancelFunctionAgent.js +28 -30
- package/lib/chatgpt/ChatGptCancelFunctionAgent.js.map +1 -1
- package/lib/chatgpt/ChatGptCompletionMessageUtil.d.ts +8 -0
- package/lib/chatgpt/ChatGptCompletionMessageUtil.js +536 -0
- package/lib/chatgpt/ChatGptCompletionMessageUtil.js.map +1 -0
- package/lib/chatgpt/ChatGptDescribeFunctionAgent.d.ts +4 -3
- package/lib/chatgpt/ChatGptDescribeFunctionAgent.js +56 -6
- package/lib/chatgpt/ChatGptDescribeFunctionAgent.js.map +1 -1
- package/lib/chatgpt/ChatGptHistoryDecoder.d.ts +2 -2
- package/lib/chatgpt/ChatGptHistoryDecoder.js +8 -8
- package/lib/chatgpt/ChatGptHistoryDecoder.js.map +1 -1
- package/lib/chatgpt/ChatGptInitializeFunctionAgent.d.ts +3 -3
- package/lib/chatgpt/ChatGptInitializeFunctionAgent.js +11 -5
- package/lib/chatgpt/ChatGptInitializeFunctionAgent.js.map +1 -1
- package/lib/chatgpt/ChatGptSelectFunctionAgent.d.ts +3 -3
- package/lib/chatgpt/ChatGptSelectFunctionAgent.js +39 -42
- package/lib/chatgpt/ChatGptSelectFunctionAgent.js.map +1 -1
- package/lib/chatgpt/ChatGptUsageAggregator.d.ts +6 -0
- package/lib/chatgpt/ChatGptUsageAggregator.js +48 -0
- package/lib/chatgpt/ChatGptUsageAggregator.js.map +1 -0
- package/lib/context/AgenticaCancelPrompt.d.ts +16 -0
- package/lib/context/AgenticaCancelPrompt.js +20 -0
- package/lib/context/AgenticaCancelPrompt.js.map +1 -0
- package/lib/context/AgenticaClassOperation.d.ts +8 -0
- package/lib/context/AgenticaClassOperation.js +11 -0
- package/lib/context/AgenticaClassOperation.js.map +1 -0
- package/lib/{structures/IAgenticaContext.d.ts → context/AgenticaContext.d.ts} +15 -14
- package/lib/{structures/IAgenticaPrompt.js → context/AgenticaContext.js} +1 -1
- package/lib/context/AgenticaContext.js.map +1 -0
- package/lib/context/AgenticaHttpOperation.d.ts +8 -0
- package/lib/context/AgenticaHttpOperation.js +11 -0
- package/lib/context/AgenticaHttpOperation.js.map +1 -0
- package/lib/context/AgenticaOperation.d.ts +46 -0
- package/lib/{structures/IAgenticaContext.js → context/AgenticaOperation.js} +1 -1
- package/lib/context/AgenticaOperation.js.map +1 -0
- package/lib/context/AgenticaOperationBase.d.ts +29 -0
- package/lib/context/AgenticaOperationBase.js +21 -0
- package/lib/context/AgenticaOperationBase.js.map +1 -0
- package/lib/{structures/IAgenticaOperationCollection.d.ts → context/AgenticaOperationCollection.d.ts} +6 -6
- package/lib/{structures/IAgenticaOperationSelection.js → context/AgenticaOperationCollection.js} +1 -1
- package/lib/context/AgenticaOperationCollection.js.map +1 -0
- package/lib/context/AgenticaOperationSelection.d.ts +15 -0
- package/lib/context/AgenticaOperationSelection.js +17 -0
- package/lib/context/AgenticaOperationSelection.js.map +1 -0
- package/lib/context/AgenticaTokenUsage.d.ts +82 -0
- package/lib/context/AgenticaTokenUsage.js +97 -0
- package/lib/context/AgenticaTokenUsage.js.map +1 -0
- package/lib/context/internal/AgenticaTokenUsageAggregator.d.ts +10 -0
- package/lib/{internal → context/internal}/AgenticaTokenUsageAggregator.js +0 -46
- package/lib/context/internal/AgenticaTokenUsageAggregator.js.map +1 -0
- package/lib/context/internal/__IChatCancelFunctionsApplication.js.map +1 -0
- package/lib/context/internal/__IChatFunctionReference.js.map +1 -0
- package/lib/context/internal/__IChatInitialApplication.js.map +1 -0
- package/lib/context/internal/__IChatSelectFunctionsApplication.js.map +1 -0
- package/lib/events/AgenticaCallEvent.d.ts +18 -0
- package/lib/events/AgenticaCallEvent.js +22 -0
- package/lib/events/AgenticaCallEvent.js.map +1 -0
- package/lib/events/AgenticaCancelEvent.d.ts +14 -0
- package/lib/events/AgenticaCancelEvent.js +18 -0
- package/lib/events/AgenticaCancelEvent.js.map +1 -0
- package/lib/events/AgenticaDescribeEvent.d.ts +27 -0
- package/lib/events/AgenticaDescribeEvent.js +40 -0
- package/lib/events/AgenticaDescribeEvent.js.map +1 -0
- package/lib/events/AgenticaEvent.d.ts +25 -0
- package/lib/{structures/IAgenticaEvent.js → events/AgenticaEvent.js} +1 -1
- package/lib/events/AgenticaEvent.js.map +1 -0
- package/lib/events/AgenticaEventBase.d.ts +4 -0
- package/lib/events/AgenticaEventBase.js +10 -0
- package/lib/events/AgenticaEventBase.js.map +1 -0
- package/lib/events/AgenticaEventSource.d.ts +1 -0
- package/lib/events/AgenticaEventSource.js +3 -0
- package/lib/events/AgenticaEventSource.js.map +1 -0
- package/lib/events/AgenticaExecuteEvent.d.ts +22 -0
- package/lib/events/AgenticaExecuteEvent.js +33 -0
- package/lib/events/AgenticaExecuteEvent.js.map +1 -0
- package/lib/events/AgenticaInitializeEvent.d.ts +6 -0
- package/lib/events/AgenticaInitializeEvent.js +16 -0
- package/lib/events/AgenticaInitializeEvent.js.map +1 -0
- package/lib/events/AgenticaRequestEvent.d.ts +27 -0
- package/lib/events/AgenticaRequestEvent.js +22 -0
- package/lib/events/AgenticaRequestEvent.js.map +1 -0
- package/lib/events/AgenticaResponseEvent.d.ts +35 -0
- package/lib/events/AgenticaResponseEvent.js +16 -0
- package/lib/events/AgenticaResponseEvent.js.map +1 -0
- package/lib/events/AgenticaSelectEvent.d.ts +16 -0
- package/lib/events/AgenticaSelectEvent.js +26 -0
- package/lib/events/AgenticaSelectEvent.js.map +1 -0
- package/lib/events/AgenticaTextEvent.d.ts +25 -0
- package/lib/events/AgenticaTextEvent.js +40 -0
- package/lib/events/AgenticaTextEvent.js.map +1 -0
- package/lib/index.d.ts +26 -8
- package/lib/index.js +29 -9
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +1391 -306
- package/lib/index.mjs.map +1 -1
- package/lib/internal/AgenticaOperationComposer.d.ts +2 -2
- package/lib/internal/AgenticaOperationComposer.js +12 -0
- package/lib/internal/AgenticaOperationComposer.js.map +1 -1
- package/lib/internal/ByteArrayUtil.d.ts +3 -0
- package/lib/internal/ByteArrayUtil.js +10 -0
- package/lib/internal/ByteArrayUtil.js.map +1 -0
- package/lib/internal/MPSCUtil.d.ts +21 -0
- package/lib/internal/MPSCUtil.js +84 -0
- package/lib/internal/MPSCUtil.js.map +1 -0
- package/lib/internal/StreamUtil.d.ts +6 -0
- package/lib/internal/StreamUtil.js +65 -0
- package/lib/internal/StreamUtil.js.map +1 -0
- package/lib/json/IAgenticaEventJson.d.ts +149 -0
- package/lib/{structures/IAgenticaOperation.js → json/IAgenticaEventJson.js} +1 -1
- package/lib/json/IAgenticaEventJson.js.map +1 -0
- package/lib/json/IAgenticaOperationJson.d.ts +33 -0
- package/lib/json/IAgenticaOperationJson.js +3 -0
- package/lib/json/IAgenticaOperationJson.js.map +1 -0
- package/lib/json/IAgenticaOperationSelectionJson.d.ts +18 -0
- package/lib/{structures/IAgenticaOperationCollection.js → json/IAgenticaOperationSelectionJson.js} +1 -1
- package/lib/json/IAgenticaOperationSelectionJson.js.map +1 -0
- package/lib/json/IAgenticaPromptJson.d.ts +111 -0
- package/lib/json/IAgenticaPromptJson.js +3 -0
- package/lib/json/IAgenticaPromptJson.js.map +1 -0
- package/lib/{structures/IAgenticaTokenUsage.d.ts → json/IAgenticaTokenUsageJson.d.ts} +10 -10
- package/lib/json/IAgenticaTokenUsageJson.js +3 -0
- package/lib/json/IAgenticaTokenUsageJson.js.map +1 -0
- package/lib/prompts/AgenticaCancelPrompt.d.ts +16 -0
- package/lib/prompts/AgenticaCancelPrompt.js +20 -0
- package/lib/prompts/AgenticaCancelPrompt.js.map +1 -0
- package/lib/prompts/AgenticaDescribePrompt.d.ts +24 -0
- package/lib/prompts/AgenticaDescribePrompt.js +20 -0
- package/lib/prompts/AgenticaDescribePrompt.js.map +1 -0
- package/lib/prompts/AgenticaExecutePrompt.d.ts +20 -0
- package/lib/prompts/AgenticaExecutePrompt.js +24 -0
- package/lib/prompts/AgenticaExecutePrompt.js.map +1 -0
- package/lib/prompts/AgenticaPrompt.d.ts +7 -0
- package/lib/{typings/AgenticaSource.js → prompts/AgenticaPrompt.js} +1 -1
- package/lib/prompts/AgenticaPrompt.js.map +1 -0
- package/lib/prompts/AgenticaPromptBase.d.ts +22 -0
- package/lib/prompts/AgenticaPromptBase.js +22 -0
- package/lib/prompts/AgenticaPromptBase.js.map +1 -0
- package/lib/prompts/AgenticaSelectPrompt.d.ts +16 -0
- package/lib/prompts/AgenticaSelectPrompt.js +20 -0
- package/lib/prompts/AgenticaSelectPrompt.js.map +1 -0
- package/lib/prompts/AgenticaTextPrompt.d.ts +14 -0
- package/lib/prompts/AgenticaTextPrompt.js +20 -0
- package/lib/prompts/AgenticaTextPrompt.js.map +1 -0
- package/lib/structures/IAgenticaConfig.d.ts +3 -3
- package/lib/structures/IAgenticaExecutor.d.ts +12 -11
- package/lib/structures/IAgenticaProps.d.ts +2 -3
- package/lib/structures/IAgenticaSystemPrompt.d.ts +12 -11
- package/lib/transformers/AgenticaEventTransformer.d.ts +45 -0
- package/lib/transformers/AgenticaEventTransformer.js +127 -0
- package/lib/transformers/AgenticaEventTransformer.js.map +1 -0
- package/lib/transformers/AgenticaPromptTransformer.d.ts +34 -0
- package/lib/transformers/AgenticaPromptTransformer.js +90 -0
- package/lib/transformers/AgenticaPromptTransformer.js.map +1 -0
- package/package.json +1 -1
- package/src/Agentica.ts +93 -63
- package/src/chatgpt/ChatGptAgent.ts +8 -7
- package/src/chatgpt/ChatGptCallFunctionAgent.ts +90 -88
- package/src/chatgpt/ChatGptCancelFunctionAgent.ts +51 -58
- package/src/chatgpt/ChatGptCompletionMessageUtil.ts +166 -0
- package/src/chatgpt/ChatGptDescribeFunctionAgent.ts +81 -12
- package/src/chatgpt/ChatGptHistoryDecoder.ts +14 -14
- package/src/chatgpt/ChatGptInitializeFunctionAgent.ts +21 -13
- package/src/chatgpt/ChatGptSelectFunctionAgent.ts +66 -74
- package/src/chatgpt/ChatGptUsageAggregator.ts +62 -0
- package/src/context/AgenticaCancelPrompt.ts +32 -0
- package/src/context/AgenticaClassOperation.ts +23 -0
- package/src/{structures/IAgenticaContext.ts → context/AgenticaContext.ts} +17 -16
- package/src/context/AgenticaHttpOperation.ts +27 -0
- package/src/{structures/IAgenticaOperation.ts → context/AgenticaOperation.ts} +25 -22
- package/src/context/AgenticaOperationBase.ts +57 -0
- package/src/{structures/IAgenticaOperationCollection.ts → context/AgenticaOperationCollection.ts} +6 -6
- package/src/context/AgenticaOperationSelection.ts +27 -0
- package/src/context/AgenticaTokenUsage.ts +170 -0
- package/src/context/internal/AgenticaTokenUsageAggregator.ts +66 -0
- package/src/events/AgenticaCallEvent.ts +36 -0
- package/src/events/AgenticaCancelEvent.ts +28 -0
- package/src/events/AgenticaDescribeEvent.ts +61 -0
- package/src/events/AgenticaEvent.ts +36 -0
- package/src/events/AgenticaEventBase.ts +7 -0
- package/src/{typings/AgenticaSource.ts → events/AgenticaEventSource.ts} +1 -1
- package/src/events/AgenticaExecuteEvent.ts +50 -0
- package/src/events/AgenticaInitializeEvent.ts +14 -0
- package/src/events/AgenticaRequestEvent.ts +45 -0
- package/src/events/AgenticaResponseEvent.ts +48 -0
- package/src/events/AgenticaSelectEvent.ts +37 -0
- package/src/events/AgenticaTextEvent.ts +57 -0
- package/src/index.ts +33 -9
- package/src/internal/AgenticaOperationComposer.ts +24 -15
- package/src/internal/ByteArrayUtil.ts +5 -0
- package/src/internal/MPSCUtil.ts +75 -0
- package/src/internal/StreamUtil.ts +64 -0
- package/src/json/IAgenticaEventJson.ts +178 -0
- package/src/json/IAgenticaOperationJson.ts +36 -0
- package/src/json/IAgenticaOperationSelectionJson.ts +19 -0
- package/src/json/IAgenticaPromptJson.ts +130 -0
- package/src/{structures/IAgenticaTokenUsage.ts → json/IAgenticaTokenUsageJson.ts} +10 -10
- package/src/prompts/AgenticaCancelPrompt.ts +32 -0
- package/src/prompts/AgenticaDescribePrompt.ts +41 -0
- package/src/prompts/AgenticaExecutePrompt.ts +52 -0
- package/src/prompts/AgenticaPrompt.ts +14 -0
- package/src/prompts/AgenticaPromptBase.ts +27 -0
- package/src/prompts/AgenticaSelectPrompt.ts +32 -0
- package/src/prompts/AgenticaTextPrompt.ts +31 -0
- package/src/structures/IAgenticaConfig.ts +3 -3
- package/src/structures/IAgenticaExecutor.ts +14 -13
- package/src/structures/IAgenticaProps.ts +2 -3
- package/src/structures/IAgenticaSystemPrompt.ts +12 -11
- package/src/transformers/AgenticaEventTransformer.ts +165 -0
- package/src/transformers/AgenticaPromptTransformer.ts +134 -0
- package/lib/internal/AgenticaPromptFactory.d.ts +0 -7
- package/lib/internal/AgenticaPromptFactory.js +0 -9
- package/lib/internal/AgenticaPromptFactory.js.map +0 -1
- package/lib/internal/AgenticaPromptTransformer.d.ts +0 -10
- package/lib/internal/AgenticaPromptTransformer.js +0 -58
- package/lib/internal/AgenticaPromptTransformer.js.map +0 -1
- package/lib/internal/AgenticaTokenUsageAggregator.d.ts +0 -11
- package/lib/internal/AgenticaTokenUsageAggregator.js.map +0 -1
- package/lib/structures/IAgenticaContext.js.map +0 -1
- package/lib/structures/IAgenticaEvent.d.ts +0 -192
- package/lib/structures/IAgenticaEvent.js.map +0 -1
- package/lib/structures/IAgenticaOperation.d.ts +0 -47
- package/lib/structures/IAgenticaOperation.js.map +0 -1
- package/lib/structures/IAgenticaOperationCollection.js.map +0 -1
- package/lib/structures/IAgenticaOperationSelection.d.ts +0 -50
- package/lib/structures/IAgenticaOperationSelection.js.map +0 -1
- package/lib/structures/IAgenticaPrompt.d.ts +0 -138
- package/lib/structures/IAgenticaPrompt.js.map +0 -1
- package/lib/structures/IAgenticaTokenUsage.js +0 -3
- package/lib/structures/IAgenticaTokenUsage.js.map +0 -1
- package/lib/structures/internal/__IChatCancelFunctionsApplication.js.map +0 -1
- package/lib/structures/internal/__IChatFunctionReference.js.map +0 -1
- package/lib/structures/internal/__IChatInitialApplication.js.map +0 -1
- package/lib/structures/internal/__IChatSelectFunctionsApplication.js.map +0 -1
- package/lib/typings/AgenticaSource.d.ts +0 -1
- package/lib/typings/AgenticaSource.js.map +0 -1
- package/src/internal/AgenticaPromptFactory.ts +0 -32
- package/src/internal/AgenticaPromptTransformer.ts +0 -86
- package/src/internal/AgenticaTokenUsageAggregator.ts +0 -121
- package/src/structures/IAgenticaEvent.ts +0 -229
- package/src/structures/IAgenticaOperationSelection.ts +0 -68
- package/src/structures/IAgenticaPrompt.ts +0 -182
- /package/lib/{structures → context}/internal/__IChatCancelFunctionsApplication.d.ts +0 -0
- /package/lib/{structures → context}/internal/__IChatCancelFunctionsApplication.js +0 -0
- /package/lib/{structures → context}/internal/__IChatFunctionReference.d.ts +0 -0
- /package/lib/{structures → context}/internal/__IChatFunctionReference.js +0 -0
- /package/lib/{structures → context}/internal/__IChatInitialApplication.d.ts +0 -0
- /package/lib/{structures → context}/internal/__IChatInitialApplication.js +0 -0
- /package/lib/{structures → context}/internal/__IChatSelectFunctionsApplication.d.ts +0 -0
- /package/lib/{structures → context}/internal/__IChatSelectFunctionsApplication.js +0 -0
- /package/src/{structures → context}/internal/__IChatCancelFunctionsApplication.ts +0 -0
- /package/src/{structures → context}/internal/__IChatFunctionReference.ts +0 -0
- /package/src/{structures → context}/internal/__IChatInitialApplication.ts +0 -0
- /package/src/{structures → context}/internal/__IChatSelectFunctionsApplication.ts +0 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
|
|
3
|
+
import { AgenticaOperation } from "../context/AgenticaOperation";
|
|
4
|
+
import { AgenticaOperationSelection } from "../context/AgenticaOperationSelection";
|
|
5
|
+
import { AgenticaCallEvent } from "../events/AgenticaCallEvent";
|
|
6
|
+
import { AgenticaCancelEvent } from "../events/AgenticaCancelEvent";
|
|
7
|
+
import { AgenticaDescribeEvent } from "../events/AgenticaDescribeEvent";
|
|
8
|
+
import { AgenticaEvent } from "../events/AgenticaEvent";
|
|
9
|
+
import { AgenticaExecuteEvent } from "../events/AgenticaExecuteEvent";
|
|
10
|
+
import { AgenticaInitializeEvent } from "../events/AgenticaInitializeEvent";
|
|
11
|
+
import { AgenticaRequestEvent } from "../events/AgenticaRequestEvent";
|
|
12
|
+
import { AgenticaSelectEvent } from "../events/AgenticaSelectEvent";
|
|
13
|
+
import { AgenticaTextEvent } from "../events/AgenticaTextEvent";
|
|
14
|
+
import { StreamUtil } from "../internal/StreamUtil";
|
|
15
|
+
import { IAgenticaEventJson } from "../json/IAgenticaEventJson";
|
|
16
|
+
|
|
17
|
+
export namespace AgenticaEventTransformer {
|
|
18
|
+
export const transform = <Model extends ILlmSchema.Model>(props: {
|
|
19
|
+
operations: Map<string, Map<string, AgenticaOperation<Model>>>;
|
|
20
|
+
event: IAgenticaEventJson;
|
|
21
|
+
}): AgenticaEvent<Model> => {
|
|
22
|
+
if (props.event.type === "call")
|
|
23
|
+
return transformCall({
|
|
24
|
+
operations: props.operations,
|
|
25
|
+
event: props.event,
|
|
26
|
+
});
|
|
27
|
+
else if (props.event.type === "cancel")
|
|
28
|
+
return transformCancel({
|
|
29
|
+
operations: props.operations,
|
|
30
|
+
event: props.event,
|
|
31
|
+
});
|
|
32
|
+
else if (props.event.type === "describe")
|
|
33
|
+
return transformDescribe({
|
|
34
|
+
operations: props.operations,
|
|
35
|
+
event: props.event,
|
|
36
|
+
});
|
|
37
|
+
else if (props.event.type === "execute")
|
|
38
|
+
return transformExecute({
|
|
39
|
+
operations: props.operations,
|
|
40
|
+
event: props.event,
|
|
41
|
+
});
|
|
42
|
+
else if (props.event.type === "initialize") return transformInitialize();
|
|
43
|
+
else if (props.event.type === "request")
|
|
44
|
+
return transformRequest({
|
|
45
|
+
event: props.event,
|
|
46
|
+
});
|
|
47
|
+
else if (props.event.type === "select")
|
|
48
|
+
return transformSelect({
|
|
49
|
+
operations: props.operations,
|
|
50
|
+
event: props.event,
|
|
51
|
+
});
|
|
52
|
+
else if (props.event.type === "text")
|
|
53
|
+
return transformText({
|
|
54
|
+
event: props.event,
|
|
55
|
+
});
|
|
56
|
+
else throw new Error("Unknown event type");
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const transformCall = <Model extends ILlmSchema.Model>(props: {
|
|
60
|
+
operations: Map<string, Map<string, AgenticaOperation<Model>>>;
|
|
61
|
+
event: IAgenticaEventJson.ICall;
|
|
62
|
+
}): AgenticaCallEvent<Model> =>
|
|
63
|
+
new AgenticaCallEvent({
|
|
64
|
+
id: props.event.id,
|
|
65
|
+
operation: findOperation({
|
|
66
|
+
operations: props.operations,
|
|
67
|
+
input: props.event.operation,
|
|
68
|
+
}),
|
|
69
|
+
arguments: props.event.arguments,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export const transformCancel = <Model extends ILlmSchema.Model>(props: {
|
|
73
|
+
operations: Map<string, Map<string, AgenticaOperation<Model>>>;
|
|
74
|
+
event: IAgenticaEventJson.ICancel;
|
|
75
|
+
}): AgenticaCancelEvent<Model> =>
|
|
76
|
+
new AgenticaCancelEvent({
|
|
77
|
+
selection: new AgenticaOperationSelection({
|
|
78
|
+
operation: findOperation({
|
|
79
|
+
operations: props.operations,
|
|
80
|
+
input: props.event.selection.operation,
|
|
81
|
+
}),
|
|
82
|
+
reason: props.event.selection.reason,
|
|
83
|
+
}),
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
export const transformDescribe = <Model extends ILlmSchema.Model>(props: {
|
|
87
|
+
operations: Map<string, Map<string, AgenticaOperation<Model>>>;
|
|
88
|
+
event: IAgenticaEventJson.IDescribe;
|
|
89
|
+
}): AgenticaDescribeEvent<Model> =>
|
|
90
|
+
new AgenticaDescribeEvent({
|
|
91
|
+
executes: props.event.executes.map((next) =>
|
|
92
|
+
transformExecute({
|
|
93
|
+
operations: props.operations,
|
|
94
|
+
event: next,
|
|
95
|
+
}),
|
|
96
|
+
),
|
|
97
|
+
stream: StreamUtil.to(props.event.text),
|
|
98
|
+
done: () => true,
|
|
99
|
+
get: () => props.event.text,
|
|
100
|
+
join: async () => props.event.text,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
export const transformExecute = <Model extends ILlmSchema.Model>(props: {
|
|
104
|
+
operations: Map<string, Map<string, AgenticaOperation<Model>>>;
|
|
105
|
+
event: IAgenticaEventJson.IExecute;
|
|
106
|
+
}): AgenticaExecuteEvent<Model> =>
|
|
107
|
+
new AgenticaExecuteEvent({
|
|
108
|
+
id: props.event.id,
|
|
109
|
+
operation: findOperation({
|
|
110
|
+
operations: props.operations,
|
|
111
|
+
input: props.event.operation,
|
|
112
|
+
}),
|
|
113
|
+
arguments: props.event.arguments,
|
|
114
|
+
value: props.event.value,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
export const transformInitialize = (): AgenticaInitializeEvent =>
|
|
118
|
+
new AgenticaInitializeEvent();
|
|
119
|
+
|
|
120
|
+
export const transformRequest = (props: {
|
|
121
|
+
event: IAgenticaEventJson.IRequest;
|
|
122
|
+
}): AgenticaRequestEvent => new AgenticaRequestEvent(props.event);
|
|
123
|
+
|
|
124
|
+
export const transformSelect = <Model extends ILlmSchema.Model>(props: {
|
|
125
|
+
operations: Map<string, Map<string, AgenticaOperation<Model>>>;
|
|
126
|
+
event: IAgenticaEventJson.ISelect;
|
|
127
|
+
}): AgenticaSelectEvent<Model> =>
|
|
128
|
+
new AgenticaSelectEvent({
|
|
129
|
+
selection: new AgenticaOperationSelection({
|
|
130
|
+
operation: findOperation({
|
|
131
|
+
operations: props.operations,
|
|
132
|
+
input: props.event.selection.operation,
|
|
133
|
+
}),
|
|
134
|
+
reason: props.event.selection.reason,
|
|
135
|
+
}),
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
export const transformText = (props: {
|
|
139
|
+
event: IAgenticaEventJson.IText;
|
|
140
|
+
}): AgenticaTextEvent =>
|
|
141
|
+
new AgenticaTextEvent({
|
|
142
|
+
role: props.event.role,
|
|
143
|
+
stream: StreamUtil.to(props.event.text),
|
|
144
|
+
done: () => true,
|
|
145
|
+
get: () => props.event.text,
|
|
146
|
+
join: async () => props.event.text,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const findOperation = <Model extends ILlmSchema.Model>(props: {
|
|
151
|
+
operations: Map<string, Map<string, AgenticaOperation<Model>>>;
|
|
152
|
+
input: {
|
|
153
|
+
controller: string;
|
|
154
|
+
function: string;
|
|
155
|
+
};
|
|
156
|
+
}): AgenticaOperation<Model> => {
|
|
157
|
+
const found: AgenticaOperation<Model> | undefined = props.operations
|
|
158
|
+
.get(props.input.controller)
|
|
159
|
+
?.get(props.input.function);
|
|
160
|
+
if (found === undefined)
|
|
161
|
+
throw new Error(
|
|
162
|
+
`No operation found: (controller: ${props.input.controller}, function: ${props.input.function})`,
|
|
163
|
+
);
|
|
164
|
+
return found;
|
|
165
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
+
|
|
3
|
+
import { AgenticaOperation } from "../context/AgenticaOperation";
|
|
4
|
+
import { AgenticaOperationSelection } from "../context/AgenticaOperationSelection";
|
|
5
|
+
import { IAgenticaPromptJson } from "../json/IAgenticaPromptJson";
|
|
6
|
+
import { AgenticaCancelPrompt } from "../prompts/AgenticaCancelPrompt";
|
|
7
|
+
import { AgenticaDescribePrompt } from "../prompts/AgenticaDescribePrompt";
|
|
8
|
+
import { AgenticaExecutePrompt } from "../prompts/AgenticaExecutePrompt";
|
|
9
|
+
import { AgenticaPrompt } from "../prompts/AgenticaPrompt";
|
|
10
|
+
import { AgenticaSelectPrompt } from "../prompts/AgenticaSelectPrompt";
|
|
11
|
+
import { AgenticaTextPrompt } from "../prompts/AgenticaTextPrompt";
|
|
12
|
+
|
|
13
|
+
export namespace AgenticaPromptTransformer {
|
|
14
|
+
export const transform = <Model extends ILlmSchema.Model>(props: {
|
|
15
|
+
operations: Map<string, Map<string, AgenticaOperation<Model>>>;
|
|
16
|
+
prompt: IAgenticaPromptJson;
|
|
17
|
+
}): AgenticaPrompt<Model> => {
|
|
18
|
+
// TEXT
|
|
19
|
+
if (props.prompt.type === "text")
|
|
20
|
+
return transformText({
|
|
21
|
+
prompt: props.prompt,
|
|
22
|
+
});
|
|
23
|
+
// SELECT & CANCEL
|
|
24
|
+
else if (props.prompt.type === "select")
|
|
25
|
+
return transformSelect({
|
|
26
|
+
operations: props.operations,
|
|
27
|
+
prompt: props.prompt,
|
|
28
|
+
});
|
|
29
|
+
else if (props.prompt.type === "cancel")
|
|
30
|
+
return transformCancel({
|
|
31
|
+
operations: props.operations,
|
|
32
|
+
prompt: props.prompt,
|
|
33
|
+
});
|
|
34
|
+
// EXECUTE
|
|
35
|
+
else if (props.prompt.type === "execute")
|
|
36
|
+
return transformExecute({
|
|
37
|
+
operations: props.operations,
|
|
38
|
+
prompt: props.prompt,
|
|
39
|
+
});
|
|
40
|
+
else if (props.prompt.type === "describe")
|
|
41
|
+
return transformDescribe({
|
|
42
|
+
operations: props.operations,
|
|
43
|
+
prompt: props.prompt,
|
|
44
|
+
});
|
|
45
|
+
throw new Error("Invalid prompt type.");
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const transformText = (props: {
|
|
49
|
+
prompt: IAgenticaPromptJson.IText;
|
|
50
|
+
}): AgenticaTextPrompt => {
|
|
51
|
+
return new AgenticaTextPrompt(props.prompt);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const transformSelect = <Model extends ILlmSchema.Model>(props: {
|
|
55
|
+
operations: Map<string, Map<string, AgenticaOperation<Model>>>;
|
|
56
|
+
prompt: IAgenticaPromptJson.ISelect;
|
|
57
|
+
}): AgenticaSelectPrompt<Model> =>
|
|
58
|
+
new AgenticaSelectPrompt({
|
|
59
|
+
id: props.prompt.id,
|
|
60
|
+
selections: props.prompt.selections.map(
|
|
61
|
+
(select) =>
|
|
62
|
+
new AgenticaOperationSelection({
|
|
63
|
+
operation: findOperation({
|
|
64
|
+
operations: props.operations,
|
|
65
|
+
input: select.operation,
|
|
66
|
+
}),
|
|
67
|
+
reason: select.reason,
|
|
68
|
+
}),
|
|
69
|
+
),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export const transformCancel = <Model extends ILlmSchema.Model>(props: {
|
|
73
|
+
operations: Map<string, Map<string, AgenticaOperation<Model>>>;
|
|
74
|
+
prompt: IAgenticaPromptJson.ICancel;
|
|
75
|
+
}): AgenticaCancelPrompt<Model> =>
|
|
76
|
+
new AgenticaCancelPrompt({
|
|
77
|
+
id: props.prompt.id,
|
|
78
|
+
selections: props.prompt.selections.map(
|
|
79
|
+
(select) =>
|
|
80
|
+
new AgenticaOperationSelection({
|
|
81
|
+
operation: findOperation({
|
|
82
|
+
operations: props.operations,
|
|
83
|
+
input: select.operation,
|
|
84
|
+
}),
|
|
85
|
+
reason: select.reason,
|
|
86
|
+
}),
|
|
87
|
+
),
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
export const transformExecute = <Model extends ILlmSchema.Model>(props: {
|
|
91
|
+
operations: Map<string, Map<string, AgenticaOperation<Model>>>;
|
|
92
|
+
prompt: IAgenticaPromptJson.IExecute;
|
|
93
|
+
}): AgenticaExecutePrompt<Model> =>
|
|
94
|
+
new AgenticaExecutePrompt({
|
|
95
|
+
id: props.prompt.id,
|
|
96
|
+
operation: findOperation({
|
|
97
|
+
operations: props.operations,
|
|
98
|
+
input: props.prompt.operation,
|
|
99
|
+
}),
|
|
100
|
+
arguments: props.prompt.arguments,
|
|
101
|
+
value: props.prompt.value,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
export const transformDescribe = <Model extends ILlmSchema.Model>(props: {
|
|
105
|
+
operations: Map<string, Map<string, AgenticaOperation<Model>>>;
|
|
106
|
+
prompt: IAgenticaPromptJson.IDescribe;
|
|
107
|
+
}): AgenticaDescribePrompt<Model> =>
|
|
108
|
+
new AgenticaDescribePrompt({
|
|
109
|
+
text: props.prompt.text,
|
|
110
|
+
executes: props.prompt.executions.map((next) =>
|
|
111
|
+
transformExecute({
|
|
112
|
+
operations: props.operations,
|
|
113
|
+
prompt: next,
|
|
114
|
+
}),
|
|
115
|
+
),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const findOperation = <Model extends ILlmSchema.Model>(props: {
|
|
120
|
+
operations: Map<string, Map<string, AgenticaOperation<Model>>>;
|
|
121
|
+
input: {
|
|
122
|
+
controller: string;
|
|
123
|
+
function: string;
|
|
124
|
+
};
|
|
125
|
+
}): AgenticaOperation<Model> => {
|
|
126
|
+
const found: AgenticaOperation<Model> | undefined = props.operations
|
|
127
|
+
.get(props.input.controller)
|
|
128
|
+
?.get(props.input.function);
|
|
129
|
+
if (found === undefined)
|
|
130
|
+
throw new Error(
|
|
131
|
+
`No operation found: (controller: ${props.input.controller}, function: ${props.input.function})`,
|
|
132
|
+
);
|
|
133
|
+
return found;
|
|
134
|
+
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
import { IAgenticaOperationSelection } from "../structures/IAgenticaOperationSelection";
|
|
3
|
-
import { IAgenticaPrompt } from "../structures/IAgenticaPrompt";
|
|
4
|
-
export declare namespace AgenticaPromptFactory {
|
|
5
|
-
const execute: <Model extends ILlmSchema.Model>(props: Omit<IAgenticaPrompt.IExecute<Model>, "toJSON">) => IAgenticaPrompt.IExecute<Model>;
|
|
6
|
-
const selection: <Model extends ILlmSchema.Model>(props: Omit<IAgenticaOperationSelection<Model>, "toJSON">) => IAgenticaOperationSelection<Model>;
|
|
7
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AgenticaPromptFactory = void 0;
|
|
4
|
-
var AgenticaPromptFactory;
|
|
5
|
-
(function (AgenticaPromptFactory) {
|
|
6
|
-
AgenticaPromptFactory.execute = (props) => (Object.assign(Object.assign({}, props), { toJSON: () => (Object.assign(Object.assign({}, props), { controller: props.controller.name, function: props.function.name })) }));
|
|
7
|
-
AgenticaPromptFactory.selection = (props) => (Object.assign(Object.assign({}, props), { toJSON: () => (Object.assign(Object.assign({}, props), { controller: props.controller.name, function: props.function.name })) }));
|
|
8
|
-
})(AgenticaPromptFactory || (exports.AgenticaPromptFactory = AgenticaPromptFactory = {}));
|
|
9
|
-
//# sourceMappingURL=AgenticaPromptFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AgenticaPromptFactory.js","sourceRoot":"","sources":["../../src/internal/AgenticaPromptFactory.ts"],"names":[],"mappings":";;;AAKA,IAAiB,qBAAqB,CA0BrC;AA1BD,WAAiB,qBAAqB;IACvB,6BAAO,GAAG,CACrB,KAAsD,EACrB,EAAE,CACnC,iCACK,KAAK,KACR,MAAM,EAAE,GAAG,EAAE,CACX,iCACK,KAAK,KACR,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,IAAI,EACjC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI,IACtB,IACwB,CAAC;IAE3B,+BAAS,GAAG,CACvB,KAAyD,EACrB,EAAE,CACtC,iCACK,KAAK,KACR,MAAM,EAAE,GAAG,EAAE,CACX,iCACK,KAAK,KACR,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,IAAI,EACjC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI,IACtB,IAC2B,CAAC;AAC7C,CAAC,EA1BgB,qBAAqB,qCAArB,qBAAqB,QA0BrC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
import { Primitive } from "typia";
|
|
3
|
-
import { IAgenticaOperation } from "../structures/IAgenticaOperation";
|
|
4
|
-
import { IAgenticaPrompt } from "../structures/IAgenticaPrompt";
|
|
5
|
-
export declare namespace AgenticaPromptTransformer {
|
|
6
|
-
const transform: <Model extends ILlmSchema.Model>(props: {
|
|
7
|
-
operations: Map<string, Map<string, IAgenticaOperation<Model>>>;
|
|
8
|
-
input: Primitive<IAgenticaPrompt<Model>>;
|
|
9
|
-
}) => IAgenticaPrompt<Model>;
|
|
10
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AgenticaPromptTransformer = void 0;
|
|
4
|
-
const AgenticaPromptFactory_1 = require("./AgenticaPromptFactory");
|
|
5
|
-
var AgenticaPromptTransformer;
|
|
6
|
-
(function (AgenticaPromptTransformer) {
|
|
7
|
-
AgenticaPromptTransformer.transform = (props) => {
|
|
8
|
-
// TEXT
|
|
9
|
-
if (props.input.type === "text")
|
|
10
|
-
return props.input;
|
|
11
|
-
// SELECT & CANCEL
|
|
12
|
-
else if (props.input.type === "select" || props.input.type === "cancel")
|
|
13
|
-
return Object.assign(Object.assign({}, props.input), { operations: props.input.operations.map((func) => AgenticaPromptFactory_1.AgenticaPromptFactory.selection(Object.assign(Object.assign({}, findOperation({
|
|
14
|
-
operations: props.operations,
|
|
15
|
-
input: func,
|
|
16
|
-
})), { reason: func.reason }))) });
|
|
17
|
-
// EXECUTE
|
|
18
|
-
else if (props.input.type === "execute")
|
|
19
|
-
return transformExecute({
|
|
20
|
-
operations: props.operations,
|
|
21
|
-
input: props.input,
|
|
22
|
-
});
|
|
23
|
-
// DESCRIBE
|
|
24
|
-
return {
|
|
25
|
-
type: "describe",
|
|
26
|
-
text: props.input.text,
|
|
27
|
-
executions: props.input.executions.map((next) => transformExecute({
|
|
28
|
-
operations: props.operations,
|
|
29
|
-
input: next,
|
|
30
|
-
})),
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
const transformExecute = (props) => {
|
|
34
|
-
const operation = findOperation({
|
|
35
|
-
operations: props.operations,
|
|
36
|
-
input: props.input,
|
|
37
|
-
});
|
|
38
|
-
return AgenticaPromptFactory_1.AgenticaPromptFactory.execute({
|
|
39
|
-
type: "execute",
|
|
40
|
-
protocol: operation.protocol,
|
|
41
|
-
controller: operation.controller,
|
|
42
|
-
function: operation.function,
|
|
43
|
-
id: props.input.id,
|
|
44
|
-
name: props.input.name,
|
|
45
|
-
arguments: props.input.arguments,
|
|
46
|
-
value: props.input.value,
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
const findOperation = (props) => {
|
|
50
|
-
var _a;
|
|
51
|
-
const found = (_a = props.operations
|
|
52
|
-
.get(props.input.controller)) === null || _a === void 0 ? void 0 : _a.get(props.input.function);
|
|
53
|
-
if (found === undefined)
|
|
54
|
-
throw new Error(`No operation found: (controller: ${props.input.controller}, function: ${props.input.function})`);
|
|
55
|
-
return found;
|
|
56
|
-
};
|
|
57
|
-
})(AgenticaPromptTransformer || (exports.AgenticaPromptTransformer = AgenticaPromptTransformer = {}));
|
|
58
|
-
//# sourceMappingURL=AgenticaPromptTransformer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AgenticaPromptTransformer.js","sourceRoot":"","sources":["../../src/internal/AgenticaPromptTransformer.ts"],"names":[],"mappings":";;;AAKA,mEAAgE;AAEhE,IAAiB,yBAAyB,CA8EzC;AA9ED,WAAiB,yBAAyB;IAC3B,mCAAS,GAAG,CAAiC,KAGzD,EAA0B,EAAE;QAC3B,OAAO;QACP,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM;YAAE,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C,QAAkB;YACtC,UAAU,EAAE,SAAS,CAAC,UAAU;YAChC,QAAQ,EAAE,SAAS,CAAC,QAAQ;YAC5B,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE;YAClB,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI;YACtB,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS;YAChC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK;SACzB,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,CAAiC,KAMtD,EAAmC,EAAE;;QACpC,MAAM,KAAK,GAA0C,MAAA,KAAK,CAAC,UAAU;aAClE,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,0CAC1B,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC9B,IAAI,KAAK,KAAK,SAAS;YACrB,MAAM,IAAI,KAAK,CACb,oCAAoC,KAAK,CAAC,KAAK,CAAC,UAAU,eAAe,KAAK,CAAC,KAAK,CAAC,QAAQ,GAAG,CACjG,CAAC;QACJ,OAAO,KAAwC,CAAC;IAClD,CAAC,CAAC;AACJ,CAAC,EA9EgB,yBAAyB,yCAAzB,yBAAyB,QA8EzC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { CompletionUsage } from "openai/resources";
|
|
2
|
-
import { IAgenticaTokenUsage } from "../structures/IAgenticaTokenUsage";
|
|
3
|
-
export declare namespace AgenticaTokenUsageAggregator {
|
|
4
|
-
const aggregate: (props: {
|
|
5
|
-
kind: Exclude<keyof IAgenticaTokenUsage, "aggregate">;
|
|
6
|
-
completionUsage: CompletionUsage;
|
|
7
|
-
usage: IAgenticaTokenUsage;
|
|
8
|
-
}) => void;
|
|
9
|
-
const plus: (x: IAgenticaTokenUsage, y: IAgenticaTokenUsage) => IAgenticaTokenUsage;
|
|
10
|
-
const zero: () => IAgenticaTokenUsage;
|
|
11
|
-
}
|
|
@@ -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AC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;YACrC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;YAC/B,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC;SAC5C,CAAC;IACJ,CAAC,CAAC;IAEW,iCAAI,GAAG,GAAwB,EAAE;QAC5C,MAAM,SAAS,GAAG,GAAmC,EAAE,CAAC,CAAC;YACvD,KAAK,EAAE,CAAC;YACR,KAAK,EAAE;gBACL,KAAK,EAAE,CAAC;gBACR,MAAM,EAAE,CAAC;aACV;YACD,MAAM,EAAE;gBACN,KAAK,EAAE,CAAC;gBACR,SAAS,EAAE,CAAC;gBACZ,mBAAmB,EAAE,CAAC;gBACtB,mBAAmB,EAAE,CAAC;aACvB;SACF,CAAC,CAAC;QACH,OAAO;YACL,SAAS,EAAE,SAAS,EAAE;YACtB,UAAU,EAAE,SAAS,EAAE;YACvB,MAAM,EAAE,SAAS,EAAE;YACnB,MAAM,EAAE,SAAS,EAAE;YACnB,IAAI,EAAE,SAAS,EAAE;YACjB,QAAQ,EAAE,SAAS,EAAE;SACtB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,EApHgB,4BAA4B,4CAA5B,4BAA4B,QAoH5C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IAgenticaContext.js","sourceRoot":"","sources":["../../src/structures/IAgenticaContext.ts"],"names":[],"mappings":""}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
import OpenAI from "openai";
|
|
3
|
-
import { AgenticaSource } from "../typings/AgenticaSource";
|
|
4
|
-
import { IAgenticaOperation } from "./IAgenticaOperation";
|
|
5
|
-
import { IAgenticaPrompt } from "./IAgenticaPrompt";
|
|
6
|
-
/**
|
|
7
|
-
* Nestia A.I. chatbot event.
|
|
8
|
-
*
|
|
9
|
-
* `IAgenticaEvent` is an union type of all possible events that can
|
|
10
|
-
* be emitted by the A.I. chatbot of the {@link Agentica} class. You
|
|
11
|
-
* can discriminate the subtype by checking the {@link type} property.
|
|
12
|
-
*
|
|
13
|
-
* @author Samchon
|
|
14
|
-
*/
|
|
15
|
-
export type IAgenticaEvent<Model extends ILlmSchema.Model> = IAgenticaEvent.IInitialize | IAgenticaEvent.ISelect<Model> | IAgenticaEvent.ICancel<Model> | IAgenticaEvent.ICall<Model> | IAgenticaEvent.IExecute<Model> | IAgenticaEvent.IDescribe<Model> | IAgenticaEvent.IText | IAgenticaEvent.IRequest | IAgenticaEvent.IResponse;
|
|
16
|
-
export declare namespace IAgenticaEvent {
|
|
17
|
-
export type Type = IAgenticaEvent<any>["type"];
|
|
18
|
-
export type Mapper<Model extends ILlmSchema.Model> = {
|
|
19
|
-
initialize: IInitialize;
|
|
20
|
-
select: ISelect<Model>;
|
|
21
|
-
cancel: ICancel<Model>;
|
|
22
|
-
call: ICall<Model>;
|
|
23
|
-
execute: IExecute<Model>;
|
|
24
|
-
describe: IDescribe<Model>;
|
|
25
|
-
text: IText;
|
|
26
|
-
request: IRequest;
|
|
27
|
-
response: IResponse;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Event of initializing the chatbot.
|
|
31
|
-
*/
|
|
32
|
-
export interface IInitialize extends IBase<"initialize"> {
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Event of selecting a function to call.
|
|
36
|
-
*/
|
|
37
|
-
export interface ISelect<Model extends ILlmSchema.Model> extends IBase<"select"> {
|
|
38
|
-
/**
|
|
39
|
-
* Selected operation.
|
|
40
|
-
*
|
|
41
|
-
* Operation that has been selected to prepare LLM function calling.
|
|
42
|
-
*/
|
|
43
|
-
operation: IAgenticaOperation<Model>;
|
|
44
|
-
/**
|
|
45
|
-
* Reason of selecting the function.
|
|
46
|
-
*
|
|
47
|
-
* The A.I. chatbot will fill this property describing why the function
|
|
48
|
-
* has been selected.
|
|
49
|
-
*/
|
|
50
|
-
reason: string;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Event of canceling a function calling.
|
|
54
|
-
*/
|
|
55
|
-
export interface ICancel<Model extends ILlmSchema.Model> extends IBase<"cancel"> {
|
|
56
|
-
/**
|
|
57
|
-
* Selected operation to cancel.
|
|
58
|
-
*
|
|
59
|
-
* Operation that has been selected to prepare LLM function calling,
|
|
60
|
-
* but canceled due to no more required.
|
|
61
|
-
*/
|
|
62
|
-
operation: IAgenticaOperation<Model>;
|
|
63
|
-
/**
|
|
64
|
-
* Reason of selecting the function.
|
|
65
|
-
*
|
|
66
|
-
* The A.I. chatbot will fill this property describing why the function
|
|
67
|
-
* has been cancelled.
|
|
68
|
-
*
|
|
69
|
-
* For reference, if the A.I. chatbot successfully completes the LLM
|
|
70
|
-
* function calling, the reason of the function cancellation will be
|
|
71
|
-
* "complete".
|
|
72
|
-
*/
|
|
73
|
-
reason: string;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Event of calling a function.
|
|
77
|
-
*/
|
|
78
|
-
export interface ICall<Model extends ILlmSchema.Model> extends IBase<"call"> {
|
|
79
|
-
/**
|
|
80
|
-
* ID of the tool calling.
|
|
81
|
-
*/
|
|
82
|
-
id: string;
|
|
83
|
-
/**
|
|
84
|
-
* Target operation to call.
|
|
85
|
-
*/
|
|
86
|
-
operation: IAgenticaOperation<Model>;
|
|
87
|
-
/**
|
|
88
|
-
* Arguments of the function calling.
|
|
89
|
-
*
|
|
90
|
-
* If you modify this {@link arguments} property, it actually modifies
|
|
91
|
-
* the backend server's request. Therefore, be careful when you're
|
|
92
|
-
* trying to modify this property.
|
|
93
|
-
*/
|
|
94
|
-
arguments: object;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Event of function calling execution.
|
|
98
|
-
*/
|
|
99
|
-
export interface IExecute<Model extends ILlmSchema.Model> extends IBase<"execute"> {
|
|
100
|
-
/**
|
|
101
|
-
* ID of the tool calling.
|
|
102
|
-
*/
|
|
103
|
-
id: string;
|
|
104
|
-
/**
|
|
105
|
-
* Target operation had called.
|
|
106
|
-
*/
|
|
107
|
-
operation: IAgenticaOperation<Model>;
|
|
108
|
-
/**
|
|
109
|
-
* Arguments of the function calling.
|
|
110
|
-
*/
|
|
111
|
-
arguments: object;
|
|
112
|
-
/**
|
|
113
|
-
* Return value.
|
|
114
|
-
*/
|
|
115
|
-
value: any;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Event of description.
|
|
119
|
-
*
|
|
120
|
-
* Event describing return values of LLM function callings.
|
|
121
|
-
*/
|
|
122
|
-
export interface IDescribe<Model extends ILlmSchema.Model> extends IBase<"describe"> {
|
|
123
|
-
/**
|
|
124
|
-
* Executions of the LLM function calling.
|
|
125
|
-
*
|
|
126
|
-
* This prompt describes the return value of them.
|
|
127
|
-
*/
|
|
128
|
-
executions: IAgenticaPrompt.IExecute<Model>[];
|
|
129
|
-
/**
|
|
130
|
-
* Description text.
|
|
131
|
-
*/
|
|
132
|
-
text: string;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Event of text message.
|
|
136
|
-
*/
|
|
137
|
-
export interface IText extends IBase<"text"> {
|
|
138
|
-
/**
|
|
139
|
-
* Role of the orator.
|
|
140
|
-
*/
|
|
141
|
-
role: "assistant" | "user";
|
|
142
|
-
/**
|
|
143
|
-
* The text content.
|
|
144
|
-
*/
|
|
145
|
-
text: string;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Request event of LLM vendor API.
|
|
149
|
-
*/
|
|
150
|
-
export interface IRequest extends IBase<"request"> {
|
|
151
|
-
/**
|
|
152
|
-
* The source agent of the request.
|
|
153
|
-
*/
|
|
154
|
-
source: AgenticaSource;
|
|
155
|
-
/**
|
|
156
|
-
* Request body.
|
|
157
|
-
*/
|
|
158
|
-
body: OpenAI.ChatCompletionCreateParamsNonStreaming;
|
|
159
|
-
/**
|
|
160
|
-
* Options for the request.
|
|
161
|
-
*/
|
|
162
|
-
options?: OpenAI.RequestOptions | undefined;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Response event of LLM vendor API.
|
|
166
|
-
*/
|
|
167
|
-
export interface IResponse extends IBase<"response"> {
|
|
168
|
-
/**
|
|
169
|
-
* The source agent of the response.
|
|
170
|
-
*/
|
|
171
|
-
source: AgenticaSource;
|
|
172
|
-
/**
|
|
173
|
-
* Request body.
|
|
174
|
-
*/
|
|
175
|
-
body: OpenAI.ChatCompletionCreateParamsNonStreaming;
|
|
176
|
-
/**
|
|
177
|
-
* Options for the request.
|
|
178
|
-
*/
|
|
179
|
-
options?: OpenAI.RequestOptions | undefined;
|
|
180
|
-
/**
|
|
181
|
-
* Return value from the LLM vendor API.
|
|
182
|
-
*/
|
|
183
|
-
value: OpenAI.ChatCompletion;
|
|
184
|
-
}
|
|
185
|
-
interface IBase<Type extends string> {
|
|
186
|
-
/**
|
|
187
|
-
* Discriminator type.
|
|
188
|
-
*/
|
|
189
|
-
type: Type;
|
|
190
|
-
}
|
|
191
|
-
export {};
|
|
192
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IAgenticaEvent.js","sourceRoot":"","sources":["../../src/structures/IAgenticaEvent.ts"],"names":[],"mappings":""}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { IHttpLlmFunction, ILlmFunction, ILlmSchema } from "@samchon/openapi";
|
|
2
|
-
import { IAgenticaController } from "./IAgenticaController";
|
|
3
|
-
/**
|
|
4
|
-
* Operation information in the Nestia Agent.
|
|
5
|
-
*
|
|
6
|
-
* `IAgenticaOperation` is a type represents an operation that would
|
|
7
|
-
* be selected by the A.I. chatbot of {@link Agentica} class to
|
|
8
|
-
* perform the LLM (Large Language Model) function calling.
|
|
9
|
-
*
|
|
10
|
-
* Also, it is an union type that is discriminated by the {@link protocol}
|
|
11
|
-
* property. If the protocol value is `http`, it means that the HTTP API
|
|
12
|
-
* operation would be called by the A.I. chatbot. Otherwise, if the protocol
|
|
13
|
-
* value is `class`, it means that the operation has come from a
|
|
14
|
-
* TypeScript class.
|
|
15
|
-
*
|
|
16
|
-
* @author Samchon
|
|
17
|
-
*/
|
|
18
|
-
export type IAgenticaOperation<Model extends ILlmSchema.Model> = IAgenticaOperation.IHttp<Model> | IAgenticaOperation.IClass<Model>;
|
|
19
|
-
export declare namespace IAgenticaOperation {
|
|
20
|
-
/**
|
|
21
|
-
* HTTP API operation.
|
|
22
|
-
*/
|
|
23
|
-
export type IHttp<Model extends ILlmSchema.Model> = IBase<"http", IAgenticaController.IHttp<Model>, IHttpLlmFunction<Model>>;
|
|
24
|
-
/**
|
|
25
|
-
* TypeScript class operation.
|
|
26
|
-
*/
|
|
27
|
-
export type IClass<Model extends ILlmSchema.Model> = IBase<"class", IAgenticaController.IClass<Model>, ILlmFunction<Model>>;
|
|
28
|
-
interface IBase<Protocol, Application, Function> {
|
|
29
|
-
/**
|
|
30
|
-
* Protocol discriminator.
|
|
31
|
-
*/
|
|
32
|
-
protocol: Protocol;
|
|
33
|
-
/**
|
|
34
|
-
* Belonged controller of the target function.
|
|
35
|
-
*/
|
|
36
|
-
controller: Application;
|
|
37
|
-
/**
|
|
38
|
-
* Target function to call.
|
|
39
|
-
*/
|
|
40
|
-
function: Function;
|
|
41
|
-
/**
|
|
42
|
-
* Identifier name.
|
|
43
|
-
*/
|
|
44
|
-
name: string;
|
|
45
|
-
}
|
|
46
|
-
export {};
|
|
47
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IAgenticaOperation.js","sourceRoot":"","sources":["../../src/structures/IAgenticaOperation.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IAgenticaOperationCollection.js","sourceRoot":"","sources":["../../src/structures/IAgenticaOperationCollection.ts"],"names":[],"mappings":""}
|