fast72 commited on
Commit
80d66cf
·
verified ·
1 Parent(s): 01aa32b

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +25 -7
server.js CHANGED
@@ -1,7 +1,7 @@
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;
@@ -21,21 +21,39 @@ async function transcript(url) {
21
  .join(' ');
22
 
23
  return text;
24
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  app.get('/summary', async (req, res) => {
27
  const { url } = req.query;
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: 'AIzaSyCgDZhJ6d_8ZfmJzp17ibFXqtxg5wkTZtk' });
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-1.5-pro',
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' });
 
1
  const express = require('express');
2
  const cheerio = require('cheerio');
3
  const axios = require('axios');
4
+ const FormData = require('form-data');
5
 
6
  const app = express();
7
  const PORT = 7860;
 
21
  .join(' ');
22
 
23
  return text;
24
+ };
25
+
26
+ POST https://mind.hydrooo.web.id/v2/chat 200
27
+
28
+ Response Headers
29
+
30
+ access-control-allow-origin: *
31
+ content-length: 127
32
+ content-type: application/json; charset=utf-8
33
+ date: Fri, 28 Mar 2025 22:01:46 GMT
34
+ etag: W/"7f-np0JQgT6PQsy51qetZibp/AliuQ"
35
+ server: railway-edge
36
+ x-powered-by: Express
37
+ x-railway-edge: railway/asia-southeast1
38
+ x-railway-request-id: oncZt8QAR6KdAZXGT-S-UA_3176973899
39
+
40
+ {"status":200,"result":{"model":"gemini-2.0-pro-exp-02-05","messages":[{"role":"ai","content":"Oi! Como posso ajudar? 😊"}]}}
41
+
42
 
43
  app.get('/summary', async (req, res) => {
44
  const { url } = req.query;
45
  if (!url) return res.status(400).json({ error: 'Missing video URL' });
46
  try {
47
  const rttex = await transcript(url);
 
48
  const prompt = `INPUT: ${rttex}`;
49
  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.`;
50
+ const form = new FormData();
51
+ form.append('content', `${sysp}\n${prompt}`);
52
+ form.append('model', '@google/gemini-2.0-pro-exp-02-05');
53
+ const { data } = await axios.post('https//mind.hydrooo.web.id/v2/chat', form, {
54
+ headers: form.getHeaders()
55
  });
56
+ res.json({ summary: data?.result?.messages[0]?.content?.trim() })
57
  } catch (error) {
58
  console.log(error);
59
  res.status(500).json({ error: 'Failed to fetch transcript' });