@atomoz/workflows-nodes 0.1.7 → 0.1.9
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/dist/index.cjs +146 -99
- package/dist/index.d.cts +3 -8
- package/dist/index.d.ts +3 -8
- package/dist/index.js +146 -97
- package/package.json +3 -1
package/dist/index.cjs
CHANGED
|
@@ -61,8 +61,6 @@ __export(index_exports, {
|
|
|
61
61
|
IaMessageNode: () => IaMessageNode,
|
|
62
62
|
IaMessageNodeFunction: () => IaMessageNodeFunction,
|
|
63
63
|
IaMessageNodeSchema: () => IaMessageNodeSchema,
|
|
64
|
-
IaModelNode: () => IaModelNode,
|
|
65
|
-
IaModelNodeFunction: () => IaModelNodeFunction,
|
|
66
64
|
QueryParamSchema: () => QueryParamSchema,
|
|
67
65
|
RouteSchema: () => RouteSchema,
|
|
68
66
|
WhatsappMessageTriggerNode: () => WhatsappMessageTriggerNode,
|
|
@@ -172,7 +170,6 @@ var HttpGetInputNodeFunction = async (params) => {
|
|
|
172
170
|
throw new Error(`Headers obrigat\xF3rios ausentes: ${missingHeaders.map((h) => h.key).join(", ")}`);
|
|
173
171
|
}
|
|
174
172
|
}
|
|
175
|
-
console.log(actualData);
|
|
176
173
|
return actualData;
|
|
177
174
|
};
|
|
178
175
|
|
|
@@ -418,11 +415,9 @@ var ManualTriggerNode = {
|
|
|
418
415
|
// src/nodes/processors/concat.ts
|
|
419
416
|
var import_zod4 = require("zod");
|
|
420
417
|
var ConcatNodeFunction = (inputs) => {
|
|
421
|
-
console.log("\u{1F517} ConcatNode - Input:", { input1: inputs.input1 || "", input2: inputs.input2 || "" });
|
|
422
418
|
const input1 = inputs.input1 || "";
|
|
423
419
|
const input2 = inputs.input2 || "";
|
|
424
420
|
const result = `${input1}${input2}`;
|
|
425
|
-
console.log("\u{1F517} ConcatNode - Output:", result);
|
|
426
421
|
return {
|
|
427
422
|
output: result,
|
|
428
423
|
function: ConcatNodeFunction,
|
|
@@ -730,7 +725,6 @@ var IaAgentNode = {
|
|
|
730
725
|
},
|
|
731
726
|
{
|
|
732
727
|
id: "agent",
|
|
733
|
-
// O output agora é o próprio agente
|
|
734
728
|
label: "Agent",
|
|
735
729
|
type: "agent",
|
|
736
730
|
required: true,
|
|
@@ -743,15 +737,15 @@ var IaAgentNode = {
|
|
|
743
737
|
}
|
|
744
738
|
},
|
|
745
739
|
{
|
|
746
|
-
id: "
|
|
747
|
-
label: "
|
|
740
|
+
id: "response",
|
|
741
|
+
label: "Response",
|
|
748
742
|
type: "string",
|
|
749
743
|
required: true,
|
|
750
744
|
typeable: false,
|
|
751
745
|
handle: {
|
|
752
746
|
type: "output",
|
|
753
|
-
label: "
|
|
754
|
-
name: "
|
|
747
|
+
label: "response",
|
|
748
|
+
name: "response",
|
|
755
749
|
fieldType: "string"
|
|
756
750
|
}
|
|
757
751
|
}
|
|
@@ -761,8 +755,109 @@ var IaAgentNode = {
|
|
|
761
755
|
// src/nodes/ia/agent/function.ts
|
|
762
756
|
var import_prebuilt = require("@langchain/langgraph/prebuilt");
|
|
763
757
|
var import_messages = require("@langchain/core/messages");
|
|
758
|
+
|
|
759
|
+
// src/utils/llm-factory.ts
|
|
760
|
+
var import_graphql_request = require("graphql-request");
|
|
761
|
+
var import_google_gauth = require("@langchain/google-gauth");
|
|
762
|
+
var import_openai = require("@langchain/openai");
|
|
763
|
+
var GRAPHQL_ENDPOINT = process.env["GRAPHQL_URL"] || "http://localhost:3001/graphql";
|
|
764
|
+
var GET_INTEGRATIONS_QUERY = import_graphql_request.gql`
|
|
765
|
+
query GetIntegrations($where: IntegrationWhereInput) {
|
|
766
|
+
getIntegrations(where: $where) {
|
|
767
|
+
status
|
|
768
|
+
message
|
|
769
|
+
data {
|
|
770
|
+
id
|
|
771
|
+
status
|
|
772
|
+
data
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
`;
|
|
777
|
+
async function createLLMFromModel(modelConfig, authToken, streaming = false) {
|
|
778
|
+
if (modelConfig?.invoke || modelConfig?.call) {
|
|
779
|
+
return modelConfig;
|
|
780
|
+
}
|
|
781
|
+
if (!modelConfig?.model || !modelConfig?.integrationId) {
|
|
782
|
+
throw new Error('Model config deve conter "model" e "integrationId"');
|
|
783
|
+
}
|
|
784
|
+
const { model, integrationId } = modelConfig;
|
|
785
|
+
const client = new import_graphql_request.GraphQLClient(GRAPHQL_ENDPOINT, {
|
|
786
|
+
headers: {
|
|
787
|
+
Authorization: `Bearer ${authToken}`,
|
|
788
|
+
"x-tenant-id": "65d62c52-0c09-473a-8895-359afbed3f5a"
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
let integrationData;
|
|
792
|
+
try {
|
|
793
|
+
const response = await client.request(
|
|
794
|
+
GET_INTEGRATIONS_QUERY,
|
|
795
|
+
{
|
|
796
|
+
where: {
|
|
797
|
+
id: {
|
|
798
|
+
eq: integrationId
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
);
|
|
803
|
+
if (!response.getIntegrations?.data?.[0]) {
|
|
804
|
+
throw new Error(`Integra\xE7\xE3o ${integrationId} n\xE3o encontrada`);
|
|
805
|
+
}
|
|
806
|
+
integrationData = response.getIntegrations.data[0];
|
|
807
|
+
} catch (error) {
|
|
808
|
+
console.error("Erro ao buscar integra\xE7\xE3o:", error);
|
|
809
|
+
throw new Error(
|
|
810
|
+
`Falha ao buscar integra\xE7\xE3o: ${error instanceof Error ? error.message : "Erro desconhecido"}`
|
|
811
|
+
);
|
|
812
|
+
}
|
|
813
|
+
const apiKey = integrationData.data?.["token"] || integrationData.data?.["token"];
|
|
814
|
+
if (!apiKey) {
|
|
815
|
+
throw new Error(`API Key n\xE3o encontrada na integra\xE7\xE3o ${integrationId}`);
|
|
816
|
+
}
|
|
817
|
+
const provider = integrationData.data?.provider?.toLowerCase() || inferProviderFromModel(model);
|
|
818
|
+
switch (provider) {
|
|
819
|
+
case "gemini":
|
|
820
|
+
return new import_google_gauth.ChatGoogle({
|
|
821
|
+
model: "gemini-flash-latest",
|
|
822
|
+
apiKey,
|
|
823
|
+
streaming
|
|
824
|
+
});
|
|
825
|
+
case "openai":
|
|
826
|
+
return new import_openai.ChatOpenAI({
|
|
827
|
+
model,
|
|
828
|
+
openAIApiKey: apiKey,
|
|
829
|
+
streaming
|
|
830
|
+
});
|
|
831
|
+
case "openrouter":
|
|
832
|
+
return new import_openai.ChatOpenAI({
|
|
833
|
+
model,
|
|
834
|
+
openAIApiKey: apiKey,
|
|
835
|
+
configuration: {
|
|
836
|
+
baseURL: "https://openrouter.ai/api/v1"
|
|
837
|
+
},
|
|
838
|
+
streaming
|
|
839
|
+
});
|
|
840
|
+
default:
|
|
841
|
+
throw new Error(
|
|
842
|
+
`Provider "${provider}" n\xE3o suportado. Providers dispon\xEDveis: gemini, openai, openrouter`
|
|
843
|
+
);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
function inferProviderFromModel(model) {
|
|
847
|
+
const modelLower = model.toLowerCase();
|
|
848
|
+
if (modelLower.includes("gemini") || modelLower.includes("palm")) {
|
|
849
|
+
return "gemini";
|
|
850
|
+
}
|
|
851
|
+
if (modelLower.includes("gpt") || modelLower.includes("o1") || modelLower.includes("o3")) {
|
|
852
|
+
return "openai";
|
|
853
|
+
}
|
|
854
|
+
return "openrouter";
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
// src/nodes/ia/agent/function.ts
|
|
764
858
|
var IaAgentNodeFunction = async (inputs) => {
|
|
765
|
-
const { model, tools, systemMessage, name, message } = inputs.fieldValues
|
|
859
|
+
const { model, tools, systemMessage, name, message } = inputs.fieldValues;
|
|
860
|
+
const authToken = inputs.authToken;
|
|
766
861
|
if (!name) {
|
|
767
862
|
throw new Error("Agent 'name' is required. Please provide a unique name for the agent in the node properties.");
|
|
768
863
|
}
|
|
@@ -779,8 +874,20 @@ var IaAgentNodeFunction = async (inputs) => {
|
|
|
779
874
|
|
|
780
875
|
IMPORTANT: You must base your response on the last message in the conversation history.`;
|
|
781
876
|
const finalSystemMessage = new import_messages.SystemMessage(finalSystemMessageContent);
|
|
877
|
+
let llmInstance;
|
|
878
|
+
if (model?.integrationId) {
|
|
879
|
+
if (!authToken) {
|
|
880
|
+
throw new Error("Auth token is required to instantiate LLM from integration");
|
|
881
|
+
}
|
|
882
|
+
const streaming = Boolean(inputs?.stream);
|
|
883
|
+
llmInstance = await createLLMFromModel(model, authToken, streaming);
|
|
884
|
+
} else if (typeof model?.bindTools === "function") {
|
|
885
|
+
llmInstance = model;
|
|
886
|
+
} else {
|
|
887
|
+
throw new Error("Invalid model: must have integrationId or be a valid LLM instance with bindTools method");
|
|
888
|
+
}
|
|
782
889
|
const agent = (0, import_prebuilt.createReactAgent)({
|
|
783
|
-
llm:
|
|
890
|
+
llm: llmInstance,
|
|
784
891
|
tools: toolsArray,
|
|
785
892
|
messageModifier: finalSystemMessage
|
|
786
893
|
});
|
|
@@ -956,15 +1063,25 @@ var AiSupervisorNodeFunction = async (fieldValues) => {
|
|
|
956
1063
|
const systemMessage = inner.systemMessage ?? outer.systemMessage;
|
|
957
1064
|
const stream = (typeof outer.stream === "boolean" ? outer.stream : inner.stream) ?? false;
|
|
958
1065
|
const emitter = outer.emitter ?? inner.emitter;
|
|
1066
|
+
const authToken = outer.authToken ?? inner.authToken;
|
|
959
1067
|
if (!model) throw new Error("Model is required for AiSupervisorNode");
|
|
960
1068
|
if (!agents) throw new Error("Agents are required for AiSupervisorNode.");
|
|
961
1069
|
try {
|
|
962
1070
|
const supervisorAgents = extractSupervisorAgents(agents);
|
|
963
1071
|
if (supervisorAgents.length === 0) throw new Error("No valid agents were extracted from the 'agents' input.");
|
|
964
1072
|
if (supervisorAgents.some((agent) => !agent.name)) throw new Error("All agents must have a name.");
|
|
1073
|
+
let llmInstance;
|
|
1074
|
+
if (model?.model && model?.integrationId) {
|
|
1075
|
+
if (!authToken) {
|
|
1076
|
+
throw new Error("Auth token is required to instantiate LLM from integration 3");
|
|
1077
|
+
}
|
|
1078
|
+
llmInstance = await createLLMFromModel(model, authToken, stream);
|
|
1079
|
+
} else {
|
|
1080
|
+
llmInstance = model;
|
|
1081
|
+
}
|
|
965
1082
|
const finalSystemPrompt = systemMessage || "You are a supervisor...";
|
|
966
1083
|
const workflow = (0, import_langgraph_supervisor.createSupervisor)({
|
|
967
|
-
llm:
|
|
1084
|
+
llm: llmInstance,
|
|
968
1085
|
agents: supervisorAgents,
|
|
969
1086
|
prompt: finalSystemPrompt
|
|
970
1087
|
});
|
|
@@ -974,7 +1091,6 @@ var AiSupervisorNodeFunction = async (fieldValues) => {
|
|
|
974
1091
|
});
|
|
975
1092
|
if (stream && emitter) {
|
|
976
1093
|
try {
|
|
977
|
-
console.log("\u{1F504} Starting streaming mode...");
|
|
978
1094
|
const streamIterator = await app.stream(
|
|
979
1095
|
{ messages: [new import_messages2.HumanMessage({ content: message })] },
|
|
980
1096
|
{ recursionLimit: 150, configurable: { thread_id: "conversation" } }
|
|
@@ -1139,7 +1255,8 @@ var AiToolNode = {
|
|
|
1139
1255
|
label: "Tool",
|
|
1140
1256
|
name: "tool",
|
|
1141
1257
|
fieldType: "tool",
|
|
1142
|
-
required: true
|
|
1258
|
+
required: true,
|
|
1259
|
+
acceptTypes: ["tool"]
|
|
1143
1260
|
}
|
|
1144
1261
|
}
|
|
1145
1262
|
]
|
|
@@ -1192,76 +1309,6 @@ var AiToolNodeFunction = async (fieldValues) => {
|
|
|
1192
1309
|
};
|
|
1193
1310
|
};
|
|
1194
1311
|
|
|
1195
|
-
// src/nodes/ia/model/data.ts
|
|
1196
|
-
var IaModelNode = {
|
|
1197
|
-
label: "AI Model",
|
|
1198
|
-
type: "IaModelNode",
|
|
1199
|
-
category: "step",
|
|
1200
|
-
description: "AI Model",
|
|
1201
|
-
icon: "\u{1F916}",
|
|
1202
|
-
tags: {
|
|
1203
|
-
execution: "async",
|
|
1204
|
-
group: "IA"
|
|
1205
|
-
},
|
|
1206
|
-
fields: [
|
|
1207
|
-
{
|
|
1208
|
-
id: "model",
|
|
1209
|
-
label: "Model",
|
|
1210
|
-
type: "select",
|
|
1211
|
-
required: true,
|
|
1212
|
-
defaultValue: "gemini-2.5-pro",
|
|
1213
|
-
options: [
|
|
1214
|
-
{ label: "Gemini 2.5 Pro", value: "gemini-2.5-pro" },
|
|
1215
|
-
{ label: "Gemini 2.5 Flash", value: "gemini-2.5-flash" },
|
|
1216
|
-
{ label: "Gemini 2.5 Flash Lite", value: "gemini-2.5-flash-lite" },
|
|
1217
|
-
{ label: "Gemini 2.0 Flash", value: "gemini-2.0-flash" },
|
|
1218
|
-
{ label: "Gemini 2.0 Flash Lite", value: "gemini-2.0-flash-lite" }
|
|
1219
|
-
]
|
|
1220
|
-
},
|
|
1221
|
-
{
|
|
1222
|
-
id: "apiKey",
|
|
1223
|
-
label: "API Key",
|
|
1224
|
-
type: "string",
|
|
1225
|
-
required: true
|
|
1226
|
-
},
|
|
1227
|
-
{
|
|
1228
|
-
id: "model",
|
|
1229
|
-
label: "Model",
|
|
1230
|
-
type: "model",
|
|
1231
|
-
required: true,
|
|
1232
|
-
typeable: false,
|
|
1233
|
-
handle: {
|
|
1234
|
-
type: "output",
|
|
1235
|
-
label: "Model",
|
|
1236
|
-
name: "model",
|
|
1237
|
-
fieldType: "model",
|
|
1238
|
-
required: true
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
]
|
|
1242
|
-
};
|
|
1243
|
-
|
|
1244
|
-
// src/nodes/ia/model/function.ts
|
|
1245
|
-
var import_google_gauth = require("@langchain/google-gauth");
|
|
1246
|
-
var IaModelNodeFunction = async (inputs) => {
|
|
1247
|
-
const fieldValues = inputs.fieldValues || inputs;
|
|
1248
|
-
const { model, apiKey } = fieldValues;
|
|
1249
|
-
const stream = Boolean(inputs?.stream || fieldValues?.stream);
|
|
1250
|
-
if (!model || !apiKey) {
|
|
1251
|
-
console.error("\u274C Model e apiKey s\xE3o obrigat\xF3rios para IaModelNode");
|
|
1252
|
-
console.error("\u274C Received:", { model, apiKey });
|
|
1253
|
-
throw new Error("Model e apiKey s\xE3o obrigat\xF3rios");
|
|
1254
|
-
}
|
|
1255
|
-
const llm = new import_google_gauth.ChatGoogle({
|
|
1256
|
-
model,
|
|
1257
|
-
apiKey,
|
|
1258
|
-
streaming: stream
|
|
1259
|
-
});
|
|
1260
|
-
return {
|
|
1261
|
-
model: llm
|
|
1262
|
-
};
|
|
1263
|
-
};
|
|
1264
|
-
|
|
1265
1312
|
// src/nodes/ia/message/message.ts
|
|
1266
1313
|
var import_zod8 = require("zod");
|
|
1267
1314
|
var IaMessageNodeSchema = import_zod8.z.object({
|
|
@@ -1269,21 +1316,33 @@ var IaMessageNodeSchema = import_zod8.z.object({
|
|
|
1269
1316
|
systemMessage: import_zod8.z.string().optional().describe("System message for context"),
|
|
1270
1317
|
message: import_zod8.z.string().describe("User message to send to the LLM")
|
|
1271
1318
|
});
|
|
1272
|
-
var IaMessageNodeFunction = async (
|
|
1319
|
+
var IaMessageNodeFunction = async (inputs) => {
|
|
1320
|
+
const fieldValues = inputs.fieldValues || inputs;
|
|
1273
1321
|
const { model, systemMessage, message } = fieldValues;
|
|
1322
|
+
const authToken = inputs.authToken;
|
|
1274
1323
|
if (!model) {
|
|
1275
1324
|
throw new Error("Model is required");
|
|
1276
1325
|
}
|
|
1277
1326
|
if (!message) {
|
|
1278
1327
|
throw new Error("Message is required");
|
|
1279
1328
|
}
|
|
1329
|
+
let llmInstance;
|
|
1330
|
+
if (model?.model && model?.integrationId) {
|
|
1331
|
+
if (!authToken) {
|
|
1332
|
+
throw new Error("Auth token is required to instantiate LLM from integration2 ");
|
|
1333
|
+
}
|
|
1334
|
+
const streaming = Boolean(inputs?.stream);
|
|
1335
|
+
llmInstance = await createLLMFromModel(model, authToken, streaming);
|
|
1336
|
+
} else {
|
|
1337
|
+
llmInstance = model;
|
|
1338
|
+
}
|
|
1280
1339
|
const messages = [];
|
|
1281
1340
|
if (systemMessage) {
|
|
1282
1341
|
messages.push(["system", systemMessage]);
|
|
1283
1342
|
}
|
|
1284
1343
|
messages.push(["human", message]);
|
|
1285
1344
|
try {
|
|
1286
|
-
const response = await
|
|
1345
|
+
const response = await llmInstance.invoke(messages);
|
|
1287
1346
|
return {
|
|
1288
1347
|
output: response.content,
|
|
1289
1348
|
response: response.content,
|
|
@@ -1519,7 +1578,6 @@ var nodes = [
|
|
|
1519
1578
|
ConcatNode,
|
|
1520
1579
|
OutputNode,
|
|
1521
1580
|
ChatOutputNode,
|
|
1522
|
-
IaModelNode,
|
|
1523
1581
|
IaMessageNode,
|
|
1524
1582
|
IaAgentNode,
|
|
1525
1583
|
AiToolNode,
|
|
@@ -1536,10 +1594,6 @@ var NUMBER_ID = "700207253183039";
|
|
|
1536
1594
|
var TOKEN = "EAAUuy5eznhEBPQUOoF07SUTSVjgNIX9eZCWSKPYQhzHiXeEp4Qj3g47bZAPcZAgs8P2B5cZBH9YJjzq0HKNXfA14kaK5Cp2DZCmxzV60MgWlsY1yKavb2qXAQcydoHTTLKcWO53w6ZB7JNzZBeIpZBTb9cB0teRzfX3kjrZBc7utyKq2ZCZCCOQ74pZA28gnmQYzp24oZBQpf7BmuNHgndFVlTba5drxgcpERyNl1dUIDhky7NIruggZDZD";
|
|
1537
1595
|
var WhatsappStartChatFunction = async (fieldValues) => {
|
|
1538
1596
|
const { phoneNumber, template } = fieldValues;
|
|
1539
|
-
console.log({
|
|
1540
|
-
phoneNumber,
|
|
1541
|
-
template
|
|
1542
|
-
});
|
|
1543
1597
|
const response = await fetch(`https://graph.facebook.com/v23.0/${NUMBER_ID}/messages`, {
|
|
1544
1598
|
method: "POST",
|
|
1545
1599
|
headers: {
|
|
@@ -1600,10 +1654,6 @@ var NUMBER_ID2 = "700207253183039";
|
|
|
1600
1654
|
var TOKEN2 = "EAAUuy5eznhEBPWw62uE6cs4oZAW6WvpsiF9RBjTGDjg8H74GouBMl1MBifCuA572AVMp53T83pBuSaMJUcWMDIGxvXbxaU6RFTyXOuKkhUPkF3Boc7QbmRuUWSFuyvkjZCyA7ngAg2NXV8nYzzZCleSuFQD487NN2mat7sHPx2pMHuN95IcaevyKLnuz5Om2Bp36JihQweodc517aH2Krv70jqNKKzBjoGVziWNnOhULQZDZD";
|
|
1601
1655
|
var WhatsappSendMessageFunction = async (fieldValues) => {
|
|
1602
1656
|
const { phoneNumber, message } = fieldValues;
|
|
1603
|
-
console.log({
|
|
1604
|
-
phoneNumber,
|
|
1605
|
-
message
|
|
1606
|
-
});
|
|
1607
1657
|
const response = await fetch(`https://graph.facebook.com/v23.0/${NUMBER_ID2}/messages`, {
|
|
1608
1658
|
method: "POST",
|
|
1609
1659
|
headers: {
|
|
@@ -1641,7 +1691,6 @@ var nodeFunctions = {
|
|
|
1641
1691
|
ManualTrigger: ManualTriggerNodeFunction,
|
|
1642
1692
|
HttpOutput: HttpOutputNodeFunction,
|
|
1643
1693
|
ConcatNode: ConcatNodeFunction,
|
|
1644
|
-
IaModelNode: IaModelNodeFunction,
|
|
1645
1694
|
IaMessageNode: IaMessageNodeFunction,
|
|
1646
1695
|
IaAgentNode: IaAgentNodeFunction,
|
|
1647
1696
|
AiToolNode: AiToolNodeFunction,
|
|
@@ -2065,8 +2114,6 @@ var getHttpMethodFromFriendlyId = (friendlyId) => {
|
|
|
2065
2114
|
IaMessageNode,
|
|
2066
2115
|
IaMessageNodeFunction,
|
|
2067
2116
|
IaMessageNodeSchema,
|
|
2068
|
-
IaModelNode,
|
|
2069
|
-
IaModelNodeFunction,
|
|
2070
2117
|
QueryParamSchema,
|
|
2071
2118
|
RouteSchema,
|
|
2072
2119
|
WhatsappMessageTriggerNode,
|
package/dist/index.d.cts
CHANGED
|
@@ -170,8 +170,7 @@ declare const nodeFunctions: {
|
|
|
170
170
|
ManualTrigger: (params: any) => any;
|
|
171
171
|
HttpOutput: (params: any) => any;
|
|
172
172
|
ConcatNode: (inputs: any) => any;
|
|
173
|
-
|
|
174
|
-
IaMessageNode: (fieldValues: any) => Promise<any>;
|
|
173
|
+
IaMessageNode: (inputs: any) => Promise<any>;
|
|
175
174
|
IaAgentNode: (inputs: any) => Promise<any>;
|
|
176
175
|
AiToolNode: (fieldValues: any) => Promise<{
|
|
177
176
|
tool: any;
|
|
@@ -220,16 +219,12 @@ declare const AiToolNodeFunction: (fieldValues: any) => Promise<{
|
|
|
220
219
|
tool: any;
|
|
221
220
|
}>;
|
|
222
221
|
|
|
223
|
-
declare const IaModelNode: NodeData;
|
|
224
|
-
|
|
225
|
-
declare const IaModelNodeFunction: (inputs: any) => Promise<any>;
|
|
226
|
-
|
|
227
222
|
declare const IaMessageNodeSchema: z.ZodObject<{
|
|
228
223
|
model: z.ZodAny;
|
|
229
224
|
systemMessage: z.ZodOptional<z.ZodString>;
|
|
230
225
|
message: z.ZodString;
|
|
231
226
|
}, z.core.$strip>;
|
|
232
|
-
declare const IaMessageNodeFunction: (
|
|
227
|
+
declare const IaMessageNodeFunction: (inputs: any) => Promise<any>;
|
|
233
228
|
declare const IaMessageNode: NodeData;
|
|
234
229
|
|
|
235
230
|
declare const HttpGetInputNode: NodeData;
|
|
@@ -430,4 +425,4 @@ declare const WhatsappSendMessageFunction: (fieldValues: any) => Promise<any>;
|
|
|
430
425
|
|
|
431
426
|
declare const WhatsappMessageTriggerNode: NodeData;
|
|
432
427
|
|
|
433
|
-
export { AiSupervisorNode, AiSupervisorNodeFunction, AiSupervisorNodeSchema, AiToolNode, AiToolNodeFunction, AiToolNodeSchema, type BaseNodeType, BodyFieldSchema, CustomToolSchema, type ExecutionStep, HTTP_METHODS, HTTP_NODE_TYPES, HeaderSchema, HttpDeleteInputNode, HttpDeleteInputNodeFunction, HttpDeleteInputNodeSchema, type HttpDeleteInputNodeType, HttpGetInputNode, HttpGetInputNodeFunction, HttpGetInputNodeSchema, type HttpGetInputNodeType, type HttpMethod, type HttpNodeType, type HttpOutput, HttpPatchInputNode, HttpPatchInputNodeFunction, HttpPatchInputNodeSchema, type HttpPatchInputNodeType, HttpPostInputNode, HttpPostInputNodeFunction, HttpPostInputNodeSchema, type HttpPostInputNodeType, HttpPutInputNode, HttpPutInputNodeFunction, HttpPutInputNodeSchema, type HttpPutInputNodeType, IaAgentNode, IaAgentNodeFunction, IaAgentNodeSchema, IaMessageNode, IaMessageNodeFunction, IaMessageNodeSchema,
|
|
428
|
+
export { AiSupervisorNode, AiSupervisorNodeFunction, AiSupervisorNodeSchema, AiToolNode, AiToolNodeFunction, AiToolNodeSchema, type BaseNodeType, BodyFieldSchema, CustomToolSchema, type ExecutionStep, HTTP_METHODS, HTTP_NODE_TYPES, HeaderSchema, HttpDeleteInputNode, HttpDeleteInputNodeFunction, HttpDeleteInputNodeSchema, type HttpDeleteInputNodeType, HttpGetInputNode, HttpGetInputNodeFunction, HttpGetInputNodeSchema, type HttpGetInputNodeType, type HttpMethod, type HttpNodeType, type HttpOutput, HttpPatchInputNode, HttpPatchInputNodeFunction, HttpPatchInputNodeSchema, type HttpPatchInputNodeType, HttpPostInputNode, HttpPostInputNodeFunction, HttpPostInputNodeSchema, type HttpPostInputNodeType, HttpPutInputNode, HttpPutInputNodeFunction, HttpPutInputNodeSchema, type HttpPutInputNodeType, IaAgentNode, IaAgentNodeFunction, IaAgentNodeSchema, IaMessageNode, IaMessageNodeFunction, IaMessageNodeSchema, type NodeData, type NodeDefinition, type NodeExecution, type NodeExecutionConfig, type NodeExecutionContext, type NodeField, type NodeHandle, type NodeInput, type NodeInputValue, type NodeLogicFunction, type NodeOutput, type NodeOutputValue, type NodeStyle, type NodeTags, type NodeTransformation, type NodeValidation, QueryParamSchema, RouteSchema, WhatsappMessageTriggerNode, WhatsappSendMessageFunction, WhatsappSendMessageNode, WhatsappSendMessageNodeSchema, WhatsappSendTemplateNode, WhatsappSendTemplateNodeSchema, WhatsappStartChatFunction, createMessageTemplate, extractHttpMethodFromNodeType, getHttpMethodFromFriendlyId, getHttpMethodFromNodeType, getHttpNodeTypeStrings, getHttpNodeTypesArray, getHttpNodesTypes, getMessageTemplates, isAnyHttpInputNode, isHttpInputFriendlyId, isHttpInputNode, isHttpMethodNode, nodeFunctions, nodes, schemas };
|
package/dist/index.d.ts
CHANGED
|
@@ -170,8 +170,7 @@ declare const nodeFunctions: {
|
|
|
170
170
|
ManualTrigger: (params: any) => any;
|
|
171
171
|
HttpOutput: (params: any) => any;
|
|
172
172
|
ConcatNode: (inputs: any) => any;
|
|
173
|
-
|
|
174
|
-
IaMessageNode: (fieldValues: any) => Promise<any>;
|
|
173
|
+
IaMessageNode: (inputs: any) => Promise<any>;
|
|
175
174
|
IaAgentNode: (inputs: any) => Promise<any>;
|
|
176
175
|
AiToolNode: (fieldValues: any) => Promise<{
|
|
177
176
|
tool: any;
|
|
@@ -220,16 +219,12 @@ declare const AiToolNodeFunction: (fieldValues: any) => Promise<{
|
|
|
220
219
|
tool: any;
|
|
221
220
|
}>;
|
|
222
221
|
|
|
223
|
-
declare const IaModelNode: NodeData;
|
|
224
|
-
|
|
225
|
-
declare const IaModelNodeFunction: (inputs: any) => Promise<any>;
|
|
226
|
-
|
|
227
222
|
declare const IaMessageNodeSchema: z.ZodObject<{
|
|
228
223
|
model: z.ZodAny;
|
|
229
224
|
systemMessage: z.ZodOptional<z.ZodString>;
|
|
230
225
|
message: z.ZodString;
|
|
231
226
|
}, z.core.$strip>;
|
|
232
|
-
declare const IaMessageNodeFunction: (
|
|
227
|
+
declare const IaMessageNodeFunction: (inputs: any) => Promise<any>;
|
|
233
228
|
declare const IaMessageNode: NodeData;
|
|
234
229
|
|
|
235
230
|
declare const HttpGetInputNode: NodeData;
|
|
@@ -430,4 +425,4 @@ declare const WhatsappSendMessageFunction: (fieldValues: any) => Promise<any>;
|
|
|
430
425
|
|
|
431
426
|
declare const WhatsappMessageTriggerNode: NodeData;
|
|
432
427
|
|
|
433
|
-
export { AiSupervisorNode, AiSupervisorNodeFunction, AiSupervisorNodeSchema, AiToolNode, AiToolNodeFunction, AiToolNodeSchema, type BaseNodeType, BodyFieldSchema, CustomToolSchema, type ExecutionStep, HTTP_METHODS, HTTP_NODE_TYPES, HeaderSchema, HttpDeleteInputNode, HttpDeleteInputNodeFunction, HttpDeleteInputNodeSchema, type HttpDeleteInputNodeType, HttpGetInputNode, HttpGetInputNodeFunction, HttpGetInputNodeSchema, type HttpGetInputNodeType, type HttpMethod, type HttpNodeType, type HttpOutput, HttpPatchInputNode, HttpPatchInputNodeFunction, HttpPatchInputNodeSchema, type HttpPatchInputNodeType, HttpPostInputNode, HttpPostInputNodeFunction, HttpPostInputNodeSchema, type HttpPostInputNodeType, HttpPutInputNode, HttpPutInputNodeFunction, HttpPutInputNodeSchema, type HttpPutInputNodeType, IaAgentNode, IaAgentNodeFunction, IaAgentNodeSchema, IaMessageNode, IaMessageNodeFunction, IaMessageNodeSchema,
|
|
428
|
+
export { AiSupervisorNode, AiSupervisorNodeFunction, AiSupervisorNodeSchema, AiToolNode, AiToolNodeFunction, AiToolNodeSchema, type BaseNodeType, BodyFieldSchema, CustomToolSchema, type ExecutionStep, HTTP_METHODS, HTTP_NODE_TYPES, HeaderSchema, HttpDeleteInputNode, HttpDeleteInputNodeFunction, HttpDeleteInputNodeSchema, type HttpDeleteInputNodeType, HttpGetInputNode, HttpGetInputNodeFunction, HttpGetInputNodeSchema, type HttpGetInputNodeType, type HttpMethod, type HttpNodeType, type HttpOutput, HttpPatchInputNode, HttpPatchInputNodeFunction, HttpPatchInputNodeSchema, type HttpPatchInputNodeType, HttpPostInputNode, HttpPostInputNodeFunction, HttpPostInputNodeSchema, type HttpPostInputNodeType, HttpPutInputNode, HttpPutInputNodeFunction, HttpPutInputNodeSchema, type HttpPutInputNodeType, IaAgentNode, IaAgentNodeFunction, IaAgentNodeSchema, IaMessageNode, IaMessageNodeFunction, IaMessageNodeSchema, type NodeData, type NodeDefinition, type NodeExecution, type NodeExecutionConfig, type NodeExecutionContext, type NodeField, type NodeHandle, type NodeInput, type NodeInputValue, type NodeLogicFunction, type NodeOutput, type NodeOutputValue, type NodeStyle, type NodeTags, type NodeTransformation, type NodeValidation, QueryParamSchema, RouteSchema, WhatsappMessageTriggerNode, WhatsappSendMessageFunction, WhatsappSendMessageNode, WhatsappSendMessageNodeSchema, WhatsappSendTemplateNode, WhatsappSendTemplateNodeSchema, WhatsappStartChatFunction, createMessageTemplate, extractHttpMethodFromNodeType, getHttpMethodFromFriendlyId, getHttpMethodFromNodeType, getHttpNodeTypeStrings, getHttpNodeTypesArray, getHttpNodesTypes, getMessageTemplates, isAnyHttpInputNode, isHttpInputFriendlyId, isHttpInputNode, isHttpMethodNode, nodeFunctions, nodes, schemas };
|
package/dist/index.js
CHANGED
|
@@ -80,7 +80,6 @@ var HttpGetInputNodeFunction = async (params) => {
|
|
|
80
80
|
throw new Error(`Headers obrigat\xF3rios ausentes: ${missingHeaders.map((h) => h.key).join(", ")}`);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
console.log(actualData);
|
|
84
83
|
return actualData;
|
|
85
84
|
};
|
|
86
85
|
|
|
@@ -326,11 +325,9 @@ var ManualTriggerNode = {
|
|
|
326
325
|
// src/nodes/processors/concat.ts
|
|
327
326
|
import { z as z4 } from "zod";
|
|
328
327
|
var ConcatNodeFunction = (inputs) => {
|
|
329
|
-
console.log("\u{1F517} ConcatNode - Input:", { input1: inputs.input1 || "", input2: inputs.input2 || "" });
|
|
330
328
|
const input1 = inputs.input1 || "";
|
|
331
329
|
const input2 = inputs.input2 || "";
|
|
332
330
|
const result = `${input1}${input2}`;
|
|
333
|
-
console.log("\u{1F517} ConcatNode - Output:", result);
|
|
334
331
|
return {
|
|
335
332
|
output: result,
|
|
336
333
|
function: ConcatNodeFunction,
|
|
@@ -638,7 +635,6 @@ var IaAgentNode = {
|
|
|
638
635
|
},
|
|
639
636
|
{
|
|
640
637
|
id: "agent",
|
|
641
|
-
// O output agora é o próprio agente
|
|
642
638
|
label: "Agent",
|
|
643
639
|
type: "agent",
|
|
644
640
|
required: true,
|
|
@@ -651,15 +647,15 @@ var IaAgentNode = {
|
|
|
651
647
|
}
|
|
652
648
|
},
|
|
653
649
|
{
|
|
654
|
-
id: "
|
|
655
|
-
label: "
|
|
650
|
+
id: "response",
|
|
651
|
+
label: "Response",
|
|
656
652
|
type: "string",
|
|
657
653
|
required: true,
|
|
658
654
|
typeable: false,
|
|
659
655
|
handle: {
|
|
660
656
|
type: "output",
|
|
661
|
-
label: "
|
|
662
|
-
name: "
|
|
657
|
+
label: "response",
|
|
658
|
+
name: "response",
|
|
663
659
|
fieldType: "string"
|
|
664
660
|
}
|
|
665
661
|
}
|
|
@@ -669,8 +665,109 @@ var IaAgentNode = {
|
|
|
669
665
|
// src/nodes/ia/agent/function.ts
|
|
670
666
|
import { createReactAgent } from "@langchain/langgraph/prebuilt";
|
|
671
667
|
import { SystemMessage } from "@langchain/core/messages";
|
|
668
|
+
|
|
669
|
+
// src/utils/llm-factory.ts
|
|
670
|
+
import { GraphQLClient, gql } from "graphql-request";
|
|
671
|
+
import { ChatGoogle } from "@langchain/google-gauth";
|
|
672
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
673
|
+
var GRAPHQL_ENDPOINT = process.env["GRAPHQL_URL"] || "http://localhost:3001/graphql";
|
|
674
|
+
var GET_INTEGRATIONS_QUERY = gql`
|
|
675
|
+
query GetIntegrations($where: IntegrationWhereInput) {
|
|
676
|
+
getIntegrations(where: $where) {
|
|
677
|
+
status
|
|
678
|
+
message
|
|
679
|
+
data {
|
|
680
|
+
id
|
|
681
|
+
status
|
|
682
|
+
data
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
`;
|
|
687
|
+
async function createLLMFromModel(modelConfig, authToken, streaming = false) {
|
|
688
|
+
if (modelConfig?.invoke || modelConfig?.call) {
|
|
689
|
+
return modelConfig;
|
|
690
|
+
}
|
|
691
|
+
if (!modelConfig?.model || !modelConfig?.integrationId) {
|
|
692
|
+
throw new Error('Model config deve conter "model" e "integrationId"');
|
|
693
|
+
}
|
|
694
|
+
const { model, integrationId } = modelConfig;
|
|
695
|
+
const client = new GraphQLClient(GRAPHQL_ENDPOINT, {
|
|
696
|
+
headers: {
|
|
697
|
+
Authorization: `Bearer ${authToken}`,
|
|
698
|
+
"x-tenant-id": "65d62c52-0c09-473a-8895-359afbed3f5a"
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
let integrationData;
|
|
702
|
+
try {
|
|
703
|
+
const response = await client.request(
|
|
704
|
+
GET_INTEGRATIONS_QUERY,
|
|
705
|
+
{
|
|
706
|
+
where: {
|
|
707
|
+
id: {
|
|
708
|
+
eq: integrationId
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
);
|
|
713
|
+
if (!response.getIntegrations?.data?.[0]) {
|
|
714
|
+
throw new Error(`Integra\xE7\xE3o ${integrationId} n\xE3o encontrada`);
|
|
715
|
+
}
|
|
716
|
+
integrationData = response.getIntegrations.data[0];
|
|
717
|
+
} catch (error) {
|
|
718
|
+
console.error("Erro ao buscar integra\xE7\xE3o:", error);
|
|
719
|
+
throw new Error(
|
|
720
|
+
`Falha ao buscar integra\xE7\xE3o: ${error instanceof Error ? error.message : "Erro desconhecido"}`
|
|
721
|
+
);
|
|
722
|
+
}
|
|
723
|
+
const apiKey = integrationData.data?.["token"] || integrationData.data?.["token"];
|
|
724
|
+
if (!apiKey) {
|
|
725
|
+
throw new Error(`API Key n\xE3o encontrada na integra\xE7\xE3o ${integrationId}`);
|
|
726
|
+
}
|
|
727
|
+
const provider = integrationData.data?.provider?.toLowerCase() || inferProviderFromModel(model);
|
|
728
|
+
switch (provider) {
|
|
729
|
+
case "gemini":
|
|
730
|
+
return new ChatGoogle({
|
|
731
|
+
model: "gemini-flash-latest",
|
|
732
|
+
apiKey,
|
|
733
|
+
streaming
|
|
734
|
+
});
|
|
735
|
+
case "openai":
|
|
736
|
+
return new ChatOpenAI({
|
|
737
|
+
model,
|
|
738
|
+
openAIApiKey: apiKey,
|
|
739
|
+
streaming
|
|
740
|
+
});
|
|
741
|
+
case "openrouter":
|
|
742
|
+
return new ChatOpenAI({
|
|
743
|
+
model,
|
|
744
|
+
openAIApiKey: apiKey,
|
|
745
|
+
configuration: {
|
|
746
|
+
baseURL: "https://openrouter.ai/api/v1"
|
|
747
|
+
},
|
|
748
|
+
streaming
|
|
749
|
+
});
|
|
750
|
+
default:
|
|
751
|
+
throw new Error(
|
|
752
|
+
`Provider "${provider}" n\xE3o suportado. Providers dispon\xEDveis: gemini, openai, openrouter`
|
|
753
|
+
);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
function inferProviderFromModel(model) {
|
|
757
|
+
const modelLower = model.toLowerCase();
|
|
758
|
+
if (modelLower.includes("gemini") || modelLower.includes("palm")) {
|
|
759
|
+
return "gemini";
|
|
760
|
+
}
|
|
761
|
+
if (modelLower.includes("gpt") || modelLower.includes("o1") || modelLower.includes("o3")) {
|
|
762
|
+
return "openai";
|
|
763
|
+
}
|
|
764
|
+
return "openrouter";
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
// src/nodes/ia/agent/function.ts
|
|
672
768
|
var IaAgentNodeFunction = async (inputs) => {
|
|
673
|
-
const { model, tools, systemMessage, name, message } = inputs.fieldValues
|
|
769
|
+
const { model, tools, systemMessage, name, message } = inputs.fieldValues;
|
|
770
|
+
const authToken = inputs.authToken;
|
|
674
771
|
if (!name) {
|
|
675
772
|
throw new Error("Agent 'name' is required. Please provide a unique name for the agent in the node properties.");
|
|
676
773
|
}
|
|
@@ -687,8 +784,20 @@ var IaAgentNodeFunction = async (inputs) => {
|
|
|
687
784
|
|
|
688
785
|
IMPORTANT: You must base your response on the last message in the conversation history.`;
|
|
689
786
|
const finalSystemMessage = new SystemMessage(finalSystemMessageContent);
|
|
787
|
+
let llmInstance;
|
|
788
|
+
if (model?.integrationId) {
|
|
789
|
+
if (!authToken) {
|
|
790
|
+
throw new Error("Auth token is required to instantiate LLM from integration");
|
|
791
|
+
}
|
|
792
|
+
const streaming = Boolean(inputs?.stream);
|
|
793
|
+
llmInstance = await createLLMFromModel(model, authToken, streaming);
|
|
794
|
+
} else if (typeof model?.bindTools === "function") {
|
|
795
|
+
llmInstance = model;
|
|
796
|
+
} else {
|
|
797
|
+
throw new Error("Invalid model: must have integrationId or be a valid LLM instance with bindTools method");
|
|
798
|
+
}
|
|
690
799
|
const agent = createReactAgent({
|
|
691
|
-
llm:
|
|
800
|
+
llm: llmInstance,
|
|
692
801
|
tools: toolsArray,
|
|
693
802
|
messageModifier: finalSystemMessage
|
|
694
803
|
});
|
|
@@ -864,15 +973,25 @@ var AiSupervisorNodeFunction = async (fieldValues) => {
|
|
|
864
973
|
const systemMessage = inner.systemMessage ?? outer.systemMessage;
|
|
865
974
|
const stream = (typeof outer.stream === "boolean" ? outer.stream : inner.stream) ?? false;
|
|
866
975
|
const emitter = outer.emitter ?? inner.emitter;
|
|
976
|
+
const authToken = outer.authToken ?? inner.authToken;
|
|
867
977
|
if (!model) throw new Error("Model is required for AiSupervisorNode");
|
|
868
978
|
if (!agents) throw new Error("Agents are required for AiSupervisorNode.");
|
|
869
979
|
try {
|
|
870
980
|
const supervisorAgents = extractSupervisorAgents(agents);
|
|
871
981
|
if (supervisorAgents.length === 0) throw new Error("No valid agents were extracted from the 'agents' input.");
|
|
872
982
|
if (supervisorAgents.some((agent) => !agent.name)) throw new Error("All agents must have a name.");
|
|
983
|
+
let llmInstance;
|
|
984
|
+
if (model?.model && model?.integrationId) {
|
|
985
|
+
if (!authToken) {
|
|
986
|
+
throw new Error("Auth token is required to instantiate LLM from integration 3");
|
|
987
|
+
}
|
|
988
|
+
llmInstance = await createLLMFromModel(model, authToken, stream);
|
|
989
|
+
} else {
|
|
990
|
+
llmInstance = model;
|
|
991
|
+
}
|
|
873
992
|
const finalSystemPrompt = systemMessage || "You are a supervisor...";
|
|
874
993
|
const workflow = createSupervisor({
|
|
875
|
-
llm:
|
|
994
|
+
llm: llmInstance,
|
|
876
995
|
agents: supervisorAgents,
|
|
877
996
|
prompt: finalSystemPrompt
|
|
878
997
|
});
|
|
@@ -882,7 +1001,6 @@ var AiSupervisorNodeFunction = async (fieldValues) => {
|
|
|
882
1001
|
});
|
|
883
1002
|
if (stream && emitter) {
|
|
884
1003
|
try {
|
|
885
|
-
console.log("\u{1F504} Starting streaming mode...");
|
|
886
1004
|
const streamIterator = await app.stream(
|
|
887
1005
|
{ messages: [new HumanMessage({ content: message })] },
|
|
888
1006
|
{ recursionLimit: 150, configurable: { thread_id: "conversation" } }
|
|
@@ -1047,7 +1165,8 @@ var AiToolNode = {
|
|
|
1047
1165
|
label: "Tool",
|
|
1048
1166
|
name: "tool",
|
|
1049
1167
|
fieldType: "tool",
|
|
1050
|
-
required: true
|
|
1168
|
+
required: true,
|
|
1169
|
+
acceptTypes: ["tool"]
|
|
1051
1170
|
}
|
|
1052
1171
|
}
|
|
1053
1172
|
]
|
|
@@ -1100,76 +1219,6 @@ var AiToolNodeFunction = async (fieldValues) => {
|
|
|
1100
1219
|
};
|
|
1101
1220
|
};
|
|
1102
1221
|
|
|
1103
|
-
// src/nodes/ia/model/data.ts
|
|
1104
|
-
var IaModelNode = {
|
|
1105
|
-
label: "AI Model",
|
|
1106
|
-
type: "IaModelNode",
|
|
1107
|
-
category: "step",
|
|
1108
|
-
description: "AI Model",
|
|
1109
|
-
icon: "\u{1F916}",
|
|
1110
|
-
tags: {
|
|
1111
|
-
execution: "async",
|
|
1112
|
-
group: "IA"
|
|
1113
|
-
},
|
|
1114
|
-
fields: [
|
|
1115
|
-
{
|
|
1116
|
-
id: "model",
|
|
1117
|
-
label: "Model",
|
|
1118
|
-
type: "select",
|
|
1119
|
-
required: true,
|
|
1120
|
-
defaultValue: "gemini-2.5-pro",
|
|
1121
|
-
options: [
|
|
1122
|
-
{ label: "Gemini 2.5 Pro", value: "gemini-2.5-pro" },
|
|
1123
|
-
{ label: "Gemini 2.5 Flash", value: "gemini-2.5-flash" },
|
|
1124
|
-
{ label: "Gemini 2.5 Flash Lite", value: "gemini-2.5-flash-lite" },
|
|
1125
|
-
{ label: "Gemini 2.0 Flash", value: "gemini-2.0-flash" },
|
|
1126
|
-
{ label: "Gemini 2.0 Flash Lite", value: "gemini-2.0-flash-lite" }
|
|
1127
|
-
]
|
|
1128
|
-
},
|
|
1129
|
-
{
|
|
1130
|
-
id: "apiKey",
|
|
1131
|
-
label: "API Key",
|
|
1132
|
-
type: "string",
|
|
1133
|
-
required: true
|
|
1134
|
-
},
|
|
1135
|
-
{
|
|
1136
|
-
id: "model",
|
|
1137
|
-
label: "Model",
|
|
1138
|
-
type: "model",
|
|
1139
|
-
required: true,
|
|
1140
|
-
typeable: false,
|
|
1141
|
-
handle: {
|
|
1142
|
-
type: "output",
|
|
1143
|
-
label: "Model",
|
|
1144
|
-
name: "model",
|
|
1145
|
-
fieldType: "model",
|
|
1146
|
-
required: true
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
]
|
|
1150
|
-
};
|
|
1151
|
-
|
|
1152
|
-
// src/nodes/ia/model/function.ts
|
|
1153
|
-
import { ChatGoogle } from "@langchain/google-gauth";
|
|
1154
|
-
var IaModelNodeFunction = async (inputs) => {
|
|
1155
|
-
const fieldValues = inputs.fieldValues || inputs;
|
|
1156
|
-
const { model, apiKey } = fieldValues;
|
|
1157
|
-
const stream = Boolean(inputs?.stream || fieldValues?.stream);
|
|
1158
|
-
if (!model || !apiKey) {
|
|
1159
|
-
console.error("\u274C Model e apiKey s\xE3o obrigat\xF3rios para IaModelNode");
|
|
1160
|
-
console.error("\u274C Received:", { model, apiKey });
|
|
1161
|
-
throw new Error("Model e apiKey s\xE3o obrigat\xF3rios");
|
|
1162
|
-
}
|
|
1163
|
-
const llm = new ChatGoogle({
|
|
1164
|
-
model,
|
|
1165
|
-
apiKey,
|
|
1166
|
-
streaming: stream
|
|
1167
|
-
});
|
|
1168
|
-
return {
|
|
1169
|
-
model: llm
|
|
1170
|
-
};
|
|
1171
|
-
};
|
|
1172
|
-
|
|
1173
1222
|
// src/nodes/ia/message/message.ts
|
|
1174
1223
|
import { z as z8 } from "zod";
|
|
1175
1224
|
var IaMessageNodeSchema = z8.object({
|
|
@@ -1177,21 +1226,33 @@ var IaMessageNodeSchema = z8.object({
|
|
|
1177
1226
|
systemMessage: z8.string().optional().describe("System message for context"),
|
|
1178
1227
|
message: z8.string().describe("User message to send to the LLM")
|
|
1179
1228
|
});
|
|
1180
|
-
var IaMessageNodeFunction = async (
|
|
1229
|
+
var IaMessageNodeFunction = async (inputs) => {
|
|
1230
|
+
const fieldValues = inputs.fieldValues || inputs;
|
|
1181
1231
|
const { model, systemMessage, message } = fieldValues;
|
|
1232
|
+
const authToken = inputs.authToken;
|
|
1182
1233
|
if (!model) {
|
|
1183
1234
|
throw new Error("Model is required");
|
|
1184
1235
|
}
|
|
1185
1236
|
if (!message) {
|
|
1186
1237
|
throw new Error("Message is required");
|
|
1187
1238
|
}
|
|
1239
|
+
let llmInstance;
|
|
1240
|
+
if (model?.model && model?.integrationId) {
|
|
1241
|
+
if (!authToken) {
|
|
1242
|
+
throw new Error("Auth token is required to instantiate LLM from integration2 ");
|
|
1243
|
+
}
|
|
1244
|
+
const streaming = Boolean(inputs?.stream);
|
|
1245
|
+
llmInstance = await createLLMFromModel(model, authToken, streaming);
|
|
1246
|
+
} else {
|
|
1247
|
+
llmInstance = model;
|
|
1248
|
+
}
|
|
1188
1249
|
const messages = [];
|
|
1189
1250
|
if (systemMessage) {
|
|
1190
1251
|
messages.push(["system", systemMessage]);
|
|
1191
1252
|
}
|
|
1192
1253
|
messages.push(["human", message]);
|
|
1193
1254
|
try {
|
|
1194
|
-
const response = await
|
|
1255
|
+
const response = await llmInstance.invoke(messages);
|
|
1195
1256
|
return {
|
|
1196
1257
|
output: response.content,
|
|
1197
1258
|
response: response.content,
|
|
@@ -1427,7 +1488,6 @@ var nodes = [
|
|
|
1427
1488
|
ConcatNode,
|
|
1428
1489
|
OutputNode,
|
|
1429
1490
|
ChatOutputNode,
|
|
1430
|
-
IaModelNode,
|
|
1431
1491
|
IaMessageNode,
|
|
1432
1492
|
IaAgentNode,
|
|
1433
1493
|
AiToolNode,
|
|
@@ -1444,10 +1504,6 @@ var NUMBER_ID = "700207253183039";
|
|
|
1444
1504
|
var TOKEN = "EAAUuy5eznhEBPQUOoF07SUTSVjgNIX9eZCWSKPYQhzHiXeEp4Qj3g47bZAPcZAgs8P2B5cZBH9YJjzq0HKNXfA14kaK5Cp2DZCmxzV60MgWlsY1yKavb2qXAQcydoHTTLKcWO53w6ZB7JNzZBeIpZBTb9cB0teRzfX3kjrZBc7utyKq2ZCZCCOQ74pZA28gnmQYzp24oZBQpf7BmuNHgndFVlTba5drxgcpERyNl1dUIDhky7NIruggZDZD";
|
|
1445
1505
|
var WhatsappStartChatFunction = async (fieldValues) => {
|
|
1446
1506
|
const { phoneNumber, template } = fieldValues;
|
|
1447
|
-
console.log({
|
|
1448
|
-
phoneNumber,
|
|
1449
|
-
template
|
|
1450
|
-
});
|
|
1451
1507
|
const response = await fetch(`https://graph.facebook.com/v23.0/${NUMBER_ID}/messages`, {
|
|
1452
1508
|
method: "POST",
|
|
1453
1509
|
headers: {
|
|
@@ -1508,10 +1564,6 @@ var NUMBER_ID2 = "700207253183039";
|
|
|
1508
1564
|
var TOKEN2 = "EAAUuy5eznhEBPWw62uE6cs4oZAW6WvpsiF9RBjTGDjg8H74GouBMl1MBifCuA572AVMp53T83pBuSaMJUcWMDIGxvXbxaU6RFTyXOuKkhUPkF3Boc7QbmRuUWSFuyvkjZCyA7ngAg2NXV8nYzzZCleSuFQD487NN2mat7sHPx2pMHuN95IcaevyKLnuz5Om2Bp36JihQweodc517aH2Krv70jqNKKzBjoGVziWNnOhULQZDZD";
|
|
1509
1565
|
var WhatsappSendMessageFunction = async (fieldValues) => {
|
|
1510
1566
|
const { phoneNumber, message } = fieldValues;
|
|
1511
|
-
console.log({
|
|
1512
|
-
phoneNumber,
|
|
1513
|
-
message
|
|
1514
|
-
});
|
|
1515
1567
|
const response = await fetch(`https://graph.facebook.com/v23.0/${NUMBER_ID2}/messages`, {
|
|
1516
1568
|
method: "POST",
|
|
1517
1569
|
headers: {
|
|
@@ -1549,7 +1601,6 @@ var nodeFunctions = {
|
|
|
1549
1601
|
ManualTrigger: ManualTriggerNodeFunction,
|
|
1550
1602
|
HttpOutput: HttpOutputNodeFunction,
|
|
1551
1603
|
ConcatNode: ConcatNodeFunction,
|
|
1552
|
-
IaModelNode: IaModelNodeFunction,
|
|
1553
1604
|
IaMessageNode: IaMessageNodeFunction,
|
|
1554
1605
|
IaAgentNode: IaAgentNodeFunction,
|
|
1555
1606
|
AiToolNode: AiToolNodeFunction,
|
|
@@ -1972,8 +2023,6 @@ export {
|
|
|
1972
2023
|
IaMessageNode,
|
|
1973
2024
|
IaMessageNodeFunction,
|
|
1974
2025
|
IaMessageNodeSchema,
|
|
1975
|
-
IaModelNode,
|
|
1976
|
-
IaModelNodeFunction,
|
|
1977
2026
|
QueryParamSchema,
|
|
1978
2027
|
RouteSchema,
|
|
1979
2028
|
WhatsappMessageTriggerNode,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomoz/workflows-nodes",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Atomoz Workflows - Node Library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -41,6 +41,8 @@
|
|
|
41
41
|
"@langchain/google-gauth": "^0.2.16",
|
|
42
42
|
"@langchain/langgraph": "^0.4.3",
|
|
43
43
|
"@langchain/langgraph-supervisor": "^0.0.17",
|
|
44
|
+
"@langchain/openai": "^0.6.3",
|
|
45
|
+
"graphql-request": "^7.2.0",
|
|
44
46
|
"tslib": "^2.3.0",
|
|
45
47
|
"zod": "^4.0.14"
|
|
46
48
|
},
|