n8n-nodes-deepseek-llm
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
98 lines • 3.5 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LmChatDeepSeek = void 0;
const axios_1 = __importDefault(require("axios"));
class ChatDeepSeek {
constructor(baseUrl, apiKey, modelName, options) {
this.baseUrl = baseUrl;
this.apiKey = apiKey;
this.modelName = modelName;
this.options = options;
}
async call(prompt) {
const headers = {
Authorization: `Bearer ${this.apiKey}`,
'Content-Type': 'application/json',
};
const response = await axios_1.default.post(`${this.baseUrl}/chat/completions`, {
model: this.modelName,
prompt,
...this.options,
}, { headers });
return response.data.choices[0].message.content;
}
}
class LmChatDeepSeek {
constructor() {
this.description = {
displayName: 'DeepSeek Chat Model',
name: 'lmChatDeepSeek',
icon: { light: 'file:DeepSeek.svg', dark: 'file:DeepSeek.svg' },
group: ['transform'],
version: 1,
description: 'Language Model DeepSeek v3',
defaults: {
name: 'DeepSeek Chat Model',
},
codex: {
categories: ['AI'],
subcategories: {
AI: ['Language Models', 'Root Nodes'],
'Language Models': ['Chat Models (Recommended)'],
},
resources: {
primaryDocumentation: [
{
url: 'https://docs.deepseek.com/',
},
],
},
},
inputs: [],
outputs: ["ai_languageModel"],
outputNames: ['Model'],
properties: [
{
displayName: 'Model Name',
name: 'model',
type: 'options',
options: [
{ name: 'DeepSeek V3', value: 'deepseek-v3' },
],
default: 'deepseek-v3',
description: 'The DeepSeek model to use',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Options',
options: [
{
displayName: 'Temperature',
name: 'temperature',
type: 'number',
default: 0.7,
description: 'Sampling temperature',
},
],
default: {},
},
],
};
}
async supplyData(itemIndex) {
const credentials = await this.getCredentials('deepSeekApi');
const modelName = this.getNodeParameter('model', itemIndex);
const options = this.getNodeParameter('options', itemIndex, {});
const model = new ChatDeepSeek(credentials.baseUrl, credentials.apiKey, modelName, options);
return {
response: model,
};
}
}
exports.LmChatDeepSeek = LmChatDeepSeek;
//# sourceMappingURL=LmChatDeepSeek.node.js.map