fast72 commited on
Commit
4fc5959
·
verified ·
1 Parent(s): ee7e9bb

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +7 -2
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 { data } = await axios.get(`https://fastrestapis.fasturl.cloud/aillm/gpt-4o-turbo?ask=${encodeURIComponent(prompt)}&style=${encodeURIComponent(sysp)}`);
33
- res.json({ summary: data?.result?.trim() })
 
 
 
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' });