added nodes

This commit is contained in:
Saifeddine ALOUI 2024-07-31 19:51:04 +02:00
parent 417cc27a6a
commit 1b61aa8149
4 changed files with 95 additions and 0 deletions

28
web/src/nodes/LLM.js Normal file
View File

@ -0,0 +1,28 @@
import { defineNode, NodeInterface, TextInterface, SelectInterface } from "baklavajs";
import axios from 'axios';
import { store } from '../main'
export const LLMNode = defineNode({
type: "LLMNode",
title: "LLM",
inputs: {
request: () => new NodeInterface("Request", ""),
},
outputs: {
response: () => new NodeInterface("Response", "")
},
async calculate({ request }) {
console.log(store.state.config.personalities)
let response = '';
try {
const result = await axios.post('/generate', { params: { text: request } });
response = result.data;
} catch (error) {
console.error(error);
}
return {
display: response,
response: response
};
}
});

View File

@ -0,0 +1,19 @@
import { defineNode, NodeInterface, TextInputInterface } from "baklavajs";
export const MultichoiceNode = defineNode({
type: "MultichoiceNode",
title: "Multichoice",
inputs: {
question: () => new NodeInterface("Question", ""),
outputs: () =>
new TextInputInterface("choices, one per line", "", "").setPort(
false
),
},
outputs: {
response: () => new NodeInterface("Response", "")
},
});

View File

@ -0,0 +1,16 @@
import { defineNode, NodeInterface, TextInterface, SelectInterface } from "baklavajs";
import axios from 'axios';
import { store } from '../main'
export const TextDisplayNode = defineNode({
type: "TextDisplayNode",
title: "TextDisplay",
inputs: {
text2display: () => new NodeInterface("Input", ""),
},
outputs: {
response: () => new TextInterface("Text", "")
},
async calculate({ request }) {
}
});

32
web/src/nodes/Yes_No.js Normal file
View File

@ -0,0 +1,32 @@
import { defineNode, NodeInterface, TextInterface, SelectInterface } from "baklavajs";
import axios from 'axios';
import { store } from '../main'
export const LLMNode = defineNode({
type: "LLMNode",
title: "LLM",
inputs: {
input: () => new NodeInterface("Input", ""),
question: () => new NodeInterface("Question", "").setPort(
false
),
},
outputs: {
yes: () => new NodeInterface("Yes", ""),
no: () => new NodeInterface("No", "")
},
async calculate({ request }) {
console.log(store.state.config.personalities)
let response = '';
try {
const result = await axios.get('/yes_no', { params: { text: request } });
response = result.data;
} catch (error) {
console.error(error);
}
return {
display: response,
response: response
};
}
});