@@ -6,7 +6,7 @@ import { getAuthToken } from '../utils/handleToken';
66import { useParams , useNavigate } from 'react-router-dom' ;
77import { toast } from 'react-toastify' ;
88
9- const GEMINI_API_KEY = import . meta. env . VITE_GEMINI_API_KEY ;
9+ const GROQ_API_KEY = import . meta. env . VITE_GROQ_API_KEY ;
1010const baseUrl = import . meta. env . VITE_API_URL ;
1111
1212// Form Container Component
@@ -284,9 +284,9 @@ const QuestionsConfig = ({ onNext, onBack, formData, setFormData }) => {
284284 } ) ) ;
285285 } ;
286286
287- const generateQuestionsWithGemini = async ( ) => {
288- if ( ! GEMINI_API_KEY ) {
289- toast . error ( 'Gemini API key not configured' ) ;
287+ const generateQuestionsWithGroq = async ( ) => {
288+ if ( ! GROQ_API_KEY ) {
289+ toast . error ( 'Groq API key not configured' ) ;
290290 return ;
291291 }
292292
@@ -310,23 +310,20 @@ Example format:
310310 }
311311]` ;
312312
313- const response = await fetch ( ` https://generativelanguage.googleapis .com/v1beta/models/gemini-1.5-flash-latest:generateContent?key= ${ GEMINI_API_KEY } ` , {
313+ const response = await fetch ( ' https://api.groq .com/openai/v1/chat/completions' , {
314314 method : 'POST' ,
315315 headers : {
316316 'Content-Type' : 'application/json' ,
317+ 'Authorization' : `Bearer ${ GROQ_API_KEY } ` ,
317318 } ,
318319 body : JSON . stringify ( {
319- contents : [ {
320- parts : [ {
321- text : prompt
322- } ]
320+ model : 'llama-3.3-70b-versatile' ,
321+ messages : [ {
322+ role : 'user' ,
323+ content : prompt
323324 } ] ,
324- generationConfig : {
325- temperature : 0.7 ,
326- topK : 40 ,
327- topP : 0.95 ,
328- maxOutputTokens : 2048 ,
329- }
325+ temperature : 0.7 ,
326+ max_tokens : 2048 ,
330327 } )
331328 } ) ;
332329
@@ -336,11 +333,11 @@ Example format:
336333
337334 const data = await response . json ( ) ;
338335
339- if ( ! data . candidates || ! data . candidates [ 0 ] || ! data . candidates [ 0 ] . content ) {
340- throw new Error ( 'Invalid response format from Gemini API' ) ;
336+ if ( ! data . choices || ! data . choices [ 0 ] || ! data . choices [ 0 ] . message ) {
337+ throw new Error ( 'Invalid response format from Groq API' ) ;
341338 }
342339
343- const generatedText = data . candidates [ 0 ] . content . parts [ 0 ] . text ;
340+ const generatedText = data . choices [ 0 ] . message . content ;
344341
345342 let cleanedText = generatedText . replace ( / ` ` ` j s o n \n ? / g, '' ) . replace ( / ` ` ` \n ? / g, '' ) . trim ( ) ;
346343
@@ -438,7 +435,7 @@ Example format:
438435 < h3 className = "text-xl font-semibold text-gray-900" > Development Questions ({ formData . Dev } %)</ h3 >
439436 < div className = "flex space-x-3" >
440437 < button
441- onClick = { generateQuestionsWithGemini }
438+ onClick = { generateQuestionsWithGroq }
442439 disabled = { isGenerating }
443440 className = "px-6 py-3 bg-gradient-to-r from-green-500 to-emerald-500 text-white rounded-2xl font-semibold hover:from-green-600 hover:to-emerald-600 transition-all duration-300 disabled:opacity-50 flex items-center space-x-2 shadow-lg"
444441 >
0 commit comments