n8n-nodes-deepseek-new
Version:
A user-friendly DeepSeek AI node, similar to OpenAI, designed to enhance your workflow. npm link: https://www.npmjs.com/package/n8n-nodes-deepseek
312 lines • 10.7 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FIMFields = exports.fimOperations = void 0;
const GenericFunctions_1 = require("./GenericFunctions");
exports.fimOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['fim'],
},
},
options: [
{
name: 'Complete',
value: 'complete',
action: 'Create fim completion beta',
description: 'The FIM (Fill-In-the-Middle) Completion API',
routing: {
request: {
method: 'POST',
url: '/beta/completions',
},
output: { postReceive: [GenericFunctions_1.sendErrorPostReceive] },
}
},
],
default: 'complete',
},
];
const completeOperations = [
{
displayName: 'Model',
name: 'model',
type: 'options',
description: 'The model which will generate the completion. <a href="https://platform.deepseek.com/api-docs/pricing/">Learn more</a>.',
displayOptions: {
show: {
resource: ['fim'],
},
},
typeOptions: {
loadOptions: {
routing: {
request: {
method: 'GET',
url: '/models',
},
output: {
postReceive: [
{
type: 'rootProperty',
properties: {
property: 'data',
},
},
{
type: 'filter',
properties: {
pass: "={{ $responseItem.id.startsWith('deepseek-coder') }}",
},
},
{
type: 'setKeyValue',
properties: {
name: '={{$responseItem.id}}',
value: '={{$responseItem.id}}',
},
},
{
type: 'sort',
properties: {
key: 'name',
},
},
],
},
},
},
},
routing: {
send: {
type: 'body',
property: 'model',
},
},
default: '',
},
{
displayName: 'Prompt',
name: 'prompt',
type: 'string',
required: true,
typeOptions: {
rows: 3,
},
default: '',
description: 'The prompt to generate completions for',
displayOptions: {
show: {
resource: ['fim']
},
},
routing: {
send: {
type: 'body',
property: 'prompt',
},
},
}
];
const sharedOperations = [
{
displayName: 'Simplify',
name: 'simplifyOutput',
type: 'boolean',
default: true,
displayOptions: {
show: {
resource: ['fim'],
},
},
routing: {
output: {
postReceive: [
{
type: 'set',
enabled: '={{$value}}',
properties: {
value: '={{ { "data": $response.body.choices } }}',
},
},
{
type: 'rootProperty',
enabled: '={{$value}}',
properties: {
property: 'data',
},
},
async function (items) {
if (this.getNode().parameters.simplifyOutput === false) {
return items;
}
return items.map((item) => {
return {
json: {
...item.json,
message: item.json.message,
},
};
});
},
],
},
},
description: 'Whether to return a simplified version of the response instead of the raw data',
},
{
displayName: 'Options',
name: 'options',
placeholder: 'Add Option',
description: 'Additional options to add',
type: 'collection',
default: {},
displayOptions: {
show: {
resource: ['fim']
},
},
options: [
{
displayName: 'Frequency Penalty',
name: 'frequency_penalty',
default: 0,
typeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },
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",
type: 'number',
routing: {
send: {
type: 'body',
property: 'frequency_penalty',
},
},
},
{
displayName: 'Maximum Number of Tokens',
name: 'maxTokens',
default: 16,
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).',
type: 'number',
displayOptions: {
show: {
'/operation': ['complete'],
},
},
typeOptions: {
maxValue: 32768,
},
routing: {
send: {
type: 'body',
property: 'max_tokens',
},
},
},
{
displayName: 'Presence Penalty',
name: 'presence_penalty',
default: 0,
typeOptions: { maxValue: 2, minValue: -2, numberPrecision: 1 },
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",
type: 'number',
routing: {
send: {
type: 'body',
property: 'presence_penalty',
},
},
},
{
displayName: 'Sampling Temperature',
name: 'temperature',
default: 1,
typeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },
description: 'Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.',
type: 'number',
routing: {
send: {
type: 'body',
property: 'temperature',
},
},
},
{
displayName: 'Top P',
name: 'topP',
default: 1,
typeOptions: { maxValue: 1, minValue: 0, numberPrecision: 1 },
description: '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.',
type: 'number',
routing: {
send: {
type: 'body',
property: 'top_p',
},
},
},
{
displayName: 'Echo Prompt',
name: 'echo',
type: 'boolean',
description: 'Whether the prompt should be echo back in addition to the completion',
default: false,
displayOptions: {
show: {
'/operation': ['complete'],
},
},
routing: {
send: {
type: 'body',
property: 'echo',
},
},
},
{
displayName: 'Logprobs',
name: 'logprobs',
type: 'boolean',
description: 'Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message.',
default: false,
displayOptions: {
show: {
'/operation': ['complete'],
},
},
routing: {
send: {
type: 'body',
property: 'logprobs',
},
},
},
{
displayName: 'Suffix',
name: 'suffix',
type: 'string',
default: '',
description: 'The suffix that comes after a completion of inserted text',
displayOptions: {
show: {
'/operation': ['complete'],
},
},
routing: {
send: {
type: 'body',
property: 'suffix',
},
}
},
],
},
];
exports.FIMFields = [
...completeOperations,
...sharedOperations,
];
//# sourceMappingURL=FIMDescription.js.map