Update language handling in document processing to support dynamic output languages

This commit is contained in:
MikeHughes-BIN
2026-01-15 17:31:53 +01:00
parent 4ac59e7597
commit ea0ff25d1a
4 changed files with 27 additions and 1 deletions
+1 -1
View File
@@ -253,7 +253,7 @@ electron.ipcMain.on("file_submit", async (event, args) => {
.function(args.document.module, { .function(args.document.module, {
inputTranscriptPath: transcriptpath, inputTranscriptPath: transcriptpath,
documentTypePath: "./storage/documentType/" + templateFile, documentTypePath: "./storage/documentType/" + templateFile,
language: "en", language: args.document.outputLanguage
}) })
.then((resp) => { .then((resp) => {
console.log(resp); console.log(resp);
+10
View File
@@ -1,6 +1,8 @@
// const fs = require('fs'); // const fs = require('fs');
// const path = require('path'); // const path = require('path');
const e = require("express");
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)) {
@@ -43,6 +45,14 @@ const module_exports = {
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
if (language.toLowerCase() === "de") {
language = "German"
}else if (language.toLowerCase() === "in") {
language = "Indish"
} else {
language = "English"
}
// return // return
// --- REST CALL --- // --- REST CALL ---
+8
View File
@@ -44,6 +44,14 @@ const module_exports = {
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
if (language.toLowerCase() === "de") {
language = "German"
}else if (language.toLowerCase() === "in") {
language = "Indish"
} else {
language = "English"
}
// --- REST CALL --- // --- REST CALL ---
const response = await fetch(`${GEMINI_URL}?key=${GEMINI_API_KEY}`, { //safe model response in variable const response = await fetch(`${GEMINI_URL}?key=${GEMINI_API_KEY}`, { //safe model response in variable
method: "POST", method: "POST",
+8
View File
@@ -44,6 +44,14 @@ const module_exports = {
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
if (language.toLowerCase() === "de") {
language = "German"
}else if (language.toLowerCase() === "in") {
language = "Indish"
} else {
language = "English"
}
// --- REST CALL --- // --- REST CALL ---
const response = await fetch(SAIA_URL, { //safe model response in variable const response = await fetch(SAIA_URL, { //safe model response in variable
method: "POST", method: "POST",