@n8n/n8n-nodes-langchain 0.12.2 → 0.14.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/build.tsbuildinfo +1 -1
- package/dist/credentials/AzureOpenAiApi.credentials.d.ts +8 -0
- package/dist/credentials/AzureOpenAiApi.credentials.js +44 -0
- package/dist/credentials/AzureOpenAiApi.credentials.js.map +1 -0
- package/dist/known/credentials.json +8 -0
- package/dist/known/nodes.json +12 -0
- package/dist/methods/defined.json +5 -1
- package/dist/methods/referenced.json +5 -1
- package/dist/nodes/agents/Agent/agents/ConversationalAgent/execute.js +3 -3
- package/dist/nodes/agents/Agent/agents/ConversationalAgent/execute.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/ReActAgent/execute.js +2 -2
- package/dist/nodes/agents/Agent/agents/ReActAgent/execute.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/other/handlers/mysql.d.ts +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/other/handlers/mysql.js +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/other/handlers/mysql.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/other/handlers/postgres.d.ts +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/other/handlers/postgres.js +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/other/handlers/postgres.js.map +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/other/handlers/sqlite.d.ts +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/other/handlers/sqlite.js +1 -1
- package/dist/nodes/agents/Agent/agents/SqlAgent/other/handlers/sqlite.js.map +1 -1
- package/dist/nodes/agents/OpenAiAssistant/OpenAiAssistant.node.js +1 -0
- package/dist/nodes/agents/OpenAiAssistant/OpenAiAssistant.node.js.map +1 -1
- package/dist/nodes/chains/ChainLLM/ChainLlm.node.js +2 -2
- package/dist/nodes/chains/ChainLLM/ChainLlm.node.js.map +1 -1
- package/dist/nodes/code/Code.node.js +2 -4
- package/dist/nodes/code/Code.node.js.map +1 -1
- package/dist/nodes/embeddings/EmbeddingsAzureOpenAi/EmbeddingsAzureOpenAi.node.d.ts +5 -0
- package/dist/nodes/embeddings/EmbeddingsAzureOpenAi/EmbeddingsAzureOpenAi.node.js +106 -0
- package/dist/nodes/embeddings/EmbeddingsAzureOpenAi/EmbeddingsAzureOpenAi.node.js.map +1 -0
- package/dist/nodes/embeddings/EmbeddingsAzureOpenAi/azure.svg +1 -0
- package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.d.ts +5 -0
- package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js +141 -0
- package/dist/nodes/llms/LmChatAzureOpenAi/LmChatAzureOpenAi.node.js.map +1 -0
- package/dist/nodes/llms/LmChatAzureOpenAi/azure.svg +1 -0
- package/dist/nodes/output_parser/OutputParserStructured/OutputParserStructured.node.js +1 -1
- package/dist/nodes/output_parser/OutputParserStructured/OutputParserStructured.node.js.map +1 -1
- package/dist/nodes/tools/ToolCode/ToolCode.node.js +14 -7
- package/dist/nodes/tools/ToolCode/ToolCode.node.js.map +1 -1
- package/dist/nodes/tools/ToolWorkflow/ToolWorkflow.node.js +26 -9
- package/dist/nodes/tools/ToolWorkflow/ToolWorkflow.node.js.map +1 -1
- package/dist/nodes/trigger/ChatTrigger/ChatTrigger.node.js.map +1 -1
- package/dist/nodes/vector_store/shared/createVectorStoreNode.js +2 -0
- package/dist/nodes/vector_store/shared/createVectorStoreNode.js.map +1 -1
- package/dist/nodes/vendors/OpenAi/OpenAi.node.d.ts +10 -0
- package/dist/nodes/vendors/OpenAi/OpenAi.node.js +20 -0
- package/dist/nodes/vendors/OpenAi/OpenAi.node.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/create.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/create.operation.js +211 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/create.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/deleteAssistant.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/deleteAssistant.operation.js +30 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/deleteAssistant.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/index.d.ts +8 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/index.js +88 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/list.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/list.operation.js +68 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/list.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/message.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/message.operation.js +149 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/message.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/update.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/update.operation.js +148 -0
- package/dist/nodes/vendors/OpenAi/actions/assistant/update.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/generate.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/generate.operation.js +168 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/generate.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/index.d.ts +6 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/index.js +82 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/transcribe.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/transcribe.operation.js +87 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/transcribe.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/translate.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/translate.operation.js +77 -0
- package/dist/nodes/vendors/OpenAi/actions/audio/translate.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/descriptions.d.ts +3 -0
- package/dist/nodes/vendors/OpenAi/actions/descriptions.js +53 -0
- package/dist/nodes/vendors/OpenAi/actions/descriptions.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/file/deleteFile.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/file/deleteFile.operation.js +59 -0
- package/dist/nodes/vendors/OpenAi/actions/file/deleteFile.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/file/index.d.ts +6 -0
- package/dist/nodes/vendors/OpenAi/actions/file/index.js +70 -0
- package/dist/nodes/vendors/OpenAi/actions/file/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/file/list.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/file/list.operation.js +58 -0
- package/dist/nodes/vendors/OpenAi/actions/file/list.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/file/upload.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/file/upload.operation.js +91 -0
- package/dist/nodes/vendors/OpenAi/actions/file/upload.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/image/analyze.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/image/analyze.operation.js +194 -0
- package/dist/nodes/vendors/OpenAi/actions/image/analyze.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/image/generate.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/image/generate.operation.js +227 -0
- package/dist/nodes/vendors/OpenAi/actions/image/generate.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/image/index.d.ts +5 -0
- package/dist/nodes/vendors/OpenAi/actions/image/index.js +61 -0
- package/dist/nodes/vendors/OpenAi/actions/image/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/node.type.d.ts +10 -0
- package/dist/nodes/vendors/OpenAi/actions/node.type.js +3 -0
- package/dist/nodes/vendors/OpenAi/actions/node.type.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/router.d.ts +2 -0
- package/dist/nodes/vendors/OpenAi/actions/router.js +81 -0
- package/dist/nodes/vendors/OpenAi/actions/router.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/text/classify.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/text/classify.operation.js +79 -0
- package/dist/nodes/vendors/OpenAi/actions/text/classify.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/text/index.d.ts +5 -0
- package/dist/nodes/vendors/OpenAi/actions/text/index.js +61 -0
- package/dist/nodes/vendors/OpenAi/actions/text/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/text/message.operation.d.ts +25 -0
- package/dist/nodes/vendors/OpenAi/actions/text/message.operation.js +239 -0
- package/dist/nodes/vendors/OpenAi/actions/text/message.operation.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/actions/versionDescription.d.ts +2 -0
- package/dist/nodes/vendors/OpenAi/actions/versionDescription.js +137 -0
- package/dist/nodes/vendors/OpenAi/actions/versionDescription.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/helpers/interfaces.d.ts +55 -0
- package/dist/nodes/vendors/OpenAi/helpers/interfaces.js +3 -0
- package/dist/nodes/vendors/OpenAi/helpers/interfaces.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/helpers/utils.d.ts +5 -0
- package/dist/nodes/vendors/OpenAi/helpers/utils.js +36 -0
- package/dist/nodes/vendors/OpenAi/helpers/utils.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/methods/index.d.ts +2 -0
- package/dist/nodes/vendors/OpenAi/methods/index.js +29 -0
- package/dist/nodes/vendors/OpenAi/methods/index.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/methods/listSearch.d.ts +4 -0
- package/dist/nodes/vendors/OpenAi/methods/listSearch.js +101 -0
- package/dist/nodes/vendors/OpenAi/methods/listSearch.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/methods/loadOptions.d.ts +2 -0
- package/dist/nodes/vendors/OpenAi/methods/loadOptions.js +17 -0
- package/dist/nodes/vendors/OpenAi/methods/loadOptions.js.map +1 -0
- package/dist/nodes/vendors/OpenAi/openAi.svg +1 -0
- package/dist/nodes/vendors/OpenAi/transport/index.d.ts +10 -0
- package/dist/nodes/vendors/OpenAi/transport/index.js +20 -0
- package/dist/nodes/vendors/OpenAi/transport/index.js.map +1 -0
- package/dist/types/credentials.json +1 -0
- package/dist/types/nodes.json +30 -27
- package/dist/utils/helpers.d.ts +3 -0
- package/dist/utils/helpers.js +7 -1
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/logWrapper.js +30 -16
- package/dist/utils/logWrapper.js.map +1 -1
- package/dist/utils/sharedFields.js +3 -1
- package/dist/utils/sharedFields.js.map +1 -1
- package/package.json +14 -8
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
+
export declare const description: {
|
|
3
|
+
displayOptions: import("n8n-workflow").IDisplayOptions;
|
|
4
|
+
displayName: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type: import("n8n-workflow").NodePropertyTypes;
|
|
7
|
+
typeOptions?: import("n8n-workflow").INodePropertyTypeOptions | undefined;
|
|
8
|
+
default: import("n8n-workflow").NodeParameterValueType;
|
|
9
|
+
description?: string | undefined;
|
|
10
|
+
hint?: string | undefined;
|
|
11
|
+
options?: (INodeProperties | import("n8n-workflow").INodePropertyOptions | import("n8n-workflow").INodePropertyCollection)[] | undefined;
|
|
12
|
+
placeholder?: string | undefined;
|
|
13
|
+
isNodeSetting?: boolean | undefined;
|
|
14
|
+
noDataExpression?: boolean | undefined;
|
|
15
|
+
required?: boolean | undefined;
|
|
16
|
+
routing?: import("n8n-workflow").INodePropertyRouting | undefined;
|
|
17
|
+
credentialTypes?: ("extends:oAuth2Api" | "extends:oAuth1Api" | "has:authenticate" | "has:genericAuth")[] | undefined;
|
|
18
|
+
extractValue?: import("n8n-workflow").INodePropertyValueExtractorRegex | undefined;
|
|
19
|
+
modes?: import("n8n-workflow").INodePropertyMode[] | undefined;
|
|
20
|
+
requiresDataPath?: "single" | "multiple" | undefined;
|
|
21
|
+
doNotInherit?: boolean | undefined;
|
|
22
|
+
validateType?: import("n8n-workflow").FieldType | undefined;
|
|
23
|
+
ignoreValidationDuringExecution?: boolean | undefined;
|
|
24
|
+
}[];
|
|
25
|
+
export declare function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.execute = exports.description = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const transport_1 = require("../../transport");
|
|
6
|
+
const properties = [
|
|
7
|
+
{
|
|
8
|
+
displayName: 'Text Input',
|
|
9
|
+
name: 'input',
|
|
10
|
+
type: 'string',
|
|
11
|
+
placeholder: 'e.g. Sample text goes here',
|
|
12
|
+
description: 'The input text to classify if it is violates the moderation policy',
|
|
13
|
+
default: '',
|
|
14
|
+
typeOptions: {
|
|
15
|
+
rows: 2,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
displayName: 'Simplify Output',
|
|
20
|
+
name: 'simplify',
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
default: false,
|
|
23
|
+
description: 'Whether to return a simplified version of the response instead of the raw data',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
displayName: 'Options',
|
|
27
|
+
name: 'options',
|
|
28
|
+
placeholder: 'Add Option',
|
|
29
|
+
type: 'collection',
|
|
30
|
+
default: {},
|
|
31
|
+
options: [
|
|
32
|
+
{
|
|
33
|
+
displayName: 'Use Stable Model',
|
|
34
|
+
name: 'useStableModel',
|
|
35
|
+
type: 'boolean',
|
|
36
|
+
default: false,
|
|
37
|
+
description: 'Whether to use the stable version of the model instead of the latest version, accuracy may be slightly lower',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
const displayOptions = {
|
|
43
|
+
show: {
|
|
44
|
+
operation: ['classify'],
|
|
45
|
+
resource: ['text'],
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
exports.description = (0, n8n_workflow_1.updateDisplayOptions)(displayOptions, properties);
|
|
49
|
+
async function execute(i) {
|
|
50
|
+
const input = this.getNodeParameter('input', i);
|
|
51
|
+
const options = this.getNodeParameter('options', i);
|
|
52
|
+
const model = options.useStableModel ? 'text-moderation-stable' : 'text-moderation-latest';
|
|
53
|
+
const body = {
|
|
54
|
+
input,
|
|
55
|
+
model,
|
|
56
|
+
};
|
|
57
|
+
const { results } = await transport_1.apiRequest.call(this, 'POST', '/moderations', { body });
|
|
58
|
+
if (!results)
|
|
59
|
+
return [];
|
|
60
|
+
const simplify = this.getNodeParameter('simplify', i);
|
|
61
|
+
if (simplify && results) {
|
|
62
|
+
return [
|
|
63
|
+
{
|
|
64
|
+
json: { flagged: results[0].flagged },
|
|
65
|
+
pairedItem: { item: i },
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return [
|
|
71
|
+
{
|
|
72
|
+
json: results[0],
|
|
73
|
+
pairedItem: { item: i },
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.execute = execute;
|
|
79
|
+
//# sourceMappingURL=classify.operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classify.operation.js","sourceRoot":"","sources":["../../../../../../nodes/vendors/OpenAi/actions/text/classify.operation.ts"],"names":[],"mappings":";;;AACA,+CAAoD;AACpD,+CAA6C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C;IAEF,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,sBAAU,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAElF,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAExB,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAC,CAAY,CAAC;IAEjE,IAAI,QAAQ,IAAI,OAAO,EAAE,CAAC;QACzB,OAAO;YACN;gBACC,IAAI,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE;gBACrC,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;aACvB;SACD,CAAC;IACH,CAAC;SAAM,CAAC;QACP,OAAO;YACN;gBACC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;gBAChB,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;aACvB;SACD,CAAC;IACH,CAAC;AACF,CAAC;AA/BD,0BA+BC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.description = exports.message = exports.classify = void 0;
|
|
27
|
+
const classify = __importStar(require("./classify.operation"));
|
|
28
|
+
exports.classify = classify;
|
|
29
|
+
const message = __importStar(require("./message.operation"));
|
|
30
|
+
exports.message = message;
|
|
31
|
+
exports.description = [
|
|
32
|
+
{
|
|
33
|
+
displayName: 'Operation',
|
|
34
|
+
name: 'operation',
|
|
35
|
+
type: 'options',
|
|
36
|
+
noDataExpression: true,
|
|
37
|
+
options: [
|
|
38
|
+
{
|
|
39
|
+
name: 'Message a Model',
|
|
40
|
+
value: 'message',
|
|
41
|
+
action: 'Message a model',
|
|
42
|
+
description: 'Create a completion with GPT 3, 4, etc.',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'Classify Text for Violations',
|
|
46
|
+
value: 'classify',
|
|
47
|
+
action: 'Classify text for violations',
|
|
48
|
+
description: 'Check whether content complies with usage policies',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
default: 'message',
|
|
52
|
+
displayOptions: {
|
|
53
|
+
show: {
|
|
54
|
+
resource: ['text'],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
...classify.description,
|
|
59
|
+
...message.description,
|
|
60
|
+
];
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../nodes/vendors/OpenAi/actions/text/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,+DAAiD;AAGxC,4BAAQ;AAFjB,6DAA+C;AAE5B,0BAAO;AAEb,QAAA,WAAW,GAAsB;IAC7C;QACC,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,SAAS;QACf,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,iBAAiB;gBACvB,KAAK,EAAE,SAAS;gBAChB,MAAM,EAAE,iBAAiB;gBAEzB,WAAW,EAAE,yCAAyC;aACtD;YACD;gBACC,IAAI,EAAE,8BAA8B;gBACpC,KAAK,EAAE,UAAU;gBACjB,MAAM,EAAE,8BAA8B;gBACtC,WAAW,EAAE,oDAAoD;aACjE;SACD;QACD,OAAO,EAAE,SAAS;QAClB,cAAc,EAAE;YACf,IAAI,EAAE;gBACL,QAAQ,EAAE,CAAC,MAAM,CAAC;aAClB;SACD;KACD;IAED,GAAG,QAAQ,CAAC,WAAW;IACvB,GAAG,OAAO,CAAC,WAAW;CACtB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
+
export declare const description: {
|
|
3
|
+
displayOptions: import("n8n-workflow").IDisplayOptions;
|
|
4
|
+
displayName: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type: import("n8n-workflow").NodePropertyTypes;
|
|
7
|
+
typeOptions?: import("n8n-workflow").INodePropertyTypeOptions | undefined;
|
|
8
|
+
default: import("n8n-workflow").NodeParameterValueType;
|
|
9
|
+
description?: string | undefined;
|
|
10
|
+
hint?: string | undefined;
|
|
11
|
+
options?: (INodeProperties | import("n8n-workflow").INodePropertyOptions | import("n8n-workflow").INodePropertyCollection)[] | undefined;
|
|
12
|
+
placeholder?: string | undefined;
|
|
13
|
+
isNodeSetting?: boolean | undefined;
|
|
14
|
+
noDataExpression?: boolean | undefined;
|
|
15
|
+
required?: boolean | undefined;
|
|
16
|
+
routing?: import("n8n-workflow").INodePropertyRouting | undefined;
|
|
17
|
+
credentialTypes?: ("extends:oAuth2Api" | "extends:oAuth1Api" | "has:authenticate" | "has:genericAuth")[] | undefined;
|
|
18
|
+
extractValue?: import("n8n-workflow").INodePropertyValueExtractorRegex | undefined;
|
|
19
|
+
modes?: import("n8n-workflow").INodePropertyMode[] | undefined;
|
|
20
|
+
requiresDataPath?: "single" | "multiple" | undefined;
|
|
21
|
+
doNotInherit?: boolean | undefined;
|
|
22
|
+
validateType?: import("n8n-workflow").FieldType | undefined;
|
|
23
|
+
ignoreValidationDuringExecution?: boolean | undefined;
|
|
24
|
+
}[];
|
|
25
|
+
export declare function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]>;
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.execute = exports.description = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const transport_1 = require("../../transport");
|
|
6
|
+
const utils_1 = require("../../helpers/utils");
|
|
7
|
+
const descriptions_1 = require("../descriptions");
|
|
8
|
+
const properties = [
|
|
9
|
+
descriptions_1.modelRLC,
|
|
10
|
+
{
|
|
11
|
+
displayName: 'Messages',
|
|
12
|
+
name: 'messages',
|
|
13
|
+
type: 'fixedCollection',
|
|
14
|
+
typeOptions: {
|
|
15
|
+
sortable: true,
|
|
16
|
+
multipleValues: true,
|
|
17
|
+
},
|
|
18
|
+
placeholder: 'Add Message',
|
|
19
|
+
default: { values: [{ content: '' }] },
|
|
20
|
+
options: [
|
|
21
|
+
{
|
|
22
|
+
displayName: 'Values',
|
|
23
|
+
name: 'values',
|
|
24
|
+
values: [
|
|
25
|
+
{
|
|
26
|
+
displayName: 'Text',
|
|
27
|
+
name: 'content',
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'The content of the message to be send',
|
|
30
|
+
default: '',
|
|
31
|
+
typeOptions: {
|
|
32
|
+
rows: 2,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
displayName: 'Role',
|
|
37
|
+
name: 'role',
|
|
38
|
+
type: 'options',
|
|
39
|
+
description: "Role in shaping the model's response, it tells the model how it should behave and interact with the user",
|
|
40
|
+
options: [
|
|
41
|
+
{
|
|
42
|
+
name: 'User',
|
|
43
|
+
value: 'user',
|
|
44
|
+
description: 'Send a message as a user and get a response from the model',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'Assistant',
|
|
48
|
+
value: 'assistant',
|
|
49
|
+
description: 'Tell the model to adopt a specific tone or personality',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'System',
|
|
53
|
+
value: 'system',
|
|
54
|
+
description: "Usually used to set the model's behavior or context for the next user message",
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
default: 'user',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
displayName: 'Simplify Output',
|
|
65
|
+
name: 'simplify',
|
|
66
|
+
type: 'boolean',
|
|
67
|
+
default: true,
|
|
68
|
+
description: 'Whether to return a simplified version of the response instead of the raw data',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
displayName: 'Output Content as JSON',
|
|
72
|
+
name: 'jsonOutput',
|
|
73
|
+
type: 'boolean',
|
|
74
|
+
description: 'Whether to attempt to return the response in JSON format, supported by gpt-3.5-turbo-1106 and gpt-4-1106-preview',
|
|
75
|
+
default: false,
|
|
76
|
+
displayOptions: {
|
|
77
|
+
show: {
|
|
78
|
+
modelId: ['gpt-3.5-turbo-1106', 'gpt-4-1106-preview'],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
displayName: 'Connect your own custom n8n tools to this node on the canvas',
|
|
84
|
+
name: 'noticeTools',
|
|
85
|
+
type: 'notice',
|
|
86
|
+
default: '',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
displayName: 'Options',
|
|
90
|
+
name: 'options',
|
|
91
|
+
placeholder: 'Add Option',
|
|
92
|
+
type: 'collection',
|
|
93
|
+
default: {},
|
|
94
|
+
options: [
|
|
95
|
+
{
|
|
96
|
+
displayName: 'Frequency Penalty',
|
|
97
|
+
name: 'frequency_penalty',
|
|
98
|
+
default: 0,
|
|
99
|
+
typeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },
|
|
100
|
+
description: "Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim",
|
|
101
|
+
type: 'number',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
displayName: 'Maximum Number of Tokens',
|
|
105
|
+
name: 'maxTokens',
|
|
106
|
+
default: 16,
|
|
107
|
+
description: 'The maximum number of tokens to generate in the completion. Most models have a context length of 2048 tokens (except for the newest models, which support 32,768).',
|
|
108
|
+
type: 'number',
|
|
109
|
+
typeOptions: {
|
|
110
|
+
maxValue: 32768,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
displayName: 'Number of Completions',
|
|
115
|
+
name: 'n',
|
|
116
|
+
default: 1,
|
|
117
|
+
description: 'How many completions to generate for each prompt. Note: Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for max_tokens and stop.',
|
|
118
|
+
type: 'number',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
displayName: 'Presence Penalty',
|
|
122
|
+
name: 'presence_penalty',
|
|
123
|
+
default: 0,
|
|
124
|
+
typeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },
|
|
125
|
+
description: "Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics",
|
|
126
|
+
type: 'number',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
displayName: 'Output Randomness (Temperature)',
|
|
130
|
+
name: 'temperature',
|
|
131
|
+
default: 1,
|
|
132
|
+
typeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },
|
|
133
|
+
description: 'Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive. We generally recommend altering this or temperature but not both.',
|
|
134
|
+
type: 'number',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
displayName: 'Output Randomness (Top P)',
|
|
138
|
+
name: 'topP',
|
|
139
|
+
default: 1,
|
|
140
|
+
typeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },
|
|
141
|
+
description: 'An alternative to sampling with temperature, controls diversity via nucleus sampling: 0.5 means half of all likelihood-weighted options are considered. We generally recommend altering this or temperature but not both.',
|
|
142
|
+
type: 'number',
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
const displayOptions = {
|
|
148
|
+
show: {
|
|
149
|
+
operation: ['message'],
|
|
150
|
+
resource: ['text'],
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
exports.description = (0, n8n_workflow_1.updateDisplayOptions)(displayOptions, properties);
|
|
154
|
+
async function execute(i) {
|
|
155
|
+
var _a, _b;
|
|
156
|
+
const model = this.getNodeParameter('modelId', i, '', { extractValue: true });
|
|
157
|
+
let messages = this.getNodeParameter('messages.values', i, []);
|
|
158
|
+
const options = this.getNodeParameter('options', i, {});
|
|
159
|
+
const jsonOutput = this.getNodeParameter('jsonOutput', i, false);
|
|
160
|
+
let response_format;
|
|
161
|
+
if (jsonOutput) {
|
|
162
|
+
response_format = { type: 'json_object' };
|
|
163
|
+
messages = [
|
|
164
|
+
{
|
|
165
|
+
role: 'system',
|
|
166
|
+
content: 'You are a helpful assistant designed to output JSON.',
|
|
167
|
+
},
|
|
168
|
+
...messages,
|
|
169
|
+
];
|
|
170
|
+
}
|
|
171
|
+
const externalTools = (await this.getInputConnectionData("ai_tool", 0)) || [];
|
|
172
|
+
let tools;
|
|
173
|
+
if (externalTools.length) {
|
|
174
|
+
tools = externalTools.length ? externalTools === null || externalTools === void 0 ? void 0 : externalTools.map(utils_1.formatToOpenAIAssistantTool) : undefined;
|
|
175
|
+
}
|
|
176
|
+
const body = {
|
|
177
|
+
model,
|
|
178
|
+
messages,
|
|
179
|
+
tools,
|
|
180
|
+
response_format,
|
|
181
|
+
...options,
|
|
182
|
+
};
|
|
183
|
+
let response = (await transport_1.apiRequest.call(this, 'POST', '/chat/completions', {
|
|
184
|
+
body,
|
|
185
|
+
}));
|
|
186
|
+
if (!response)
|
|
187
|
+
return [];
|
|
188
|
+
let toolCalls = (_b = (_a = response === null || response === void 0 ? void 0 : response.choices[0]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.tool_calls;
|
|
189
|
+
while (toolCalls && toolCalls.length) {
|
|
190
|
+
messages.push(response.choices[0].message);
|
|
191
|
+
for (const toolCall of toolCalls) {
|
|
192
|
+
const functionName = toolCall.function.name;
|
|
193
|
+
const functionArgs = toolCall.function.arguments;
|
|
194
|
+
let functionResponse;
|
|
195
|
+
for (const tool of externalTools !== null && externalTools !== void 0 ? externalTools : []) {
|
|
196
|
+
if (tool.name === functionName) {
|
|
197
|
+
functionResponse = await tool.invoke(functionArgs);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (typeof functionResponse === 'object') {
|
|
201
|
+
functionResponse = JSON.stringify(functionResponse);
|
|
202
|
+
}
|
|
203
|
+
messages.push({
|
|
204
|
+
tool_call_id: toolCall.id,
|
|
205
|
+
role: 'tool',
|
|
206
|
+
content: functionResponse,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
response = (await transport_1.apiRequest.call(this, 'POST', '/chat/completions', {
|
|
210
|
+
body,
|
|
211
|
+
}));
|
|
212
|
+
toolCalls = response.choices[0].message.tool_calls;
|
|
213
|
+
}
|
|
214
|
+
if (response_format) {
|
|
215
|
+
response.choices = response.choices.map((choice) => {
|
|
216
|
+
try {
|
|
217
|
+
choice.message.content = JSON.parse(choice.message.content);
|
|
218
|
+
}
|
|
219
|
+
catch (error) { }
|
|
220
|
+
return choice;
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
const simplify = this.getNodeParameter('simplify', i);
|
|
224
|
+
const returnData = [];
|
|
225
|
+
if (simplify) {
|
|
226
|
+
for (const entry of response.choices) {
|
|
227
|
+
returnData.push({
|
|
228
|
+
json: entry,
|
|
229
|
+
pairedItem: { item: i },
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
returnData.push({ json: response, pairedItem: { item: i } });
|
|
235
|
+
}
|
|
236
|
+
return returnData;
|
|
237
|
+
}
|
|
238
|
+
exports.execute = execute;
|
|
239
|
+
//# sourceMappingURL=message.operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.operation.js","sourceRoot":"","sources":["../../../../../../nodes/vendors/OpenAi/actions/text/message.operation.ts"],"names":[],"mappings":";;;AAMA,+CAAwE;AAExE,+CAA6C;AAG7C,+CAAkE;AAClE,kDAA2C;AAE3C,MAAM,UAAU,GAAsB;IACrC,uBAAQ;IACR;QACC,WAAW,EAAE,UAAU;QACvB,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE;YACZ,QAAQ,EAAE,IAAI;YACd,cAAc,EAAE,IAAI;SACpB;QACD,WAAW,EAAE,aAAa;QAC1B,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE;QACtC,OAAO,EAAE;YACR;gBACC,WAAW,EAAE,QAAQ;gBACrB,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE;oBACP;wBACC,WAAW,EAAE,MAAM;wBACnB,IAAI,EAAE,SAAS;wBACf,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,uCAAuC;wBACpD,OAAO,EAAE,EAAE;wBACX,WA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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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.versionDescription = void 0;
|
|
27
|
+
const assistant = __importStar(require("./assistant"));
|
|
28
|
+
const audio = __importStar(require("./audio"));
|
|
29
|
+
const file = __importStar(require("./file"));
|
|
30
|
+
const image = __importStar(require("./image"));
|
|
31
|
+
const text = __importStar(require("./text"));
|
|
32
|
+
const prettifyOperation = (resource, operation) => {
|
|
33
|
+
if (operation === 'deleteAssistant') {
|
|
34
|
+
return 'Delete Assistant';
|
|
35
|
+
}
|
|
36
|
+
if (operation === 'deleteFile') {
|
|
37
|
+
return 'Delete File';
|
|
38
|
+
}
|
|
39
|
+
if (operation === 'classify') {
|
|
40
|
+
return 'Classify Text';
|
|
41
|
+
}
|
|
42
|
+
if (operation === 'message' && resource === 'text') {
|
|
43
|
+
return 'Message Model';
|
|
44
|
+
}
|
|
45
|
+
const capitalize = (str) => {
|
|
46
|
+
const chars = str.split('');
|
|
47
|
+
chars[0] = chars[0].toUpperCase();
|
|
48
|
+
return chars.join('');
|
|
49
|
+
};
|
|
50
|
+
if (['transcribe', 'translate'].includes(operation)) {
|
|
51
|
+
resource = 'recording';
|
|
52
|
+
}
|
|
53
|
+
if (operation === 'list') {
|
|
54
|
+
resource = resource + 's';
|
|
55
|
+
}
|
|
56
|
+
return `${capitalize(operation)} ${capitalize(resource)}`;
|
|
57
|
+
};
|
|
58
|
+
const configureNodeInputs = (resource, operation) => {
|
|
59
|
+
if (['assistant', 'text'].includes(resource) && operation === 'message') {
|
|
60
|
+
return [
|
|
61
|
+
{ type: "main" },
|
|
62
|
+
{ type: "ai_tool", displayName: 'Tools' },
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
return ["main"];
|
|
66
|
+
};
|
|
67
|
+
exports.versionDescription = {
|
|
68
|
+
displayName: 'OpenAI',
|
|
69
|
+
name: 'openAi',
|
|
70
|
+
icon: 'file:openAi.svg',
|
|
71
|
+
group: ['transform'],
|
|
72
|
+
version: 1,
|
|
73
|
+
subtitle: `={{(${prettifyOperation})($parameter.resource, $parameter.operation)}}`,
|
|
74
|
+
description: 'Message an assistant or GPT, analyze images, generate audio, etc.',
|
|
75
|
+
defaults: {
|
|
76
|
+
name: 'OpenAI',
|
|
77
|
+
},
|
|
78
|
+
codex: {
|
|
79
|
+
alias: ['LangChain', 'ChatGPT', 'DallE'],
|
|
80
|
+
categories: ['AI'],
|
|
81
|
+
subcategories: {
|
|
82
|
+
AI: ['Agents', 'Miscellaneous'],
|
|
83
|
+
},
|
|
84
|
+
resources: {
|
|
85
|
+
primaryDocumentation: [
|
|
86
|
+
{
|
|
87
|
+
url: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.openai/',
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
inputs: `={{(${configureNodeInputs})($parameter.resource, $parameter.operation)}}`,
|
|
93
|
+
outputs: ['main'],
|
|
94
|
+
credentials: [
|
|
95
|
+
{
|
|
96
|
+
name: 'openAiApi',
|
|
97
|
+
required: true,
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
properties: [
|
|
101
|
+
{
|
|
102
|
+
displayName: 'Resource',
|
|
103
|
+
name: 'resource',
|
|
104
|
+
type: 'options',
|
|
105
|
+
noDataExpression: true,
|
|
106
|
+
options: [
|
|
107
|
+
{
|
|
108
|
+
name: 'Assistant',
|
|
109
|
+
value: 'assistant',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: 'Text',
|
|
113
|
+
value: 'text',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: 'Image',
|
|
117
|
+
value: 'image',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'Audio',
|
|
121
|
+
value: 'audio',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: 'File',
|
|
125
|
+
value: 'file',
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
default: 'text',
|
|
129
|
+
},
|
|
130
|
+
...assistant.description,
|
|
131
|
+
...audio.description,
|
|
132
|
+
...file.description,
|
|
133
|
+
...image.description,
|
|
134
|
+
...text.description,
|
|
135
|
+
],
|
|
136
|
+
};
|
|
137
|
+
//# sourceMappingURL=versionDescription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versionDescription.js","sourceRoot":"","sources":["../../../../../nodes/vendors/OpenAi/actions/versionDescription.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,uDAAyC;AACzC,+CAAiC;AACjC,6CAA+B;AAC/B,+CAAiC;AACjC,6CAA+B;AAE/B,MAAM,iBAAiB,GAAG,CAAC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M;iBACb;aACD;YACD,OAAO,EAAE,MAAM;SACf;QACD,GAAG,SAAS,CAAC,WAAW;QACxB,GAAG,KAAK,CAAC,WAAW;QACpB,GAAG,IAAI,CAAC,WAAW;QACnB,GAAG,KAAK,CAAC,WAAW;QACpB,GAAG,IAAI,CAAC,WAAW;KACnB;CACD,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { IDataObject } from 'n8n-workflow';
|
|
2
|
+
export type ChatCompletion = {
|
|
3
|
+
id: string;
|
|
4
|
+
object: string;
|
|
5
|
+
created: number;
|
|
6
|
+
model: string;
|
|
7
|
+
choices: Array<{
|
|
8
|
+
index: number;
|
|
9
|
+
message: {
|
|
10
|
+
role: string;
|
|
11
|
+
content: string;
|
|
12
|
+
tool_calls?: Array<{
|
|
13
|
+
id: string;
|
|
14
|
+
type: 'function';
|
|
15
|
+
function: {
|
|
16
|
+
name: string;
|
|
17
|
+
arguments: string;
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
20
|
+
};
|
|
21
|
+
finish_reason?: 'tool_calls';
|
|
22
|
+
}>;
|
|
23
|
+
usage: {
|
|
24
|
+
prompt_tokens: number;
|
|
25
|
+
completion_tokens: number;
|
|
26
|
+
total_tokens: number;
|
|
27
|
+
};
|
|
28
|
+
system_fingerprint: string;
|
|
29
|
+
};
|
|
30
|
+
export type ThreadMessage = {
|
|
31
|
+
id: string;
|
|
32
|
+
object: string;
|
|
33
|
+
created_at: number;
|
|
34
|
+
thread_id: string;
|
|
35
|
+
role: string;
|
|
36
|
+
content: Array<{
|
|
37
|
+
type: string;
|
|
38
|
+
text: {
|
|
39
|
+
value: string;
|
|
40
|
+
annotations: string[];
|
|
41
|
+
};
|
|
42
|
+
}>;
|
|
43
|
+
file_ids: string[];
|
|
44
|
+
assistant_id: string;
|
|
45
|
+
run_id: string;
|
|
46
|
+
metadata: IDataObject;
|
|
47
|
+
};
|
|
48
|
+
export type ExternalApiCallOptions = {
|
|
49
|
+
callExternalApi: boolean;
|
|
50
|
+
url: string;
|
|
51
|
+
path: string;
|
|
52
|
+
method: string;
|
|
53
|
+
requestOptions: IDataObject;
|
|
54
|
+
sendParametersIn: string;
|
|
55
|
+
};
|