import React, { useState } from 'react'; import './GeminiTest.css'; import GeminiService from '../services/GeminiService'; const GeminiTest = () => { const [prompt, setPrompt] = useState('Write a short recipe for spaghetti bolognese.'); const [response, setResponse] = useState(''); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); // Initialize Gemini service with the API key const geminiService = new GeminiService('AIzaSyAIxqZ9V0Ozj1u5-WCGdSu6_MNSKyCuRJU'); const handleTest = async () => { if (!prompt.trim()) return; setIsLoading(true); setError(null); setResponse(''); try { // Call Gemini API const result = await geminiService.generateText(prompt, { temperature: 0.7, maxOutputTokens: 2048 }); setResponse(result.text); } catch (err) { console.error('Error testing Gemini API:', err); setError(err.message || 'Failed to get response from Gemini API'); } finally { setIsLoading(false); } }; return (

Gemini API Test