mirror of
https://gitlab.rlp.net/proj-wise2526-video2document/video2document.git
synced 2026-06-15 18:01:52 +02:00
Test created and changes to gemini.js file
This commit is contained in:
@@ -1,23 +1,22 @@
|
|||||||
import fs from "fs";
|
const fs = require("fs");
|
||||||
import { dirname } from "path";
|
const path = require("path");
|
||||||
import { fileURLToPath } from "url";
|
|
||||||
|
|
||||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
||||||
const { GoogleGenAI } = require("@google/genai");
|
const { GoogleGenAI } = require("@google/genai");
|
||||||
|
|
||||||
|
const outputDir = path.join(__dirname, "../../../storage/documents");
|
||||||
|
|
||||||
|
if (!fs.existsSync(outputDir)) {
|
||||||
|
fs.mkdirSync(outputDir, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
const ai = new GoogleGenAI({
|
const ai = new GoogleGenAI({
|
||||||
apiKey: process.env.GOOGLE_API_KEY
|
apiKey: process.env.GOOGLE_API_KEY
|
||||||
});
|
});
|
||||||
|
|
||||||
const outputDir = `${__dirname}/../../../storage/documents`;
|
|
||||||
if (!fs.existsSync(outputDir)) {
|
|
||||||
fs.mkdirSync(outputDir, { recursive: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: "llm-gemini",
|
name: "llm-gemini",
|
||||||
type: "llm",
|
type: "llm",
|
||||||
displayname: "Gemini LLM",
|
displayname: "Gemini LLM",
|
||||||
|
description: "Generates documents using Google Gemini LLM",
|
||||||
|
|
||||||
async function(parameter) {
|
async function(parameter) {
|
||||||
try {
|
try {
|
||||||
@@ -25,7 +24,8 @@ module.exports = {
|
|||||||
|
|
||||||
await this.createDocumentFromTranscript(
|
await this.createDocumentFromTranscript(
|
||||||
parameter.inputTranscriptPath,
|
parameter.inputTranscriptPath,
|
||||||
parameter.documentType
|
parameter.documentTypePath,
|
||||||
|
parameter.language
|
||||||
);
|
);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -33,23 +33,27 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
createDocumentFromTranscript: async function(transcriptPath, documentType) {
|
createDocumentFromTranscript: async function(transcriptPath, documentTypePath, language = "en") {
|
||||||
try {
|
try {
|
||||||
const transcript = await fs.promises.readFile(transcriptPath, "utf-8");
|
const transcript = await fs.promises.readFile(transcriptPath, "utf-8");
|
||||||
|
const documentType = await fs.promises.readFile(documentTypePath, "utf-8");
|
||||||
|
|
||||||
const text = `${documentType}\n\n${transcript}`;
|
const promptText = `${documentType}, in language ${language}, transcript:\n\n${transcript}`;
|
||||||
|
|
||||||
const response = await ai.models.generateContent({
|
const response = await ai.models.generateContent({
|
||||||
model: "gemini-2.5-flash",
|
model: "gemini-2.5-flash",
|
||||||
contents: text
|
contents: promptText
|
||||||
});
|
});
|
||||||
|
|
||||||
const output = response.text ?? "";
|
const output = response.text || "";
|
||||||
|
|
||||||
|
const outPath = path.join(outputDir, "test.md");
|
||||||
|
fs.writeFileSync(outPath, output, "utf8");
|
||||||
|
|
||||||
|
console.log("Generated document written to:", outPath);
|
||||||
|
|
||||||
fs.writeFileSync(`${outputDir}/test.md`, output, "utf8");
|
|
||||||
console.log("Generated document written to test.md");
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error generating content:", error);
|
console.error("Error generating Gemini content:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
|
||||||
|
**Goal:** Generate a structured meeting report (Markdown). **Output ONLY:** final .md. No meta.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"FORMAT": "markdown",
|
||||||
|
|
||||||
|
"STRUCTURE": {
|
||||||
|
"titlepage": ["title","date","start","end","duration","location","host","participants"],
|
||||||
|
"toc": "[section](#anchor) — HH:MM:SS",
|
||||||
|
"section": {
|
||||||
|
"h2": "<topic> — HH:MM:SS",
|
||||||
|
"summary": "1 sentence",
|
||||||
|
"key_points": "<=5 bullets, quotes optional",
|
||||||
|
"decisions": "list: text | owner | due",
|
||||||
|
"actions": "table: id | task | owner | due | status"
|
||||||
|
},
|
||||||
|
"exec_summary": "3 short sentences",
|
||||||
|
"consolidated": ["decisions", "actions"],
|
||||||
|
"appendix": "optional"
|
||||||
|
},
|
||||||
|
|
||||||
|
"STYLE": {
|
||||||
|
"tone": "neutral, concise",
|
||||||
|
"ts_format": "HH:MM:SS",
|
||||||
|
"no_meta": true
|
||||||
|
},
|
||||||
|
|
||||||
|
"PROCESS": {
|
||||||
|
"timestamps": "use if present; else estimate minimal",
|
||||||
|
"speakers": "use labels; else Speaker X",
|
||||||
|
"long_transcripts": "chunk → summarize → merge",
|
||||||
|
"unclear": "UNKLAR:<reason>"
|
||||||
|
},
|
||||||
|
|
||||||
|
"JSON_OUTPUT_OPTIONAL": true,
|
||||||
|
|
||||||
|
"PROMPT_SNIPPET": "Generate meeting report in markdown using STRUCTURE and STYLE. Output only the report."
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
const gemini = require("../../../services/modules/llm-gemini/gemini.js");
|
||||||
|
|
||||||
|
gemini.function({
|
||||||
|
inputTranscriptPath: "./transcript.txt",
|
||||||
|
documentTypePath: "./documentType.txt",
|
||||||
|
language: "de"
|
||||||
|
});
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
Meeting Transcript - Video2Document Project
|
||||||
|
Date: November 18, 2025
|
||||||
|
Attendees: Mike Hughes, Stefan Heyne, Alice Smith, Bob Johnson, Clara Nguyen
|
||||||
|
|
||||||
|
[09:00 AM] Mike Hughes: Good morning, everyone. Let’s start the weekly project meeting for Video2Document. We have multiple points on the agenda today, including updates from each module, integration challenges, and the next sprint plan.
|
||||||
|
|
||||||
|
[09:02 AM] Alice Smith: I’ve been working on the document formatting module. I’ve implemented support for markdown and PDF outputs. Still need to handle custom templates for clients.
|
||||||
|
|
||||||
|
[09:05 AM] Bob Johnson: Video preprocessing is progressing. I’ve added support for multiple video codecs and automated audio extraction. I found that some videos require normalization before sending to the LLM.
|
||||||
|
|
||||||
|
[09:08 AM] Stefan Heyne: For the LLM integration, I tested a few transcripts. Gemini handles summaries well, but we might need to tune prompts to get consistent headings and formatting.
|
||||||
|
|
||||||
|
[09:12 AM] Clara Nguyen: On the storage side, I’ve configured S3 buckets for document storage. Permissions and versioning are set, but we still need to handle large batch uploads efficiently.
|
||||||
|
|
||||||
|
[09:15 AM] Mike Hughes: Great updates. Let’s discuss some issues I noticed in the last integration test. First, audio extraction sometimes fails with videos longer than 20 minutes. Bob, any insights?
|
||||||
|
|
||||||
|
[09:17 AM] Bob Johnson: Yes, I believe the FFmpeg timeout settings need adjustment. Also, some containerized environments lack the right codec libraries, causing failures.
|
||||||
|
|
||||||
|
[09:20 AM] Stefan Heyne: On the LLM side, we noticed that very long transcripts lead to truncated outputs. We may need to split transcripts or chunk content intelligently before sending to Gemini.
|
||||||
|
|
||||||
|
[09:22 AM] Alice Smith: For document formatting, longer outputs sometimes exceed the template limits. We need to implement pagination or splitting by sections.
|
||||||
|
|
||||||
|
[09:25 AM] Clara Nguyen: For batch uploads, we can implement parallel processing with rate limiting to avoid S3 throttling.
|
||||||
|
|
||||||
|
[09:28 AM] Mike Hughes: Action items from today’s discussion:
|
||||||
|
1. Bob: Adjust FFmpeg settings for long videos and document required codecs.
|
||||||
|
2. Stefan: Implement transcript chunking and test Gemini output for longer documents.
|
||||||
|
3. Alice: Add section splitting and pagination to document formatting.
|
||||||
|
4. Clara: Optimize batch upload process and test with larger datasets.
|
||||||
|
|
||||||
|
[09:32 AM] Bob Johnson: Also, I propose adding logging for all preprocessing steps. This will help debug failed video conversions quickly.
|
||||||
|
|
||||||
|
[09:35 AM] Stefan Heyne: Agreed. Logging in the LLM pipeline will also help identify failed content generations or prompt issues.
|
||||||
|
|
||||||
|
[09:38 AM] Alice Smith: I can integrate logging hooks into the formatting module. Should include timestamped entries and file references.
|
||||||
|
|
||||||
|
[09:40 AM] Clara Nguyen: I’ll add S3 upload logs and alerting for failed uploads.
|
||||||
|
|
||||||
|
[09:42 AM] Mike Hughes: Perfect. Next sprint planning: we’ll prioritize long-video handling, chunked LLM summarization, and document formatting robustness. Everything else can follow in the subsequent sprint.
|
||||||
|
|
||||||
|
[09:45 AM] Bob Johnson: I’ll provide a small script for testing various video lengths. Can be used to benchmark preprocessing times.
|
||||||
|
|
||||||
|
[09:48 AM] Stefan Heyne: I’ll create example transcripts of different sizes to test Gemini LLM’s handling and summarize consistency.
|
||||||
|
|
||||||
|
[09:50 AM] Alice Smith: I’ll create template variations for large documents and test rendering performance.
|
||||||
|
|
||||||
|
[09:52 AM] Clara Nguyen: I’ll simulate batch uploads and stress-test the S3 storage setup.
|
||||||
|
|
||||||
|
[09:55 AM] Mike Hughes: Excellent. Let’s reconvene next Wednesday for progress review. Make sure to push your updates to the repository beforehand.
|
||||||
|
|
||||||
|
[09:57 AM] All: Agreed.
|
||||||
|
|
||||||
|
Meeting adjourned at 10:00 AM.
|
||||||
Reference in New Issue
Block a user