mirror of
https://gitlab.rlp.net/proj-wise2526-video2document/video2document.git
synced 2026-06-15 18:01:52 +02:00
Merge branch 'develop' into 'feature/meeting_document_types'
# Conflicts: # electron/main/script.js # main.js
This commit is contained in:
@@ -147,12 +147,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="step" id="step6" style="display:none;">
|
<div class="step" id="step6" style="display:none;">
|
||||||
<button class="download-btn" id="downloadButton" onclick="" disabled>Download</button>
|
<button class="download-btn" id="downloadButton" onclick="fileDownload()">Download</button>
|
||||||
|
|
||||||
<div class="progressbar" id="progressbar">
|
|
||||||
<div class="progress_fill"></div>
|
|
||||||
<span class="progress_text">0%</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ try {
|
|||||||
contextBridge.exposeInMainWorld("submitSpeaker", {
|
contextBridge.exposeInMainWorld("submitSpeaker", {
|
||||||
submitSpeaker: (speaker_names) => {ipcRenderer.send("speaker_submit", speaker_names)}
|
submitSpeaker: (speaker_names) => {ipcRenderer.send("speaker_submit", speaker_names)}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
contextBridge.exposeInMainWorld("download", {
|
||||||
|
file_download: () => {ipcRenderer.send("file_download")}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
ipcRenderer.on("error", (event, err) => {alert(err)})
|
ipcRenderer.on("error", (event, err) => {alert(err)})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
+12
-17
@@ -33,7 +33,6 @@ uploadContainer.addEventListener("drop", (e) => {
|
|||||||
|
|
||||||
window.addEventListener('load', async (e) => {
|
window.addEventListener('load', async (e) => {
|
||||||
try {
|
try {
|
||||||
console.log("test");
|
|
||||||
loadLanguageOptions();
|
loadLanguageOptions();
|
||||||
const value = await window.onStartup.getModuleNames();
|
const value = await window.onStartup.getModuleNames();
|
||||||
loadAiOptions(value.ai_modules);
|
loadAiOptions(value.ai_modules);
|
||||||
@@ -117,7 +116,7 @@ docFormat.addEventListener("change", (e) =>{
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
docFormatSummary1.addEventListener("change", (e) =>{
|
docFormatSummary1.addEventListener("change", (e) =>{
|
||||||
try {
|
try {
|
||||||
if(docFormatSummary1.checked){
|
if(docFormatSummary1.checked){
|
||||||
@@ -129,7 +128,7 @@ docFormatSummary1.addEventListener("change", (e) =>{
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
docFormatSummary2.addEventListener("change", (e) =>{
|
docFormatSummary2.addEventListener("change", (e) =>{
|
||||||
try {
|
try {
|
||||||
if(docFormatSummary2.checked){
|
if(docFormatSummary2.checked){
|
||||||
@@ -141,7 +140,7 @@ docFormatSummary2.addEventListener("change", (e) =>{
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
docFormatSummary3.addEventListener("change", (e) =>{
|
docFormatSummary3.addEventListener("change", (e) =>{
|
||||||
try {
|
try {
|
||||||
if(docFormatSummary3.checked){
|
if(docFormatSummary3.checked){
|
||||||
@@ -153,7 +152,7 @@ docFormatSummary3.addEventListener("change", (e) =>{
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
docFormatCustom.addEventListener("change", (e) =>{
|
docFormatCustom.addEventListener("change", (e) =>{
|
||||||
try {
|
try {
|
||||||
if(docFormatCustom.checked){
|
if(docFormatCustom.checked){
|
||||||
@@ -165,7 +164,7 @@ docFormatCustom.addEventListener("change", (e) =>{
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
//Speaker change listener
|
//Speaker change listener
|
||||||
cur_speaker.addEventListener("change", (e) =>{
|
cur_speaker.addEventListener("change", (e) =>{
|
||||||
@@ -174,16 +173,12 @@ cur_speaker.addEventListener("change", (e) =>{
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
window.electron.speakerAudios((event, arg) => {
|
window.audios.speakerAudios((event, arg) => {
|
||||||
try {
|
|
||||||
setSpeakerAudiosValue(arg);
|
setSpeakerAudiosValue(arg);
|
||||||
loadSpeakerOptions(arg);
|
loadSpeakerOptions(arg);
|
||||||
} catch (error) {
|
});
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
window.electron.progress((event, arg) => {
|
window.electron.progress((event, arg) => {
|
||||||
if(arg.curstep == 1){
|
if(arg.curstep == 1){
|
||||||
@@ -207,7 +202,7 @@ function setCircleOne(){
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
};
|
||||||
function setCircleZwo(){
|
function setCircleZwo(){
|
||||||
try {
|
try {
|
||||||
if(document.getElementById("box2").style.backgroundColor == "green"){
|
if(document.getElementById("box2").style.backgroundColor == "green"){
|
||||||
@@ -219,7 +214,7 @@ function setCircleZwo(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
};
|
||||||
function setCircleThree(){
|
function setCircleThree(){
|
||||||
try {
|
try {
|
||||||
if(document.getElementById("box3").style.backgroundColor == "green"){
|
if(document.getElementById("box3").style.backgroundColor == "green"){
|
||||||
@@ -231,7 +226,7 @@ function setCircleThree(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
};
|
||||||
function setCircleFour(){
|
function setCircleFour(){
|
||||||
try {
|
try {
|
||||||
if(document.getElementById("box4").style.backgroundColor == "green"){
|
if(document.getElementById("box4").style.backgroundColor == "green"){
|
||||||
@@ -242,7 +237,7 @@ function setCircleFour(){
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ function checkBoxes() {
|
|||||||
var pathTest = window.electronAPI.getFilePath(videoUpload.files[0]);
|
var pathTest = window.electronAPI.getFilePath(videoUpload.files[0]);
|
||||||
var pathToLower = pathTest.toLowerCase();
|
var pathToLower = pathTest.toLowerCase();
|
||||||
if(testEndings.some(e => pathToLower.endsWith(e))){
|
if(testEndings.some(e => pathToLower.endsWith(e))){
|
||||||
document.getElementById("progressbar").style.visibility = "visible";
|
|
||||||
//assembly of the json for the main
|
//assembly of the json for the main
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -57,8 +56,7 @@ function checkBoxes() {
|
|||||||
const sendingPackage = {
|
const sendingPackage = {
|
||||||
"video": {
|
"video": {
|
||||||
"module":"extraction-video-to-audio",
|
"module":"extraction-video-to-audio",
|
||||||
"inputVideoPath": pathTest,
|
"inputVideoPath": pathTest
|
||||||
"outputType": outputType.value
|
|
||||||
},
|
},
|
||||||
"transcription": {
|
"transcription": {
|
||||||
"module": transcriptionType.value
|
"module": transcriptionType.value
|
||||||
@@ -114,7 +112,6 @@ function changeLanguage(language) {
|
|||||||
function handleFiles(files) {
|
function handleFiles(files) {
|
||||||
try {
|
try {
|
||||||
if (files.length > 0) {
|
if (files.length > 0) {
|
||||||
document.getElementById("progressbar").style.visibility = "visible";
|
|
||||||
const file = files[0];
|
const file = files[0];
|
||||||
if (file.type.startsWith('video/')) {
|
if (file.type.startsWith('video/')) {
|
||||||
const filePath = window.explorer.onFileDrop(files[0])
|
const filePath = window.explorer.onFileDrop(files[0])
|
||||||
@@ -339,3 +336,10 @@ function sendSpeakerPackages(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fileDownload() {
|
||||||
|
try {
|
||||||
|
window.download.file_download();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Download failed:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -124,10 +124,12 @@ 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 = 4
|
let totalsteps = 4
|
||||||
|
|
||||||
@@ -230,6 +232,9 @@ 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 =
|
||||||
|
|||||||
@@ -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,8 +9,7 @@ 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",
|
||||||
@@ -19,66 +18,72 @@ 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) {
|
||||||
try {
|
return new Promise(async (resolve, reject) => {
|
||||||
console.log("SAIA OpenAI GPT module invoked with parameters:", parameter);
|
try {
|
||||||
|
// console.log("SAIA OpenAI GPT module invoked with parameters:", parameter);
|
||||||
|
|
||||||
await this.createDocumentFromTranscript( //Call the function to create document with transcript, document type and language
|
resolve(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
|
||||||
try {
|
return new Promise(async(resolve, reject) => {
|
||||||
const transcript = await fs.promises.readFile(transcriptPath, "utf-8"); //read transcript file from Path
|
try {
|
||||||
const documentType = await fs.promises.readFile(documentTypePath, "utf-8"); //read document type from Path
|
const transcript = await fs.promises.readFile(transcriptPath, "utf-8"); //read transcript file from Path
|
||||||
const promptText = `${documentType}, in language ${language}, transcript:\n\n${transcript}`; //combine doc type, language and transcript - Change prompt here if needed
|
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
|
||||||
|
|
||||||
// --- REST CALL ---
|
// --- REST CALL ---
|
||||||
const response = await fetch(SAIA_URL, {
|
const response = await fetch(SAIA_URL, { //safe model response in variable
|
||||||
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 response was successful
|
if (!response.ok) { //ok is true when a responce was successfull
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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}.md`); // Output file path & name to make naming dynamic. Pulled from input transcript name
|
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
|
fs.writeFileSync(outPath, output, "utf8"); // Write output to file
|
||||||
|
|
||||||
// console.log("Generated document written to:", outPath);
|
// console.log("Generated document written to:", outPath);
|
||||||
|
|||||||
@@ -18,66 +18,72 @@ 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) {
|
||||||
try {
|
return new Promise(async (resolve, reject) => {
|
||||||
console.log("SAIA QWEN 3 235B module invoked with parameters:", parameter);
|
try {
|
||||||
|
// console.log("SAIA QWEN 3 235B module invoked with parameters:", parameter);
|
||||||
|
|
||||||
await this.createDocumentFromTranscript( // Call the function to create document with transcript, document type and language
|
resolve(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
|
||||||
try {
|
return new Promise(async(resolve, reject) => {
|
||||||
const transcript = await fs.promises.readFile(transcriptPath, "utf-8"); // read transcript file from Path
|
try {
|
||||||
const documentType = await fs.promises.readFile(documentTypePath, "utf-8"); // read document type from Path
|
const transcript = await fs.promises.readFile(transcriptPath, "utf-8"); //read transcript file from Path
|
||||||
const promptText = `${documentType}, in language ${language}, transcript:\n\n${transcript}`; // combine doc type, language and transcript - Change prompt here if needed
|
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
|
||||||
|
|
||||||
// --- REST CALL ---
|
// --- REST CALL ---
|
||||||
const response = await fetch(SAIA_URL, {
|
const response = await fetch(SAIA_URL, { //safe model response in variable
|
||||||
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 response was successful
|
if (!response.ok) { //ok is true when a responce was successfull
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user