Spaces:
Paused
Paused
Download controllers/gemini.controller.js from wokogaming/ML-LT: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/wokogaming/ML-LT/resolve/main/controllers/gemini.controller.js
- Command line
-
hf download hf://spaces/wokogaming/ML-LT/controllers/gemini.controller.js
-
curl -L -o gemini.controller.js https://huggingface.co/spaces/wokogaming/ML-LT/resolve/main/controllers/gemini.controller.js
1.13 kB
| import geminiService from '../services/gemini.service.js'; | |
| class GeminiController { | |
| async generate(req, res) { | |
| try { | |
| const { prompt } = req.body; | |
| if (!prompt) { | |
| return res.status(400).json({ error: 'Prompt is required' }); | |
| } | |
| const data = await geminiService.generateContent(prompt); | |
| res.json(data); | |
| } catch (error) { | |
| console.error('Gemini Error:', error.message); | |
| res.status(500).json({ | |
| error: 'Failed to generate content', | |
| details: error.message | |
| }); | |
| } | |
| } | |
| async summarize(req, res) { | |
| try { | |
| const { content, title } = req.body; | |
| if (!content) { | |
| return res.status(400).json({ error: 'Content is required' }); | |
| } | |
| const data = await geminiService.summarizeNews(content, title); | |
| res.json(data); | |
| } catch (error) { | |
| console.error('Gemini Summarize Error:', error.message); | |
| res.status(500).json({ | |
| error: 'Failed to summarize content', | |
| details: error.message | |
| }); | |
| } | |
| } | |
| } | |
| export default new GeminiController(); |