Update server.js
Browse files
server.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
const express = require('express');
|
| 2 |
const cheerio = require('cheerio');
|
| 3 |
const axios = require('axios');
|
|
|
|
| 4 |
|
| 5 |
const app = express();
|
| 6 |
const PORT = 7860;
|
|
@@ -27,10 +28,14 @@ app.get('/summary', async (req, res) => {
|
|
| 27 |
if (!url) return res.status(400).json({ error: 'Missing video URL' });
|
| 28 |
try {
|
| 29 |
const rttex = await transcript(url);
|
|
|
|
| 30 |
const prompt = `INPUT: ${rttex}`;
|
| 31 |
const sysp = `You are an advanced AI designed for high-quality summarization. Your task is to generate precise, concise, and accurate summaries, extracting only the essential information while maintaining clarity. Do not include explanations, opinions, or unnecessary details. Ensure the summary is in the same language as the input.`;
|
| 32 |
-
const
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
| 34 |
} catch (error) {
|
| 35 |
console.log(error);
|
| 36 |
res.status(500).json({ error: 'Failed to fetch transcript' });
|
|
|
|
| 1 |
const express = require('express');
|
| 2 |
const cheerio = require('cheerio');
|
| 3 |
const axios = require('axios');
|
| 4 |
+
const { GoogleGenAI } = require('@google/genai');
|
| 5 |
|
| 6 |
const app = express();
|
| 7 |
const PORT = 7860;
|
|
|
|
| 28 |
if (!url) return res.status(400).json({ error: 'Missing video URL' });
|
| 29 |
try {
|
| 30 |
const rttex = await transcript(url);
|
| 31 |
+
const ai = new GoogleGenAI({ apiKey: process.env.KEY });
|
| 32 |
const prompt = `INPUT: ${rttex}`;
|
| 33 |
const sysp = `You are an advanced AI designed for high-quality summarization. Your task is to generate precise, concise, and accurate summaries, extracting only the essential information while maintaining clarity. Do not include explanations, opinions, or unnecessary details. Ensure the summary is in the same language as the input.`;
|
| 34 |
+
const response = await ai.models.generateContent({
|
| 35 |
+
model: 'gemini-2.5-pro-exp-03-25',
|
| 36 |
+
contents: `${sysp}\n${prompt}`,
|
| 37 |
+
});
|
| 38 |
+
res.json({ summary: response?.text?.trim() })
|
| 39 |
} catch (error) {
|
| 40 |
console.log(error);
|
| 41 |
res.status(500).json({ error: 'Failed to fetch transcript' });
|