-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
504 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { jsPDF } from 'jspdf'; | ||
import fs from 'node:fs'; | ||
import { NodeletExecuteContext } from '../type'; | ||
|
||
enum FileType { | ||
txt = 'txt', | ||
pdf = 'pdf', | ||
md = 'md', | ||
} | ||
export async function saveToFile({ nodeInputs, nodeConfig, setGlobalContext }: NodeletExecuteContext) { | ||
const { output } = nodeInputs as { output: string }; | ||
const { fileType, fileName, folderPath } = nodeConfig; | ||
switch (fileType) { | ||
case FileType.txt: | ||
case FileType.md: { | ||
fs.writeFile(`${folderPath}/${fileName}.${fileType}`, output, (err) => { | ||
if (err) { | ||
console.log('An error ocurred creating the file ' + err.message); | ||
} else { | ||
console.log('The file has been succesfully saved'); | ||
} | ||
}); | ||
break; | ||
} | ||
case FileType.pdf: { | ||
const doc = new jsPDF(); | ||
doc.text(output, 10, 10); | ||
doc.save(`${folderPath}/${fileName}.pdf`); | ||
break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { NodeletExecuteContext } from '../type'; | ||
|
||
export async function executeTextInput({ nodeId, globalContext, setNodeContext, nodeContext }: NodeletExecuteContext) { | ||
console.log(`executing node ${nodeId}, current message: ${globalContext?.userInput}`); | ||
setNodeContext && | ||
setNodeContext({ | ||
outputs: { output: nodeContext?.text }, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
import { NodeletExecuteContext } from '../type'; | ||
|
||
export async function executeUserInput({ nodeId, globalContext, setNodeContext, setGlobalContext }: NodeletExecuteContext) { | ||
console.log(`executing node ${nodeId}, current message: ${globalContext?.currentMessage}`); | ||
console.log(`executing node ${nodeId}, current message: ${globalContext?.userInput}`); | ||
setNodeContext && | ||
setNodeContext({ | ||
outputs: { query: globalContext?.currentMessage }, | ||
}); | ||
setGlobalContext && | ||
setGlobalContext({ | ||
...globalContext, | ||
messages: globalContext.messages.concat([globalContext?.currentMessage]), | ||
outputs: { query: globalContext?.userInput }, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ export const DefaultData = { | |
workflows: [], | ||
nodelets: Nodelets, | ||
settings: {}, | ||
executions: [], | ||
}; |
Oops, something went wrong.