n8n-nodes-akashchat
Version:
n8n community nodes for AkashChat: API for open-source AI models on Akash Supercloud.
99 lines • 5.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AkashChat = void 0;
const n8n_workflow_1 = require("n8n-workflow");
class AkashChat {
constructor() {
this.description = {
displayName: 'Akash Chat',
name: 'akashChat',
group: ['transform'],
version: 1,
description: `Interact with the AkashChat API.\n\nAkashChat provides a simple interface to leading open-source AI models powered by the Akash Supercloud.\n\n- Akash is a permissionless marketplace for cloud resources with competitive pricing.\n- The API is easy to use and supports multiple open-source models.\n- Get your API key at: https://chatapi.akash.network/\n- Docs: https://chatapi.akash.network/docs\n- Community: Akash Discord, GitHub Discussions.`,
defaults: {
name: 'Akash Chat',
},
inputs: ["main"],
outputs: ["main"],
usableAsTool: true,
credentials: [
{
name: 'akashChatApi',
required: true,
},
],
properties: [
{
displayName: 'Prompt',
name: 'prompt',
type: 'string',
default: '',
placeholder: 'Ask anything... e.g. What is Akash?',
description: 'The prompt/question to send to the selected AI model',
},
{
displayName: 'Model',
name: 'model',
type: 'options',
options: [
{ name: 'DeepSeek-R1', value: 'DeepSeek-R1', description: 'DeepSeek-R1 base model' },
{ name: 'DeepSeek-R1-Distill-Llama-70B', value: 'DeepSeek-R1-Distill-Llama-70B', description: 'Distilled Llama 70B' },
{ name: 'DeepSeek-R1-Distill-Qwen-14B', value: 'DeepSeek-R1-Distill-Qwen-14B', description: 'Distilled Qwen 14B' },
{ name: 'DeepSeek-R1-Distill-Qwen-32B', value: 'DeepSeek-R1-Distill-Qwen-32B', description: 'Distilled Qwen 32B' },
{ name: 'Meta-Llama-3-1-8B-Instruct-FP8', value: 'Meta-Llama-3-1-8B-Instruct-FP8', description: 'Meta Llama 3 8B Instruct' },
{ name: 'Meta-Llama-3-2-3B-Instruct', value: 'Meta-Llama-3-2-3B-Instruct', description: 'Meta Llama 3 23B Instruct' },
{ name: 'Meta-Llama-3-3-70B-Instruct', value: 'Meta-Llama-3-3-70B-Instruct', description: 'Meta Llama 3 70B Instruct' },
{ name: 'Meta-Llama-4-Maverick-17B-128E-Instruct-FP8', value: 'Meta-Llama-4-Maverick-17B-128E-Instruct-FP8', description: 'Meta Llama 4 Maverick 17B' },
{ name: 'Qwen3-235B-A22B-FP8', value: 'Qwen3-235B-A22B-FP8', description: 'Qwen3 235B A22B' },
],
default: 'Meta-Llama-3-1-8B-Instruct-FP8',
description: 'Select the AI model to use for generating a response',
},
],
};
}
async execute() {
var _a, _b, _c;
const items = this.getInputData();
const returnData = [];
for (let i = 0; i < items.length; i++) {
try {
const prompt = this.getNodeParameter('prompt', i);
const model = this.getNodeParameter('model', i);
const credentials = await this.getCredentials('akashChatApi');
const response = await this.helpers.httpRequest({
method: 'POST',
url: 'https://chatapi.akash.network/api/v1/chat/completions',
headers: {
'Authorization': `Bearer ${credentials.apiKey}`,
'Content-Type': 'application/json',
},
body: {
model,
messages: [
{ role: 'user', content: prompt },
],
},
json: true,
});
returnData.push({ json: {
model,
prompt,
response: ((_c = (_b = (_a = response.choices) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message) === null || _c === void 0 ? void 0 : _c.content) || response,
fullResponse: response,
} });
}
catch (error) {
if (this.continueOnFail()) {
returnData.push({ json: { error: error.message }, pairedItem: i });
}
else {
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
}
}
}
return [returnData];
}
}
exports.AkashChat = AkashChat;
//# sourceMappingURL=AkashChat.node.js.map