@agentica/core 0.7.0-dev.20250224
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 -0
- package/README.md +464 -0
- package/lib/Agentica.d.ts +124 -0
- package/lib/Agentica.js +271 -0
- package/lib/Agentica.js.map +1 -0
- package/lib/chatgpt/ChatGptAgent.d.ts +6 -0
- package/lib/chatgpt/ChatGptAgent.js +59 -0
- package/lib/chatgpt/ChatGptAgent.js.map +1 -0
- package/lib/chatgpt/ChatGptCallFunctionAgent.d.ts +5 -0
- package/lib/chatgpt/ChatGptCallFunctionAgent.js +362 -0
- package/lib/chatgpt/ChatGptCallFunctionAgent.js.map +1 -0
- package/lib/chatgpt/ChatGptCancelFunctionAgent.d.ts +8 -0
- package/lib/chatgpt/ChatGptCancelFunctionAgent.js +359 -0
- package/lib/chatgpt/ChatGptCancelFunctionAgent.js.map +1 -0
- package/lib/chatgpt/ChatGptDescribeFunctionAgent.d.ts +5 -0
- package/lib/chatgpt/ChatGptDescribeFunctionAgent.js +56 -0
- package/lib/chatgpt/ChatGptDescribeFunctionAgent.js.map +1 -0
- package/lib/chatgpt/ChatGptHistoryDecoder.d.ts +5 -0
- package/lib/chatgpt/ChatGptHistoryDecoder.js +77 -0
- package/lib/chatgpt/ChatGptHistoryDecoder.js.map +1 -0
- package/lib/chatgpt/ChatGptInitializeFunctionAgent.d.ts +5 -0
- package/lib/chatgpt/ChatGptInitializeFunctionAgent.js +1883 -0
- package/lib/chatgpt/ChatGptInitializeFunctionAgent.js.map +1 -0
- package/lib/chatgpt/ChatGptSelectFunctionAgent.d.ts +5 -0
- package/lib/chatgpt/ChatGptSelectFunctionAgent.js +381 -0
- package/lib/chatgpt/ChatGptSelectFunctionAgent.js.map +1 -0
- package/lib/functional/createHttpLlmApplication.d.ts +33 -0
- package/lib/functional/createHttpLlmApplication.js +7766 -0
- package/lib/functional/createHttpLlmApplication.js.map +1 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +35 -0
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +10366 -0
- package/lib/index.mjs.map +1 -0
- package/lib/internal/AgenticaConstant.d.ts +4 -0
- package/lib/internal/AgenticaConstant.js +9 -0
- package/lib/internal/AgenticaConstant.js.map +1 -0
- package/lib/internal/AgenticaCostAggregator.d.ts +5 -0
- package/lib/internal/AgenticaCostAggregator.js +30 -0
- package/lib/internal/AgenticaCostAggregator.js.map +1 -0
- package/lib/internal/AgenticaDefaultPrompt.d.ts +4 -0
- package/lib/internal/AgenticaDefaultPrompt.js +32 -0
- package/lib/internal/AgenticaDefaultPrompt.js.map +1 -0
- package/lib/internal/AgenticaOperationComposer.d.ts +9 -0
- package/lib/internal/AgenticaOperationComposer.js +58 -0
- package/lib/internal/AgenticaOperationComposer.js.map +1 -0
- package/lib/internal/AgenticaPromptFactory.d.ts +6 -0
- package/lib/internal/AgenticaPromptFactory.js +9 -0
- package/lib/internal/AgenticaPromptFactory.js.map +1 -0
- package/lib/internal/AgenticaPromptTransformer.d.ts +9 -0
- package/lib/internal/AgenticaPromptTransformer.js +58 -0
- package/lib/internal/AgenticaPromptTransformer.js.map +1 -0
- package/lib/internal/AgenticaSystemPrompt.d.ts +8 -0
- package/lib/internal/AgenticaSystemPrompt.js +13 -0
- package/lib/internal/AgenticaSystemPrompt.js.map +1 -0
- package/lib/internal/MathUtil.d.ts +3 -0
- package/lib/internal/MathUtil.js +8 -0
- package/lib/internal/MathUtil.js.map +1 -0
- package/lib/internal/Singleton.d.ts +1 -0
- package/lib/internal/Singleton.js +23 -0
- package/lib/internal/Singleton.js.map +1 -0
- package/lib/internal/__map_take.d.ts +1 -0
- package/lib/internal/__map_take.js +16 -0
- package/lib/internal/__map_take.js.map +1 -0
- package/lib/structures/IAgenticaConfig.d.ts +112 -0
- package/lib/structures/IAgenticaConfig.js +3 -0
- package/lib/structures/IAgenticaConfig.js.map +1 -0
- package/lib/structures/IAgenticaContext.d.ts +106 -0
- package/lib/structures/IAgenticaContext.js +3 -0
- package/lib/structures/IAgenticaContext.js.map +1 -0
- package/lib/structures/IAgenticaController.d.ts +110 -0
- package/lib/structures/IAgenticaController.js +3 -0
- package/lib/structures/IAgenticaController.js.map +1 -0
- package/lib/structures/IAgenticaEvent.d.ts +191 -0
- package/lib/structures/IAgenticaEvent.js +3 -0
- package/lib/structures/IAgenticaEvent.js.map +1 -0
- package/lib/structures/IAgenticaExecutor.d.ts +144 -0
- package/lib/structures/IAgenticaExecutor.js +3 -0
- package/lib/structures/IAgenticaExecutor.js.map +1 -0
- package/lib/structures/IAgenticaOperation.d.ts +48 -0
- package/lib/structures/IAgenticaOperation.js +3 -0
- package/lib/structures/IAgenticaOperation.js.map +1 -0
- package/lib/structures/IAgenticaOperationCollection.d.ts +46 -0
- package/lib/structures/IAgenticaOperationCollection.js +3 -0
- package/lib/structures/IAgenticaOperationCollection.js.map +1 -0
- package/lib/structures/IAgenticaOperationSelection.d.ts +51 -0
- package/lib/structures/IAgenticaOperationSelection.js +3 -0
- package/lib/structures/IAgenticaOperationSelection.js.map +1 -0
- package/lib/structures/IAgenticaPrompt.d.ts +139 -0
- package/lib/structures/IAgenticaPrompt.js +3 -0
- package/lib/structures/IAgenticaPrompt.js.map +1 -0
- package/lib/structures/IAgenticaProps.d.ts +59 -0
- package/lib/structures/IAgenticaProps.js +3 -0
- package/lib/structures/IAgenticaProps.js.map +1 -0
- package/lib/structures/IAgenticaProvider.d.ts +41 -0
- package/lib/structures/IAgenticaProvider.js +3 -0
- package/lib/structures/IAgenticaProvider.js.map +1 -0
- package/lib/structures/IAgenticaSystemPrompt.d.ts +116 -0
- package/lib/structures/IAgenticaSystemPrompt.js +3 -0
- package/lib/structures/IAgenticaSystemPrompt.js.map +1 -0
- package/lib/structures/IAgenticaTokenUsage.d.ts +50 -0
- package/lib/structures/IAgenticaTokenUsage.js +3 -0
- package/lib/structures/IAgenticaTokenUsage.js.map +1 -0
- package/lib/structures/internal/__IChatCancelFunctionsApplication.d.ts +22 -0
- package/lib/structures/internal/__IChatCancelFunctionsApplication.js +3 -0
- package/lib/structures/internal/__IChatCancelFunctionsApplication.js.map +1 -0
- package/lib/structures/internal/__IChatFunctionReference.d.ts +20 -0
- package/lib/structures/internal/__IChatFunctionReference.js +3 -0
- package/lib/structures/internal/__IChatFunctionReference.js.map +1 -0
- package/lib/structures/internal/__IChatInitialApplication.d.ts +14 -0
- package/lib/structures/internal/__IChatInitialApplication.js +3 -0
- package/lib/structures/internal/__IChatInitialApplication.js.map +1 -0
- package/lib/structures/internal/__IChatSelectFunctionsApplication.d.ts +23 -0
- package/lib/structures/internal/__IChatSelectFunctionsApplication.js +3 -0
- package/lib/structures/internal/__IChatSelectFunctionsApplication.js.map +1 -0
- package/lib/typings/AgenticaSource.d.ts +1 -0
- package/lib/typings/AgenticaSource.js +3 -0
- package/lib/typings/AgenticaSource.js.map +1 -0
- package/package.json +74 -0
- package/prompts/cancel.md +5 -0
- package/prompts/common.md +3 -0
- package/prompts/describe.md +7 -0
- package/prompts/execute.md +7 -0
- package/prompts/initialize.md +3 -0
- package/prompts/select.md +7 -0
- package/src/Agentica.ts +322 -0
- package/src/chatgpt/ChatGptAgent.ts +71 -0
- package/src/chatgpt/ChatGptCallFunctionAgent.ts +445 -0
- package/src/chatgpt/ChatGptCancelFunctionAgent.ts +283 -0
- package/src/chatgpt/ChatGptDescribeFunctionAgent.ts +51 -0
- package/src/chatgpt/ChatGptHistoryDecoder.ts +86 -0
- package/src/chatgpt/ChatGptInitializeFunctionAgent.ts +88 -0
- package/src/chatgpt/ChatGptSelectFunctionAgent.ts +316 -0
- package/src/functional/createHttpLlmApplication.ts +63 -0
- package/src/index.ts +19 -0
- package/src/internal/AgenticaConstant.ts +4 -0
- package/src/internal/AgenticaCostAggregator.ts +35 -0
- package/src/internal/AgenticaDefaultPrompt.ts +39 -0
- package/src/internal/AgenticaOperationComposer.ts +82 -0
- package/src/internal/AgenticaPromptFactory.ts +30 -0
- package/src/internal/AgenticaPromptTransformer.ts +83 -0
- package/src/internal/AgenticaSystemPrompt.ts +14 -0
- package/src/internal/MathUtil.ts +3 -0
- package/src/internal/Singleton.ts +22 -0
- package/src/internal/__map_take.ts +15 -0
- package/src/structures/IAgenticaConfig.ts +121 -0
- package/src/structures/IAgenticaContext.ts +128 -0
- package/src/structures/IAgenticaController.ts +130 -0
- package/src/structures/IAgenticaEvent.ts +224 -0
- package/src/structures/IAgenticaExecutor.ts +152 -0
- package/src/structures/IAgenticaOperation.ts +64 -0
- package/src/structures/IAgenticaOperationCollection.ts +50 -0
- package/src/structures/IAgenticaOperationSelection.ts +69 -0
- package/src/structures/IAgenticaPrompt.ts +173 -0
- package/src/structures/IAgenticaProps.ts +64 -0
- package/src/structures/IAgenticaProvider.ts +45 -0
- package/src/structures/IAgenticaSystemPrompt.ts +122 -0
- package/src/structures/IAgenticaTokenUsage.ts +52 -0
- package/src/structures/internal/__IChatCancelFunctionsApplication.ts +23 -0
- package/src/structures/internal/__IChatFunctionReference.ts +21 -0
- package/src/structures/internal/__IChatInitialApplication.ts +15 -0
- package/src/structures/internal/__IChatSelectFunctionsApplication.ts +24 -0
- package/src/typings/AgenticaSource.ts +6 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatGptInitializeFunctionAgent.js","sourceRoot":"","sources":["../../src/chatgpt/ChatGptInitializeFunctionAgent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,kDAA0B;AAE1B,6EAA0E;AAC1E,2EAAwE;AAIxE,mEAAgE;AAEhE,IAAiB,8BAA8B,CAuE9C;AAvED,WAAiB,8BAA8B;IAChC,sCAAO,GAAG,CACrB,GAAqB,EACO,EAAE;;QAC9B,MAAM;QACN,sBAAsB;QACtB,MAAM;QACN,MAAM,UAAU,GAA0B,MAAM,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE;YACxE,QAAQ,EAAE;gBACR,uBAAuB;gBACvB;oBACE,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,6CA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGtC,SAAS,CAAC,CAAC,CAAE,CAAC"}
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.ChatGptSelectFunctionAgent = void 0;
|
|
49
|
+
const __typia_transform__validateReport = __importStar(require("typia/lib/internal/_validateReport.js"));
|
|
50
|
+
const typia_1 = __importDefault(require("typia"));
|
|
51
|
+
const uuid_1 = require("uuid");
|
|
52
|
+
const AgenticaConstant_1 = require("../internal/AgenticaConstant");
|
|
53
|
+
const AgenticaDefaultPrompt_1 = require("../internal/AgenticaDefaultPrompt");
|
|
54
|
+
const AgenticaPromptFactory_1 = require("../internal/AgenticaPromptFactory");
|
|
55
|
+
const AgenticaSystemPrompt_1 = require("../internal/AgenticaSystemPrompt");
|
|
56
|
+
const ChatGptHistoryDecoder_1 = require("./ChatGptHistoryDecoder");
|
|
57
|
+
var ChatGptSelectFunctionAgent;
|
|
58
|
+
(function (ChatGptSelectFunctionAgent) {
|
|
59
|
+
ChatGptSelectFunctionAgent.execute = (ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
if (ctx.operations.divided === undefined)
|
|
62
|
+
return step(ctx, ctx.operations.array, 0);
|
|
63
|
+
const stacks = ctx.operations.divided.map(() => []);
|
|
64
|
+
const events = [];
|
|
65
|
+
const prompts = yield Promise.all(ctx.operations.divided.map((operations, i) => step(Object.assign(Object.assign({}, ctx), { stack: stacks[i], dispatch: (e) => __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
events.push(e);
|
|
67
|
+
}) }), operations, 0)));
|
|
68
|
+
// NO FUNCTION SELECTION, SO THAT ONLY TEXT LEFT
|
|
69
|
+
if (stacks.every((s) => s.length === 0))
|
|
70
|
+
return prompts[0];
|
|
71
|
+
// ELITICISM
|
|
72
|
+
else if (((_b = (_a = ctx.config) === null || _a === void 0 ? void 0 : _a.eliticism) !== null && _b !== void 0 ? _b : AgenticaConstant_1.AgenticaConstant.ELITICISM) === true)
|
|
73
|
+
return step(ctx, stacks
|
|
74
|
+
.flat()
|
|
75
|
+
.map((s) => ctx.operations.group
|
|
76
|
+
.get(s.controller.name)
|
|
77
|
+
.get(s.function.name)), 0);
|
|
78
|
+
// RE-COLLECT SELECT FUNCTION EVENTS
|
|
79
|
+
const collection = {
|
|
80
|
+
id: (0, uuid_1.v4)(),
|
|
81
|
+
type: "select",
|
|
82
|
+
operations: [],
|
|
83
|
+
};
|
|
84
|
+
for (const e of events)
|
|
85
|
+
if (e.type === "select") {
|
|
86
|
+
collection.operations.push(AgenticaPromptFactory_1.AgenticaPromptFactory.selection({
|
|
87
|
+
protocol: e.operation.protocol,
|
|
88
|
+
controller: e.operation.controller,
|
|
89
|
+
function: e.operation.function,
|
|
90
|
+
reason: e.reason,
|
|
91
|
+
name: e.operation.name,
|
|
92
|
+
}));
|
|
93
|
+
yield selectFunction(ctx, {
|
|
94
|
+
name: e.operation.name,
|
|
95
|
+
reason: e.reason,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return [collection];
|
|
99
|
+
});
|
|
100
|
+
const step = (ctx, operations, retry, failures) => __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
var _a, _b, _c, _d;
|
|
102
|
+
//----
|
|
103
|
+
// EXECUTE CHATGPT API
|
|
104
|
+
//----
|
|
105
|
+
const completion = yield ctx.request("select", {
|
|
106
|
+
messages: [
|
|
107
|
+
// COMMON SYSTEM PROMPT
|
|
108
|
+
{
|
|
109
|
+
role: "system",
|
|
110
|
+
content: AgenticaDefaultPrompt_1.AgenticaDefaultPrompt.write(ctx.config),
|
|
111
|
+
},
|
|
112
|
+
// CANDIDATE FUNCTIONS
|
|
113
|
+
{
|
|
114
|
+
role: "assistant",
|
|
115
|
+
tool_calls: [
|
|
116
|
+
{
|
|
117
|
+
type: "function",
|
|
118
|
+
id: "getApiFunctions",
|
|
119
|
+
function: {
|
|
120
|
+
name: "getApiFunctions",
|
|
121
|
+
arguments: JSON.stringify({}),
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
role: "tool",
|
|
128
|
+
tool_call_id: "getApiFunctions",
|
|
129
|
+
content: JSON.stringify(operations.map((op) => (Object.assign({ name: op.name, description: op.function.description }, (op.protocol === "http"
|
|
130
|
+
? {
|
|
131
|
+
method: op.function.method,
|
|
132
|
+
path: op.function.path,
|
|
133
|
+
tags: op.function.tags,
|
|
134
|
+
}
|
|
135
|
+
: {}))))),
|
|
136
|
+
},
|
|
137
|
+
// PREVIOUS HISTORIES
|
|
138
|
+
...ctx.histories.map(ChatGptHistoryDecoder_1.ChatGptHistoryDecoder.decode).flat(),
|
|
139
|
+
// USER INPUT
|
|
140
|
+
{
|
|
141
|
+
role: "user",
|
|
142
|
+
content: ctx.prompt.text,
|
|
143
|
+
},
|
|
144
|
+
// SYSTEM PROMPT
|
|
145
|
+
{
|
|
146
|
+
role: "system",
|
|
147
|
+
content: AgenticaSystemPrompt_1.AgenticaSystemPrompt.SELECT,
|
|
148
|
+
},
|
|
149
|
+
// TYPE CORRECTIONS
|
|
150
|
+
...emendMessages(failures !== null && failures !== void 0 ? failures : []),
|
|
151
|
+
],
|
|
152
|
+
// STACK FUNCTIONS
|
|
153
|
+
tools: CONTAINER.functions.map((func) => ({
|
|
154
|
+
type: "function",
|
|
155
|
+
function: {
|
|
156
|
+
name: func.name,
|
|
157
|
+
description: func.description,
|
|
158
|
+
parameters: func.parameters,
|
|
159
|
+
},
|
|
160
|
+
})),
|
|
161
|
+
tool_choice: "auto",
|
|
162
|
+
parallel_tool_calls: false,
|
|
163
|
+
});
|
|
164
|
+
//----
|
|
165
|
+
// VALIDATION
|
|
166
|
+
//----
|
|
167
|
+
if (retry++ < ((_b = (_a = ctx.config) === null || _a === void 0 ? void 0 : _a.retry) !== null && _b !== void 0 ? _b : AgenticaConstant_1.AgenticaConstant.RETRY)) {
|
|
168
|
+
const failures = [];
|
|
169
|
+
for (const choice of completion.choices)
|
|
170
|
+
for (const tc of (_c = choice.message.tool_calls) !== null && _c !== void 0 ? _c : []) {
|
|
171
|
+
if (tc.function.name !== "selectFunctions")
|
|
172
|
+
continue;
|
|
173
|
+
const input = JSON.parse(tc.function.arguments);
|
|
174
|
+
const validation = (() => { const _io0 = input => Array.isArray(input.functions) && input.functions.every(elem => "object" === typeof elem && null !== elem && _io1(elem)); const _io1 = input => "string" === typeof input.reason && "string" === typeof input.name; const _vo0 = (input, _path, _exceptionable = true) => [(Array.isArray(input.functions) || _report(_exceptionable, {
|
|
175
|
+
path: _path + ".functions",
|
|
176
|
+
expected: "Array<___IChatFunctionReference>",
|
|
177
|
+
value: input.functions
|
|
178
|
+
})) && input.functions.map((elem, _index2) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
|
|
179
|
+
path: _path + ".functions[" + _index2 + "]",
|
|
180
|
+
expected: "___IChatFunctionReference",
|
|
181
|
+
value: elem
|
|
182
|
+
})) && _vo1(elem, _path + ".functions[" + _index2 + "]", true && _exceptionable) || _report(_exceptionable, {
|
|
183
|
+
path: _path + ".functions[" + _index2 + "]",
|
|
184
|
+
expected: "___IChatFunctionReference",
|
|
185
|
+
value: elem
|
|
186
|
+
})).every(flag => flag) || _report(_exceptionable, {
|
|
187
|
+
path: _path + ".functions",
|
|
188
|
+
expected: "Array<___IChatFunctionReference>",
|
|
189
|
+
value: input.functions
|
|
190
|
+
})].every(flag => flag); const _vo1 = (input, _path, _exceptionable = true) => ["string" === typeof input.reason || _report(_exceptionable, {
|
|
191
|
+
path: _path + ".reason",
|
|
192
|
+
expected: "string",
|
|
193
|
+
value: input.reason
|
|
194
|
+
}), "string" === typeof input.name || _report(_exceptionable, {
|
|
195
|
+
path: _path + ".name",
|
|
196
|
+
expected: "string",
|
|
197
|
+
value: input.name
|
|
198
|
+
})].every(flag => flag); const __is = input => "object" === typeof input && null !== input && _io0(input); let errors; let _report; return input => {
|
|
199
|
+
if (false === __is(input)) {
|
|
200
|
+
errors = [];
|
|
201
|
+
_report = __typia_transform__validateReport._validateReport(errors);
|
|
202
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
203
|
+
path: _path + "",
|
|
204
|
+
expected: "__IChatFunctionReference.IProps",
|
|
205
|
+
value: input
|
|
206
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
207
|
+
path: _path + "",
|
|
208
|
+
expected: "__IChatFunctionReference.IProps",
|
|
209
|
+
value: input
|
|
210
|
+
}))(input, "$input", true);
|
|
211
|
+
const success = 0 === errors.length;
|
|
212
|
+
return success ? {
|
|
213
|
+
success,
|
|
214
|
+
data: input
|
|
215
|
+
} : {
|
|
216
|
+
success,
|
|
217
|
+
errors,
|
|
218
|
+
data: input
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
success: true,
|
|
223
|
+
data: input
|
|
224
|
+
};
|
|
225
|
+
}; })()(input);
|
|
226
|
+
if (validation.success === false)
|
|
227
|
+
failures.push({
|
|
228
|
+
id: tc.id,
|
|
229
|
+
name: tc.function.name,
|
|
230
|
+
validation,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
if (failures.length > 0)
|
|
234
|
+
return step(ctx, operations, retry, failures);
|
|
235
|
+
}
|
|
236
|
+
//----
|
|
237
|
+
// PROCESS COMPLETION
|
|
238
|
+
//----
|
|
239
|
+
const prompts = [];
|
|
240
|
+
for (const choice of completion.choices) {
|
|
241
|
+
// TOOL CALLING HANDLER
|
|
242
|
+
if (choice.message.tool_calls)
|
|
243
|
+
for (const tc of choice.message.tool_calls) {
|
|
244
|
+
if (tc.type !== "function")
|
|
245
|
+
continue;
|
|
246
|
+
const input = JSON.parse(tc.function.arguments);
|
|
247
|
+
if ((() => { const _io0 = input => Array.isArray(input.functions) && input.functions.every(elem => "object" === typeof elem && null !== elem && _io1(elem)); const _io1 = input => "string" === typeof input.reason && "string" === typeof input.name; return input => "object" === typeof input && null !== input && _io0(input); })()(input) === false)
|
|
248
|
+
continue;
|
|
249
|
+
else if (tc.function.name === "selectFunctions") {
|
|
250
|
+
const collection = {
|
|
251
|
+
id: tc.id,
|
|
252
|
+
type: "select",
|
|
253
|
+
operations: [],
|
|
254
|
+
};
|
|
255
|
+
for (const reference of input.functions) {
|
|
256
|
+
const operation = yield selectFunction(ctx, reference);
|
|
257
|
+
if (operation !== null)
|
|
258
|
+
collection.operations.push(AgenticaPromptFactory_1.AgenticaPromptFactory.selection({
|
|
259
|
+
protocol: operation.protocol,
|
|
260
|
+
controller: operation.controller,
|
|
261
|
+
function: operation.function,
|
|
262
|
+
name: operation.name,
|
|
263
|
+
reason: reference.reason,
|
|
264
|
+
}));
|
|
265
|
+
}
|
|
266
|
+
if (collection.operations.length !== 0)
|
|
267
|
+
prompts.push(collection);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// ASSISTANT MESSAGE
|
|
271
|
+
if (choice.message.role === "assistant" &&
|
|
272
|
+
!!((_d = choice.message.content) === null || _d === void 0 ? void 0 : _d.length)) {
|
|
273
|
+
const text = {
|
|
274
|
+
type: "text",
|
|
275
|
+
role: "assistant",
|
|
276
|
+
text: choice.message.content,
|
|
277
|
+
};
|
|
278
|
+
prompts.push(text);
|
|
279
|
+
yield ctx.dispatch(text);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return prompts;
|
|
283
|
+
});
|
|
284
|
+
const selectFunction = (ctx, reference) => __awaiter(this, void 0, void 0, function* () {
|
|
285
|
+
const operation = ctx.operations.flat.get(reference.name);
|
|
286
|
+
if (operation === undefined)
|
|
287
|
+
return null;
|
|
288
|
+
ctx.stack.push(AgenticaPromptFactory_1.AgenticaPromptFactory.selection({
|
|
289
|
+
protocol: operation.protocol,
|
|
290
|
+
controller: operation.controller,
|
|
291
|
+
function: operation.function,
|
|
292
|
+
name: reference.name,
|
|
293
|
+
reason: reference.reason,
|
|
294
|
+
}));
|
|
295
|
+
yield ctx.dispatch({
|
|
296
|
+
type: "select",
|
|
297
|
+
reason: reference.reason,
|
|
298
|
+
operation,
|
|
299
|
+
});
|
|
300
|
+
return operation;
|
|
301
|
+
});
|
|
302
|
+
const emendMessages = (failures) => failures
|
|
303
|
+
.map((f) => [
|
|
304
|
+
{
|
|
305
|
+
role: "assistant",
|
|
306
|
+
tool_calls: [
|
|
307
|
+
{
|
|
308
|
+
type: "function",
|
|
309
|
+
id: f.id,
|
|
310
|
+
function: {
|
|
311
|
+
name: f.name,
|
|
312
|
+
arguments: JSON.stringify(f.validation.data),
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
],
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
role: "tool",
|
|
319
|
+
content: JSON.stringify(f.validation.errors),
|
|
320
|
+
tool_call_id: f.id,
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
role: "system",
|
|
324
|
+
content: [
|
|
325
|
+
"You A.I. assistant has composed wrong typed arguments.",
|
|
326
|
+
"",
|
|
327
|
+
"Correct it at the next function calling.",
|
|
328
|
+
].join("\n"),
|
|
329
|
+
},
|
|
330
|
+
])
|
|
331
|
+
.flat();
|
|
332
|
+
})(ChatGptSelectFunctionAgent || (exports.ChatGptSelectFunctionAgent = ChatGptSelectFunctionAgent = {}));
|
|
333
|
+
const CONTAINER = {
|
|
334
|
+
model: "chatgpt",
|
|
335
|
+
options: {
|
|
336
|
+
reference: false,
|
|
337
|
+
strict: false,
|
|
338
|
+
separate: null
|
|
339
|
+
},
|
|
340
|
+
functions: [
|
|
341
|
+
{
|
|
342
|
+
name: "selectFunctions",
|
|
343
|
+
parameters: {
|
|
344
|
+
type: "object",
|
|
345
|
+
properties: {
|
|
346
|
+
functions: {
|
|
347
|
+
title: "List of target functions",
|
|
348
|
+
description: "List of target functions.",
|
|
349
|
+
type: "array",
|
|
350
|
+
items: {
|
|
351
|
+
type: "object",
|
|
352
|
+
properties: {
|
|
353
|
+
reason: {
|
|
354
|
+
title: "The reason of the function selection",
|
|
355
|
+
description: "The reason of the function selection.\n\nJust write the reason why you've determined to select this function.",
|
|
356
|
+
type: "string"
|
|
357
|
+
},
|
|
358
|
+
name: {
|
|
359
|
+
title: "Name of the target function to call",
|
|
360
|
+
description: "Name of the target function to call.",
|
|
361
|
+
type: "string"
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
required: [
|
|
365
|
+
"reason",
|
|
366
|
+
"name"
|
|
367
|
+
]
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
required: [
|
|
372
|
+
"functions"
|
|
373
|
+
],
|
|
374
|
+
additionalProperties: false,
|
|
375
|
+
$defs: {}
|
|
376
|
+
},
|
|
377
|
+
description: "Select proper API functions to call.\n\nIf you A.I. agent has found some proper API functions to call\nfrom the conversation with user, please select the API functions\njust by calling this function.\n\nWhen user wants to call a same function multiply, you A.I. agent must\nlist up it multiply in the `functions` property. Otherwise the user has\nrequested to call many different functions, you A.I. agent have to assign\nthem all into the `functions` property.\n\nAlso, if you A.I. agent can't specify a specific function to call due to lack\nof specificity or homogeneity of candidate functions, just assign all of them\nby in the` functions` property` too. Instead, when you A.I. agent can specify\na specific function to call, the others would be eliminated."
|
|
378
|
+
}
|
|
379
|
+
]
|
|
380
|
+
};
|
|
381
|
+
//# sourceMappingURL=ChatGptSelectFunctionAgent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatGptSelectFunctionAgent.js","sourceRoot":"","sources":["../../src/chatgpt/ChatGptSelectFunctionAgent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,kDAA2C;AAC3C,+BAA0B;AAE1B,mEAAgE;AAChE,6EAA0E;AAC1E,6EAA0E;AAC1E,2EAAwE;AASxE,mEAAgE;AAEhE,IAAiB,0BAA0B,CA6R1C;AA7RD,WAAiB,0BAA0B;IAC5B,kCAAO,GAAG,CACrB,GAAqB,EACO,EAAE;;QAC9B,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,KAAK,SAAS;YACtC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAE5C,MAAM,MAAM,GAAoC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CACxE,GAAG,EAAE,CAAC,EAAE,CACT,CAAC;QACF,MAAM,MAAM,GAAqB,EAAE,CAAC;QACpC,MAAM,OAAO,GAAwB,MAAM,OAAO,CAAC,GAAG,CACpD,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAC3C,IAAI,iCAEG,GAAG,KACN,KAAK,EAAE,MAAM,CAAC,CAAC,CAAE,EACjB,QAAQ,EAAE,CAAO,CAAC,EAAE,EAAE;gBACpB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACjB,CAAC,CAAA,KAEH,UAAU,EACV,CAAC,CACF,CACF,CACF,CAAC;QAEF,gDAAgD;QAChD,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,CA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idation } from "typia";
|
|
3
|
+
/**
|
|
4
|
+
* Create an HTTP LLM application instance.
|
|
5
|
+
*
|
|
6
|
+
* Create an {@link IHttpLlmApplication} instance which represents
|
|
7
|
+
* the LLM (Large Language Model) function calling application schema
|
|
8
|
+
* from the given Swagger/OpenAPI document and the target LLM model.
|
|
9
|
+
*
|
|
10
|
+
* By the way, even though this `createHttpLlmApplication` function
|
|
11
|
+
* supports every version of Swagger/OpenAPI specification, there can
|
|
12
|
+
* be a type error in the given document. In that case, the function
|
|
13
|
+
* will return {@link IValidation.IFailure} instance with detailed
|
|
14
|
+
* type error tracing information.
|
|
15
|
+
*
|
|
16
|
+
* @param props Properties to create the HTTP LLM application instance
|
|
17
|
+
* @returns Validation result of the HTTP LLM application composition
|
|
18
|
+
* @author Samchon
|
|
19
|
+
*/
|
|
20
|
+
export declare const createHttpLlmApplication: (props: {
|
|
21
|
+
/**
|
|
22
|
+
* Target LLM model.
|
|
23
|
+
*/
|
|
24
|
+
model: "chatgpt";
|
|
25
|
+
/**
|
|
26
|
+
* Swagger/OpenAPI document.
|
|
27
|
+
*/
|
|
28
|
+
document: SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument | OpenApi.IDocument;
|
|
29
|
+
/**
|
|
30
|
+
* Options for the LLM function calling schema composition.
|
|
31
|
+
*/
|
|
32
|
+
options?: Partial<IHttpLlmApplication.IOptions<"chatgpt">>;
|
|
33
|
+
}) => IValidation<IHttpLlmApplication<"chatgpt">>;
|