@n8n/n8n-nodes-langchain 1.102.0 → 1.103.0
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/known/credentials.json +1 -0
- package/dist/known/nodes.json +4 -0
- package/dist/nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.js +7 -2
- package/dist/nodes/embeddings/EmbeddingsOpenAI/EmbeddingsOpenAi.node.js.map +1 -1
- package/dist/nodes/llms/LmChatAwsBedrock/LmChatAwsBedrock.node.js +2 -0
- package/dist/nodes/llms/LmChatAwsBedrock/LmChatAwsBedrock.node.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/McpClientTool.node.js +55 -5
- package/dist/nodes/mcp/McpClientTool/McpClientTool.node.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/loadOptions.js +11 -2
- package/dist/nodes/mcp/McpClientTool/loadOptions.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/types.js.map +1 -1
- package/dist/nodes/mcp/McpClientTool/utils.js +21 -11
- package/dist/nodes/mcp/McpClientTool/utils.js.map +1 -1
- package/dist/nodes/tools/ToolThink/ToolThink.node.js +5 -2
- package/dist/nodes/tools/ToolThink/ToolThink.node.js.map +1 -1
- package/dist/nodes/vendors/Anthropic/Anthropic.node.js +42 -0
- package/dist/nodes/vendors/Anthropic/Anthropic.node.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/descriptions.js +52 -0
- package/dist/nodes/vendors/Anthropic/actions/descriptions.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/document/analyze.operation.js +125 -0
- package/dist/nodes/vendors/Anthropic/actions/document/analyze.operation.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/document/index.js +64 -0
- package/dist/nodes/vendors/Anthropic/actions/document/index.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/file/delete.operation.js +61 -0
- package/dist/nodes/vendors/Anthropic/actions/file/delete.operation.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/file/get.operation.js +63 -0
- package/dist/nodes/vendors/Anthropic/actions/file/get.operation.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/file/index.js +94 -0
- package/dist/nodes/vendors/Anthropic/actions/file/index.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/file/list.operation.js +108 -0
- package/dist/nodes/vendors/Anthropic/actions/file/list.operation.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/file/upload.operation.js +126 -0
- package/dist/nodes/vendors/Anthropic/actions/file/upload.operation.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/image/analyze.operation.js +125 -0
- package/dist/nodes/vendors/Anthropic/actions/image/analyze.operation.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/image/index.js +64 -0
- package/dist/nodes/vendors/Anthropic/actions/image/index.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/node.type.js +17 -0
- package/dist/nodes/vendors/Anthropic/actions/node.type.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/prompt/generate.operation.js +87 -0
- package/dist/nodes/vendors/Anthropic/actions/prompt/generate.operation.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/prompt/improve.operation.js +154 -0
- package/dist/nodes/vendors/Anthropic/actions/prompt/improve.operation.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/prompt/index.js +95 -0
- package/dist/nodes/vendors/Anthropic/actions/prompt/index.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/prompt/templatize.operation.js +146 -0
- package/dist/nodes/vendors/Anthropic/actions/prompt/templatize.operation.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/router.js +93 -0
- package/dist/nodes/vendors/Anthropic/actions/router.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/text/index.js +64 -0
- package/dist/nodes/vendors/Anthropic/actions/text/index.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/text/message.operation.js +540 -0
- package/dist/nodes/vendors/Anthropic/actions/text/message.operation.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/actions/versionDescription.js +125 -0
- package/dist/nodes/vendors/Anthropic/actions/versionDescription.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/anthropic.svg +1 -0
- package/dist/nodes/vendors/Anthropic/helpers/baseAnalyze.js +109 -0
- package/dist/nodes/vendors/Anthropic/helpers/baseAnalyze.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/helpers/interfaces.js +17 -0
- package/dist/nodes/vendors/Anthropic/helpers/interfaces.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/helpers/utils.js +84 -0
- package/dist/nodes/vendors/Anthropic/helpers/utils.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/methods/index.js +39 -0
- package/dist/nodes/vendors/Anthropic/methods/index.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/methods/listSearch.js +42 -0
- package/dist/nodes/vendors/Anthropic/methods/listSearch.js.map +1 -0
- package/dist/nodes/vendors/Anthropic/transport/index.js +57 -0
- package/dist/nodes/vendors/Anthropic/transport/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/router.js +1 -1
- package/dist/nodes/vendors/OpenAi/actions/router.js.map +1 -1
- package/dist/types/credentials.json +1 -1
- package/dist/types/nodes.json +5 -4
- package/package.json +5 -4
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var prompt_exports = {};
|
|
30
|
+
__export(prompt_exports, {
|
|
31
|
+
description: () => description,
|
|
32
|
+
generate: () => generate,
|
|
33
|
+
improve: () => improve,
|
|
34
|
+
templatize: () => templatize
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(prompt_exports);
|
|
37
|
+
var generate = __toESM(require("./generate.operation"));
|
|
38
|
+
var improve = __toESM(require("./improve.operation"));
|
|
39
|
+
var templatize = __toESM(require("./templatize.operation"));
|
|
40
|
+
const description = [
|
|
41
|
+
{
|
|
42
|
+
displayName: "Operation",
|
|
43
|
+
name: "operation",
|
|
44
|
+
type: "options",
|
|
45
|
+
noDataExpression: true,
|
|
46
|
+
options: [
|
|
47
|
+
{
|
|
48
|
+
name: "Generate Prompt",
|
|
49
|
+
value: "generate",
|
|
50
|
+
action: "Generate a prompt",
|
|
51
|
+
description: "Generate a prompt for a model"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "Improve Prompt",
|
|
55
|
+
value: "improve",
|
|
56
|
+
action: "Improve a prompt",
|
|
57
|
+
description: "Improve a prompt for a model"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "Templatize Prompt",
|
|
61
|
+
value: "templatize",
|
|
62
|
+
action: "Templatize a prompt",
|
|
63
|
+
description: "Templatize a prompt for a model"
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
default: "generate",
|
|
67
|
+
displayOptions: {
|
|
68
|
+
show: {
|
|
69
|
+
resource: ["prompt"]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
displayName: 'The <a href="https://docs.anthropic.com/en/api/prompt-tools-generate">prompt tools APIs</a> are in a closed research preview. Your organization must request access to use them.',
|
|
75
|
+
name: "experimentalNotice",
|
|
76
|
+
type: "notice",
|
|
77
|
+
default: "",
|
|
78
|
+
displayOptions: {
|
|
79
|
+
show: {
|
|
80
|
+
resource: ["prompt"]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
...generate.description,
|
|
85
|
+
...improve.description,
|
|
86
|
+
...templatize.description
|
|
87
|
+
];
|
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
+
0 && (module.exports = {
|
|
90
|
+
description,
|
|
91
|
+
generate,
|
|
92
|
+
improve,
|
|
93
|
+
templatize
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../nodes/vendors/Anthropic/actions/prompt/index.ts"],"sourcesContent":["import type { INodeProperties } from 'n8n-workflow';\n\nimport * as generate from './generate.operation';\nimport * as improve from './improve.operation';\nimport * as templatize from './templatize.operation';\n\nexport { generate, improve, templatize };\n\nexport const description: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Operation',\n\t\tname: 'operation',\n\t\ttype: 'options',\n\t\tnoDataExpression: true,\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Generate Prompt',\n\t\t\t\tvalue: 'generate',\n\t\t\t\taction: 'Generate a prompt',\n\t\t\t\tdescription: 'Generate a prompt for a model',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Improve Prompt',\n\t\t\t\tvalue: 'improve',\n\t\t\t\taction: 'Improve a prompt',\n\t\t\t\tdescription: 'Improve a prompt for a model',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Templatize Prompt',\n\t\t\t\tvalue: 'templatize',\n\t\t\t\taction: 'Templatize a prompt',\n\t\t\t\tdescription: 'Templatize a prompt for a model',\n\t\t\t},\n\t\t],\n\t\tdefault: 'generate',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tresource: ['prompt'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName:\n\t\t\t'The <a href=\"https://docs.anthropic.com/en/api/prompt-tools-generate\">prompt tools APIs</a> are in a closed research preview. Your organization must request access to use them.',\n\t\tname: 'experimentalNotice',\n\t\ttype: 'notice',\n\t\tdefault: '',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tresource: ['prompt'],\n\t\t\t},\n\t\t},\n\t},\n\t...generate.description,\n\t...improve.description,\n\t...templatize.description,\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,eAA0B;AAC1B,cAAyB;AACzB,iBAA4B;AAIrB,MAAM,cAAiC;AAAA,EAC7C;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,kBAAkB;AAAA,IAClB,SAAS;AAAA,MACR;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,MACA;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,IACD;AAAA,IACA,SAAS;AAAA,IACT,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,UAAU,CAAC,QAAQ;AAAA,MACpB;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,aACC;AAAA,IACD,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,UAAU,CAAC,QAAQ;AAAA,MACpB;AAAA,IACD;AAAA,EACD;AAAA,EACA,GAAG,SAAS;AAAA,EACZ,GAAG,QAAQ;AAAA,EACX,GAAG,WAAW;AACf;","names":[]}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var templatize_operation_exports = {};
|
|
20
|
+
__export(templatize_operation_exports, {
|
|
21
|
+
description: () => description,
|
|
22
|
+
execute: () => execute
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(templatize_operation_exports);
|
|
25
|
+
var import_n8n_workflow = require("n8n-workflow");
|
|
26
|
+
var import_transport = require("../../transport");
|
|
27
|
+
const properties = [
|
|
28
|
+
{
|
|
29
|
+
displayName: "Messages",
|
|
30
|
+
name: "messages",
|
|
31
|
+
type: "fixedCollection",
|
|
32
|
+
typeOptions: {
|
|
33
|
+
sortable: true,
|
|
34
|
+
multipleValues: true
|
|
35
|
+
},
|
|
36
|
+
description: "Messages that constitute the prompt to be templatized",
|
|
37
|
+
placeholder: "Add Message",
|
|
38
|
+
default: { values: [{ content: "", role: "user" }] },
|
|
39
|
+
options: [
|
|
40
|
+
{
|
|
41
|
+
displayName: "Values",
|
|
42
|
+
name: "values",
|
|
43
|
+
values: [
|
|
44
|
+
{
|
|
45
|
+
displayName: "Prompt",
|
|
46
|
+
name: "content",
|
|
47
|
+
type: "string",
|
|
48
|
+
description: "The content of the message to be sent",
|
|
49
|
+
default: "",
|
|
50
|
+
placeholder: "e.g. Translate hello to German",
|
|
51
|
+
typeOptions: {
|
|
52
|
+
rows: 2
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
displayName: "Role",
|
|
57
|
+
name: "role",
|
|
58
|
+
type: "options",
|
|
59
|
+
description: "Role in shaping the model's response, it tells the model how it should behave and interact with the user",
|
|
60
|
+
options: [
|
|
61
|
+
{
|
|
62
|
+
name: "User",
|
|
63
|
+
value: "user",
|
|
64
|
+
description: "Send a message as a user and get a response from the model"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "Assistant",
|
|
68
|
+
value: "assistant",
|
|
69
|
+
description: "Tell the model to adopt a specific tone or personality"
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
default: "user"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
displayName: "Simplify Output",
|
|
80
|
+
name: "simplify",
|
|
81
|
+
type: "boolean",
|
|
82
|
+
default: true,
|
|
83
|
+
description: "Whether to return a simplified version of the response instead of the raw data"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
displayName: "Options",
|
|
87
|
+
name: "options",
|
|
88
|
+
placeholder: "Add Option",
|
|
89
|
+
type: "collection",
|
|
90
|
+
default: {},
|
|
91
|
+
options: [
|
|
92
|
+
{
|
|
93
|
+
displayName: "System Message",
|
|
94
|
+
name: "system",
|
|
95
|
+
type: "string",
|
|
96
|
+
description: "The existing system prompt to templatize",
|
|
97
|
+
default: "",
|
|
98
|
+
placeholder: "e.g. You are a professional English to German translator"
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
];
|
|
103
|
+
const displayOptions = {
|
|
104
|
+
show: {
|
|
105
|
+
operation: ["templatize"],
|
|
106
|
+
resource: ["prompt"]
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const description = (0, import_n8n_workflow.updateDisplayOptions)(displayOptions, properties);
|
|
110
|
+
async function execute(i) {
|
|
111
|
+
const messages = this.getNodeParameter("messages.values", i, []);
|
|
112
|
+
const simplify = this.getNodeParameter("simplify", i, true);
|
|
113
|
+
const options = this.getNodeParameter("options", i, {});
|
|
114
|
+
const body = {
|
|
115
|
+
messages,
|
|
116
|
+
system: options.system
|
|
117
|
+
};
|
|
118
|
+
const response = await import_transport.apiRequest.call(this, "POST", "/v1/experimental/templatize_prompt", {
|
|
119
|
+
body,
|
|
120
|
+
enableAnthropicBetas: { promptTools: true }
|
|
121
|
+
});
|
|
122
|
+
if (simplify) {
|
|
123
|
+
return [
|
|
124
|
+
{
|
|
125
|
+
json: {
|
|
126
|
+
messages: response.messages,
|
|
127
|
+
system: response.system,
|
|
128
|
+
variable_values: response.variable_values
|
|
129
|
+
},
|
|
130
|
+
pairedItem: { item: i }
|
|
131
|
+
}
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
return [
|
|
135
|
+
{
|
|
136
|
+
json: { ...response },
|
|
137
|
+
pairedItem: { item: i }
|
|
138
|
+
}
|
|
139
|
+
];
|
|
140
|
+
}
|
|
141
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
142
|
+
0 && (module.exports = {
|
|
143
|
+
description,
|
|
144
|
+
execute
|
|
145
|
+
});
|
|
146
|
+
//# sourceMappingURL=templatize.operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../nodes/vendors/Anthropic/actions/prompt/templatize.operation.ts"],"sourcesContent":["import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';\nimport { updateDisplayOptions } from 'n8n-workflow';\n\nimport type { Message, TemplatizeResponse } from '../../helpers/interfaces';\nimport { apiRequest } from '../../transport';\n\nconst properties: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Messages',\n\t\tname: 'messages',\n\t\ttype: 'fixedCollection',\n\t\ttypeOptions: {\n\t\t\tsortable: true,\n\t\t\tmultipleValues: true,\n\t\t},\n\t\tdescription: 'Messages that constitute the prompt to be templatized',\n\t\tplaceholder: 'Add Message',\n\t\tdefault: { values: [{ content: '', role: 'user' }] },\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Values',\n\t\t\t\tname: 'values',\n\t\t\t\tvalues: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Prompt',\n\t\t\t\t\t\tname: 'content',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The content of the message to be sent',\n\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\tplaceholder: 'e.g. Translate hello to German',\n\t\t\t\t\t\ttypeOptions: {\n\t\t\t\t\t\t\trows: 2,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Role',\n\t\t\t\t\t\tname: 'role',\n\t\t\t\t\t\ttype: 'options',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Role in shaping the model's response, it tells the model how it should behave and interact with the user\",\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'User',\n\t\t\t\t\t\t\t\tvalue: 'user',\n\t\t\t\t\t\t\t\tdescription: 'Send a message as a user and get a response from the model',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: 'Assistant',\n\t\t\t\t\t\t\t\tvalue: 'assistant',\n\t\t\t\t\t\t\t\tdescription: 'Tell the model to adopt a specific tone or personality',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdefault: 'user',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tdisplayName: 'Simplify Output',\n\t\tname: 'simplify',\n\t\ttype: 'boolean',\n\t\tdefault: true,\n\t\tdescription: 'Whether to return a simplified version of the response instead of the raw data',\n\t},\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tplaceholder: 'Add Option',\n\t\ttype: 'collection',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'System Message',\n\t\t\t\tname: 'system',\n\t\t\t\ttype: 'string',\n\t\t\t\tdescription: 'The existing system prompt to templatize',\n\t\t\t\tdefault: '',\n\t\t\t\tplaceholder: 'e.g. You are a professional English to German translator',\n\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['templatize'],\n\t\tresource: ['prompt'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst messages = this.getNodeParameter('messages.values', i, []) as Message[];\n\tconst simplify = this.getNodeParameter('simplify', i, true) as boolean;\n\tconst options = this.getNodeParameter('options', i, {});\n\n\tconst body = {\n\t\tmessages,\n\t\tsystem: options.system,\n\t};\n\tconst response = (await apiRequest.call(this, 'POST', '/v1/experimental/templatize_prompt', {\n\t\tbody,\n\t\tenableAnthropicBetas: { promptTools: true },\n\t})) as TemplatizeResponse;\n\n\tif (simplify) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tjson: {\n\t\t\t\t\tmessages: response.messages,\n\t\t\t\t\tsystem: response.system,\n\t\t\t\t\tvariable_values: response.variable_values,\n\t\t\t\t},\n\t\t\t\tpairedItem: { item: i },\n\t\t\t},\n\t\t];\n\t}\n\n\treturn [\n\t\t{\n\t\t\tjson: { ...response },\n\t\t\tpairedItem: { item: i },\n\t\t},\n\t];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAqC;AAGrC,uBAA2B;AAE3B,MAAM,aAAgC;AAAA,EACrC;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,aAAa;AAAA,MACZ,UAAU;AAAA,MACV,gBAAgB;AAAA,IACjB;AAAA,IACA,aAAa;AAAA,IACb,aAAa;AAAA,IACb,SAAS,EAAE,QAAQ,CAAC,EAAE,SAAS,IAAI,MAAM,OAAO,CAAC,EAAE;AAAA,IACnD,SAAS;AAAA,MACR;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,QAAQ;AAAA,UACP;AAAA,YACC,aAAa;AAAA,YACb,MAAM;AAAA,YACN,MAAM;AAAA,YACN,aAAa;AAAA,YACb,SAAS;AAAA,YACT,aAAa;AAAA,YACb,aAAa;AAAA,cACZ,MAAM;AAAA,YACP;AAAA,UACD;AAAA,UACA;AAAA,YACC,aAAa;AAAA,YACb,MAAM;AAAA,YACN,MAAM;AAAA,YACN,aACC;AAAA,YACD,SAAS;AAAA,cACR;AAAA,gBACC,MAAM;AAAA,gBACN,OAAO;AAAA,gBACP,aAAa;AAAA,cACd;AAAA,cACA;AAAA,gBACC,MAAM;AAAA,gBACN,OAAO;AAAA,gBACP,aAAa;AAAA,cACd;AAAA,YACD;AAAA,YACA,SAAS;AAAA,UACV;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,EACd;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,aAAa;AAAA,IACb,MAAM;AAAA,IACN,SAAS,CAAC;AAAA,IACV,SAAS;AAAA,MACR;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,aAAa;AAAA,QACb,SAAS;AAAA,QACT,aAAa;AAAA,MACd;AAAA,IACD;AAAA,EACD;AACD;AAEA,MAAM,iBAAiB;AAAA,EACtB,MAAM;AAAA,IACL,WAAW,CAAC,YAAY;AAAA,IACxB,UAAU,CAAC,QAAQ;AAAA,EACpB;AACD;AAEO,MAAM,kBAAc,0CAAqB,gBAAgB,UAAU;AAE1E,eAAsB,QAAiC,GAA0C;AAChG,QAAM,WAAW,KAAK,iBAAiB,mBAAmB,GAAG,CAAC,CAAC;AAC/D,QAAM,WAAW,KAAK,iBAAiB,YAAY,GAAG,IAAI;AAC1D,QAAM,UAAU,KAAK,iBAAiB,WAAW,GAAG,CAAC,CAAC;AAEtD,QAAM,OAAO;AAAA,IACZ;AAAA,IACA,QAAQ,QAAQ;AAAA,EACjB;AACA,QAAM,WAAY,MAAM,4BAAW,KAAK,MAAM,QAAQ,sCAAsC;AAAA,IAC3F;AAAA,IACA,sBAAsB,EAAE,aAAa,KAAK;AAAA,EAC3C,CAAC;AAED,MAAI,UAAU;AACb,WAAO;AAAA,MACN;AAAA,QACC,MAAM;AAAA,UACL,UAAU,SAAS;AAAA,UACnB,QAAQ,SAAS;AAAA,UACjB,iBAAiB,SAAS;AAAA,QAC3B;AAAA,QACA,YAAY,EAAE,MAAM,EAAE;AAAA,MACvB;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AAAA,IACN;AAAA,MACC,MAAM,EAAE,GAAG,SAAS;AAAA,MACpB,YAAY,EAAE,MAAM,EAAE;AAAA,IACvB;AAAA,EACD;AACD;","names":[]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var router_exports = {};
|
|
30
|
+
__export(router_exports, {
|
|
31
|
+
router: () => router
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(router_exports);
|
|
34
|
+
var import_n8n_workflow = require("n8n-workflow");
|
|
35
|
+
var document = __toESM(require("./document"));
|
|
36
|
+
var file = __toESM(require("./file"));
|
|
37
|
+
var image = __toESM(require("./image"));
|
|
38
|
+
var prompt = __toESM(require("./prompt"));
|
|
39
|
+
var text = __toESM(require("./text"));
|
|
40
|
+
async function router() {
|
|
41
|
+
const returnData = [];
|
|
42
|
+
const items = this.getInputData();
|
|
43
|
+
const resource = this.getNodeParameter("resource", 0);
|
|
44
|
+
const operation = this.getNodeParameter("operation", 0);
|
|
45
|
+
const anthropicTypeData = {
|
|
46
|
+
resource,
|
|
47
|
+
operation
|
|
48
|
+
};
|
|
49
|
+
let execute;
|
|
50
|
+
switch (anthropicTypeData.resource) {
|
|
51
|
+
case "document":
|
|
52
|
+
execute = document[anthropicTypeData.operation].execute;
|
|
53
|
+
break;
|
|
54
|
+
case "file":
|
|
55
|
+
execute = file[anthropicTypeData.operation].execute;
|
|
56
|
+
break;
|
|
57
|
+
case "image":
|
|
58
|
+
execute = image[anthropicTypeData.operation].execute;
|
|
59
|
+
break;
|
|
60
|
+
case "prompt":
|
|
61
|
+
execute = prompt[anthropicTypeData.operation].execute;
|
|
62
|
+
break;
|
|
63
|
+
case "text":
|
|
64
|
+
execute = text[anthropicTypeData.operation].execute;
|
|
65
|
+
break;
|
|
66
|
+
default:
|
|
67
|
+
throw new import_n8n_workflow.NodeOperationError(
|
|
68
|
+
this.getNode(),
|
|
69
|
+
`The operation "${operation}" is not supported!`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
for (let i = 0; i < items.length; i++) {
|
|
73
|
+
try {
|
|
74
|
+
const responseData = await execute.call(this, i);
|
|
75
|
+
returnData.push(...responseData);
|
|
76
|
+
} catch (error) {
|
|
77
|
+
if (this.continueOnFail()) {
|
|
78
|
+
returnData.push({ json: { error: error.message }, pairedItem: { item: i } });
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
throw new import_n8n_workflow.NodeOperationError(this.getNode(), error, {
|
|
82
|
+
itemIndex: i,
|
|
83
|
+
description: error.description
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return [returnData];
|
|
88
|
+
}
|
|
89
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
90
|
+
0 && (module.exports = {
|
|
91
|
+
router
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../nodes/vendors/Anthropic/actions/router.ts"],"sourcesContent":["import { NodeOperationError, type IExecuteFunctions, type INodeExecutionData } from 'n8n-workflow';\n\nimport * as document from './document';\nimport * as file from './file';\nimport * as image from './image';\nimport type { AnthropicType } from './node.type';\nimport * as prompt from './prompt';\nimport * as text from './text';\n\nexport async function router(this: IExecuteFunctions) {\n\tconst returnData: INodeExecutionData[] = [];\n\n\tconst items = this.getInputData();\n\tconst resource = this.getNodeParameter('resource', 0);\n\tconst operation = this.getNodeParameter('operation', 0);\n\n\tconst anthropicTypeData = {\n\t\tresource,\n\t\toperation,\n\t} as AnthropicType;\n\n\tlet execute;\n\tswitch (anthropicTypeData.resource) {\n\t\tcase 'document':\n\t\t\texecute = document[anthropicTypeData.operation].execute;\n\t\t\tbreak;\n\t\tcase 'file':\n\t\t\texecute = file[anthropicTypeData.operation].execute;\n\t\t\tbreak;\n\t\tcase 'image':\n\t\t\texecute = image[anthropicTypeData.operation].execute;\n\t\t\tbreak;\n\t\tcase 'prompt':\n\t\t\texecute = prompt[anthropicTypeData.operation].execute;\n\t\t\tbreak;\n\t\tcase 'text':\n\t\t\texecute = text[anthropicTypeData.operation].execute;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t`The operation \"${operation}\" is not supported!`,\n\t\t\t);\n\t}\n\n\tfor (let i = 0; i < items.length; i++) {\n\t\ttry {\n\t\t\tconst responseData = await execute.call(this, i);\n\t\t\treturnData.push(...responseData);\n\t\t} catch (error) {\n\t\t\tif (this.continueOnFail()) {\n\t\t\t\treturnData.push({ json: { error: error.message }, pairedItem: { item: i } });\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthrow new NodeOperationError(this.getNode(), error, {\n\t\t\t\titemIndex: i,\n\t\t\t\tdescription: error.description,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn [returnData];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAoF;AAEpF,eAA0B;AAC1B,WAAsB;AACtB,YAAuB;AAEvB,aAAwB;AACxB,WAAsB;AAEtB,eAAsB,SAAgC;AACrD,QAAM,aAAmC,CAAC;AAE1C,QAAM,QAAQ,KAAK,aAAa;AAChC,QAAM,WAAW,KAAK,iBAAiB,YAAY,CAAC;AACpD,QAAM,YAAY,KAAK,iBAAiB,aAAa,CAAC;AAEtD,QAAM,oBAAoB;AAAA,IACzB;AAAA,IACA;AAAA,EACD;AAEA,MAAI;AACJ,UAAQ,kBAAkB,UAAU;AAAA,IACnC,KAAK;AACJ,gBAAU,SAAS,kBAAkB,SAAS,EAAE;AAChD;AAAA,IACD,KAAK;AACJ,gBAAU,KAAK,kBAAkB,SAAS,EAAE;AAC5C;AAAA,IACD,KAAK;AACJ,gBAAU,MAAM,kBAAkB,SAAS,EAAE;AAC7C;AAAA,IACD,KAAK;AACJ,gBAAU,OAAO,kBAAkB,SAAS,EAAE;AAC9C;AAAA,IACD,KAAK;AACJ,gBAAU,KAAK,kBAAkB,SAAS,EAAE;AAC5C;AAAA,IACD;AACC,YAAM,IAAI;AAAA,QACT,KAAK,QAAQ;AAAA,QACb,kBAAkB,SAAS;AAAA,MAC5B;AAAA,EACF;AAEA,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACtC,QAAI;AACH,YAAM,eAAe,MAAM,QAAQ,KAAK,MAAM,CAAC;AAC/C,iBAAW,KAAK,GAAG,YAAY;AAAA,IAChC,SAAS,OAAO;AACf,UAAI,KAAK,eAAe,GAAG;AAC1B,mBAAW,KAAK,EAAE,MAAM,EAAE,OAAO,MAAM,QAAQ,GAAG,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC;AAC3E;AAAA,MACD;AAEA,YAAM,IAAI,uCAAmB,KAAK,QAAQ,GAAG,OAAO;AAAA,QACnD,WAAW;AAAA,QACX,aAAa,MAAM;AAAA,MACpB,CAAC;AAAA,IACF;AAAA,EACD;AAEA,SAAO,CAAC,UAAU;AACnB;","names":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var text_exports = {};
|
|
30
|
+
__export(text_exports, {
|
|
31
|
+
description: () => description,
|
|
32
|
+
message: () => message
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(text_exports);
|
|
35
|
+
var message = __toESM(require("./message.operation"));
|
|
36
|
+
const description = [
|
|
37
|
+
{
|
|
38
|
+
displayName: "Operation",
|
|
39
|
+
name: "operation",
|
|
40
|
+
type: "options",
|
|
41
|
+
noDataExpression: true,
|
|
42
|
+
options: [
|
|
43
|
+
{
|
|
44
|
+
name: "Message a Model",
|
|
45
|
+
value: "message",
|
|
46
|
+
action: "Message a model",
|
|
47
|
+
description: "Create a completion with Anthropic model"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
default: "message",
|
|
51
|
+
displayOptions: {
|
|
52
|
+
show: {
|
|
53
|
+
resource: ["text"]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
...message.description
|
|
58
|
+
];
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
description,
|
|
62
|
+
message
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../nodes/vendors/Anthropic/actions/text/index.ts"],"sourcesContent":["import type { INodeProperties } from 'n8n-workflow';\n\nimport * as message from './message.operation';\n\nexport { message };\n\nexport const description: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Operation',\n\t\tname: 'operation',\n\t\ttype: 'options',\n\t\tnoDataExpression: true,\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Message a Model',\n\t\t\t\tvalue: 'message',\n\t\t\t\taction: 'Message a model',\n\t\t\t\tdescription: 'Create a completion with Anthropic model',\n\t\t\t},\n\t\t],\n\t\tdefault: 'message',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tresource: ['text'],\n\t\t\t},\n\t\t},\n\t},\n\t...message.description,\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,cAAyB;AAIlB,MAAM,cAAiC;AAAA,EAC7C;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,kBAAkB;AAAA,IAClB,SAAS;AAAA,MACR;AAAA,QACC,MAAM;AAAA,QACN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,aAAa;AAAA,MACd;AAAA,IACD;AAAA,IACA,SAAS;AAAA,IACT,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,UAAU,CAAC,MAAM;AAAA,MAClB;AAAA,IACD;AAAA,EACD;AAAA,EACA,GAAG,QAAQ;AACZ;","names":[]}
|