Compare commits

..

1 Commits

Author SHA1 Message Date
MikeHughes-BIN 2998799826 Window width for the GUI to fit the Arrows 2025-12-15 16:42:44 +01:00
4 changed files with 112 additions and 128 deletions
+4 -9
View File
@@ -61,7 +61,7 @@ let mainWindow;
function createWindow() { function createWindow() {
mainWindow = new electron.BrowserWindow({ mainWindow = new electron.BrowserWindow({
width: 800, width: 1200,
height: 800, height: 800,
webPreferences: { webPreferences: {
nodeIntegration: false, nodeIntegration: false,
@@ -124,12 +124,10 @@ electron.ipcMain.handle('get-module-names', async () => {
// mainWindow.webContents.send("modules", module_array) // mainWindow.webContents.send("modules", module_array)
// }) // })
var globalArgs = {}
var globalFinalHtmlPath = ""
electron.ipcMain.on("file_submit", async (event, args) => { electron.ipcMain.on("file_submit", async (event, args) => {
try { try {
globalArgs = args
let curstep = 0 let curstep = 0
let totalsteps = 3 + args.document.styles.length let totalsteps = 3 + args.document.styles.length
@@ -189,7 +187,7 @@ electron.ipcMain.on("file_submit", async (event, args) => {
await mapFunctions.get("module-handler").function(args.document.module, {inputTranscriptPath: transcriptpath, documentTypePath: "./storage/documentType/standard_meeting_report.txt", language: "en"}).then(resp => { await mapFunctions.get("module-handler").function(args.document.module, {inputTranscriptPath: transcriptpath, documentTypePath: "./storage/documentType/standard_meeting_report.txt", language: "en"}).then(resp => {
console.log(resp); console.log(resp);
globalFinalHtmlPath = resp transcriptpath = resp
curstep++ curstep++
mainWindow.webContents.send("progress", {curstep:curstep, totalsteps:totalsteps}) mainWindow.webContents.send("progress", {curstep:curstep, totalsteps:totalsteps})
}).catch(err => { }).catch(err => {
@@ -197,7 +195,7 @@ electron.ipcMain.on("file_submit", async (event, args) => {
return return
}) })
} }
// TODO actually implement this functionality // TODO actually implement this functionality
// Module to get the first few lines for each speaker to send to the frontend // Module to get the first few lines for each speaker to send to the frontend
// await mapFunctions.get("speaker-getter-idfk").function(transcriptpath).then(resp => { // await mapFunctions.get("speaker-getter-idfk").function(transcriptpath).then(resp => {
@@ -222,9 +220,6 @@ electron.ipcMain.on("file_submit", async (event, args) => {
} }
}) })
electron.ipcMain.on("file_download", async() => {
await mapFunctions.get("htmlDocumentConverter").convert({inputPath:globalFinalHtmlPath, format: globalArgs.document.outputType, showDialog: true});
})
let q = let q =
+55 -60
View File
@@ -1,7 +1,7 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const outputDir = path.join(__dirname, "../../../storage/documents"); // path for output directory const outputDir = path.join(__dirname, "../../../storage/documents"); // path for output directory
if (!fs.existsSync(outputDir)) { if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true }); // Create output directory if it doesn't exist fs.mkdirSync(outputDir, { recursive: true }); // Create output directory if it doesn't exist
@@ -9,7 +9,8 @@ if (!fs.existsSync(outputDir)) {
// Ensure SAIA API key is set in environment variables: export SAIA_API_KEY="your_api_key_here" // Ensure SAIA API key is set in environment variables: export SAIA_API_KEY="your_api_key_here"
const SAIA_API_KEY = process.env.SAIA_API_KEY; // Ensure SAIA API key is set in environment variables const SAIA_API_KEY = process.env.SAIA_API_KEY; // Ensure SAIA API key is set in environment variables
const SAIA_URL = "https://chat-ai.academiccloud.de/v1/chat/completions"; // URL for the REST call, used model and action
const SAIA_URL = "https://chat-ai.academiccloud.de/v1/chat/completions"; //URL for the REST call, used model and action
const module_exports = { const module_exports = {
name: "llm-saia_openai_gpt", name: "llm-saia_openai_gpt",
@@ -18,72 +19,66 @@ const module_exports = {
description: "Generates documents using OpenAI GPT OSS 120B via SAIA platform", description: "Generates documents using OpenAI GPT OSS 120B via SAIA platform",
async function(parameter) { async function(parameter) {
return new Promise(async (resolve, reject) => { try {
try { console.log("SAIA OpenAI GPT module invoked with parameters:", parameter);
// console.log("SAIA OpenAI GPT module invoked with parameters:", parameter);
resolve(await this.createDocumentFromTranscript( //Call the function to create document with transcript, document type and language await this.createDocumentFromTranscript( //Call the function to create document with transcript, document type and language
parameter.inputTranscriptPath, // Path to input transcript file parameter.inputTranscriptPath, // Path to input transcript file
parameter.documentTypePath, // Path to document type file which is chosen in the front end by the user parameter.documentTypePath, // Path to document type file which is chosen in the front end by the user
parameter.language // Language for the document which is chosen in the front end by the user parameter.language // Language for the document which is chosen in the front end by the user
)); );
} catch (error) {
// console.error("Error in SAIA OpenAI GPT module:", error);
reject(error)
}
})
} catch (error) {
console.error("Error in SAIA OpenAI GPT module:", error);
}
}, },
createDocumentFromTranscript: async function(transcriptPath, documentTypePath, language = "en") { // default language is English createDocumentFromTranscript: async function(transcriptPath, documentTypePath, language = "en") { // default language is English
return new Promise(async(resolve, reject) => { try {
try { const transcript = await fs.promises.readFile(transcriptPath, "utf-8"); //read transcript file from Path
const transcript = await fs.promises.readFile(transcriptPath, "utf-8"); //read transcript file from Path const documentType = await fs.promises.readFile(documentTypePath, "utf-8"); //read document type from Path
const documentType = await fs.promises.readFile(documentTypePath, "utf-8"); //read document type from Path const promptText = `${documentType}, in language ${language}, transcript:\n\n${transcript}`; //combine doc type, language and transcript - Change prompt here if needed
const promptText = `${documentType}, in language ${language}, transcript:\n\n${transcript}`; //combine doc type, language and transcript - Change prompt here if needed
// --- REST CALL --- // --- REST CALL ---
const response = await fetch(SAIA_URL, { //safe model response in variable const response = await fetch(SAIA_URL, {
method: "POST", method: "POST",
headers: { headers: {
"Authorization": `Bearer ${SAIA_API_KEY}`, "Authorization": `Bearer ${SAIA_API_KEY}`,
"Accept": "application/json", "Accept": "application/json",
"Content-Type": "application/json" "Content-Type": "application/json"
}, },
body: JSON.stringify({ body: JSON.stringify({
model: "openai-gpt-oss-120b", model: "openai-gpt-oss-120b",
messages: [ messages: [
{ role: "system", content: "You are a helpful assistant that generates HTML documents from transcripts. Output only valid HTML content without any preamble, explanations, or markdown formatting." }, { role: "system", content: "You are a helpful assistant that generates HTML documents from transcripts. Output only valid HTML content without any preamble, explanations, or markdown formatting." },
{ role: "user", content: promptText } { role: "user", content: promptText }
], ],
temperature: 0 temperature: 0
}) })
}); });
if (!response.ok) { //ok is true when a responce was successfull if (!response.ok) { //ok is true when a response was successful
const text = await response.text(); const text = await response.text();
throw new Error(`SAIA API error (${response.status}): ${text}`); throw new Error(`SAIA API error (${response.status}): ${text}`);
}
const data = await response.json();
// Get generated text from response or default to empty string (if null)
// SAIA uses OpenAI-compatible structure: data.choices[x].message.content
const output = data.choices?.[0]?.message?.content || "";
let inputTranscriptName = path.basename(transcriptPath, path.extname(transcriptPath)); // Name for the output file
// console.log(inputTranscriptName);
const outPath = path.join(outputDir, `${inputTranscriptName}.html`); // Output file path & name to make naming dynamic. Pulled from input transcript name
fs.writeFileSync(outPath, output, "utf8"); // Write output to file
// console.log("Generated document written to:", outPath);
resolve(outPath)
} catch (error) {
// console.error("Error generating SAIA content:", error);
reject(error)
} }
})
const data = await response.json();
// Get generated text from response or default to empty string (if null)
// SAIA uses OpenAI-compatible structure: data.choices[x].message.content
const output = data.choices?.[0]?.message?.content || "";
let inputTranscriptName = path.basename(transcriptPath, path.extname(transcriptPath)); // Name for the output file
console.log(inputTranscriptName);
const outPath = path.join(outputDir, `${inputTranscriptName}.html`); // Output file path & name to make naming dynamic. Pulled from input transcript name
fs.writeFileSync(outPath, output, "utf8"); // Write output to file
console.log("Generated document written to:", outPath);
} catch (error) {
console.error("Error generating SAIA content:", error);
}
} }
}; };
+1 -1
View File
@@ -71,7 +71,7 @@ const module_exports = {
const output = data?.candidates?.[0]?.content?.parts?.[0]?.text || ""; const output = data?.candidates?.[0]?.content?.parts?.[0]?.text || "";
let inputTranscriptName = path.basename(transcriptPath, path.extname(transcriptPath)); // Name for the output file let inputTranscriptName = path.basename(transcriptPath, path.extname(transcriptPath)); // Name for the output file
// console.log(inputTranscriptName); // console.log(inputTranscriptName);
const outPath = path.join(outputDir, `${inputTranscriptName}.html`); // Output file path & name to make naming dynamic. Pulled from input transcript name const outPath = path.join(outputDir, `${inputTranscriptName}.md`); // Output file path & name to make naming dynamic. Pulled from input transcript name
fs.writeFileSync(outPath, output, "utf8"); // Write output to file fs.writeFileSync(outPath, output, "utf8"); // Write output to file
// console.log("Generated document written to:", outPath); // console.log("Generated document written to:", outPath);
+52 -58
View File
@@ -18,72 +18,66 @@ const module_exports = {
description: "Generates documents using QWEN 3 235B via SAIA platform", description: "Generates documents using QWEN 3 235B via SAIA platform",
async function(parameter) { async function(parameter) {
return new Promise(async (resolve, reject) => { try {
try { console.log("SAIA QWEN 3 235B module invoked with parameters:", parameter);
// console.log("SAIA QWEN 3 235B module invoked with parameters:", parameter);
resolve(await this.createDocumentFromTranscript( //Call the function to create document with transcript, document type and language await this.createDocumentFromTranscript( // Call the function to create document with transcript, document type and language
parameter.inputTranscriptPath, // Path to input transcript file parameter.inputTranscriptPath, // Path to input transcript file
parameter.documentTypePath, // Path to document type file which is chosen in the front end by the user parameter.documentTypePath, // Path to document type file which is chosen in the front end by the user
parameter.language // Language for the document which is chosen in the front end by the user parameter.language // Language for the document which is chosen in the front end by the user
)); );
} catch (error) {
// console.error("Error in SAIA QWEN 3 235B module:", error);
reject(error)
}
})
} catch (error) {
console.error("Error in SAIA QWEN 3 235B module:", error);
}
}, },
createDocumentFromTranscript: async function(transcriptPath, documentTypePath, language = "en") { // default language is English createDocumentFromTranscript: async function(transcriptPath, documentTypePath, language = "en") { // default language is English
return new Promise(async(resolve, reject) => { try {
try { const transcript = await fs.promises.readFile(transcriptPath, "utf-8"); // read transcript file from Path
const transcript = await fs.promises.readFile(transcriptPath, "utf-8"); //read transcript file from Path const documentType = await fs.promises.readFile(documentTypePath, "utf-8"); // read document type from Path
const documentType = await fs.promises.readFile(documentTypePath, "utf-8"); //read document type from Path const promptText = `${documentType}, in language ${language}, transcript:\n\n${transcript}`; // combine doc type, language and transcript - Change prompt here if needed
const promptText = `${documentType}, in language ${language}, transcript:\n\n${transcript}`; //combine doc type, language and transcript - Change prompt here if needed
// --- REST CALL --- // --- REST CALL ---
const response = await fetch(SAIA_URL, { //safe model response in variable const response = await fetch(SAIA_URL, {
method: "POST", method: "POST",
headers: { headers: {
"Authorization": `Bearer ${SAIA_API_KEY}`, "Authorization": `Bearer ${SAIA_API_KEY}`,
"Accept": "application/json", "Accept": "application/json",
"Content-Type": "application/json" "Content-Type": "application/json"
}, },
body: JSON.stringify({ body: JSON.stringify({
model: "qwen3-235b-a22b", model: "qwen3-235b-a22b",
messages: [ messages: [
{ role: "system", content: "You are a helpful assistant that generates HTML documents from transcripts. Output only valid HTML content without any preamble, explanations, or markdown formatting." }, { role: "system", content: "You are a helpful assistant that generates HTML documents from transcripts. Output only valid HTML content without any preamble, explanations, or markdown formatting." },
{ role: "user", content: promptText } { role: "user", content: promptText }
], ],
temperature: 0 temperature: 0
}) })
}); });
if (!response.ok) { //ok is true when a responce was successfull if (!response.ok) { // ok is true when a response was successful
const text = await response.text(); const text = await response.text();
throw new Error(`SAIA API error (${response.status}): ${text}`); throw new Error(`SAIA API error (${response.status}): ${text}`);
}
const data = await response.json();
// Get generated text from response or default to empty string (if null)
// SAIA uses OpenAI-compatible structure: data.choices[x].message.content
const output = data.choices?.[0]?.message?.content || "";
let inputTranscriptName = path.basename(transcriptPath, path.extname(transcriptPath)); // Name for the output file
// console.log(inputTranscriptName);
const outPath = path.join(outputDir, `${inputTranscriptName}.html`); // Output file path & name to make naming dynamic. Pulled from input transcript name
fs.writeFileSync(outPath, output, "utf8"); // Write output to file
// console.log("Generated document written to:", outPath);
resolve(outPath)
} catch (error) {
// console.error("Error generating SAIA content:", error);
reject(error)
} }
})
const data = await response.json();
// Get generated text from response or default to empty string (if null)
// SAIA uses OpenAI-compatible structure: data.choices[x].message.content
const output = data.choices?.[0]?.message?.content || "";
let inputTranscriptName = path.basename(transcriptPath, path.extname(transcriptPath)); // Name for the output file
console.log(inputTranscriptName);
const outPath = path.join(outputDir, `${inputTranscriptName}.html`); // Output file path & name to make naming dynamic. Pulled from input transcript name
fs.writeFileSync(outPath, output, "utf8"); // Write output to file
console.log("Generated document written to:", outPath);
} catch (error) {
console.error("Error generating SAIA content:", error);
}
} }
}; };