File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,15 +61,27 @@ export const useAI = () => {
6161 return data . content [ 0 ] ?. text || 'No response received' ;
6262 } ;
6363
64- const callGemini = async ( prompt : string , apiKey : string ) : Promise < string > => {
65- const response = await fetch ( `https://generativelanguage.googleapis.com/v1/models/gemini-pro:generateContent?key=${ apiKey } ` , {
64+ const callGemini = async ( prompt : string , apiKey : string ) : Promise < string > => {
65+ const response = await fetch (
66+ `https://generativelanguage.googleapis.com/v1/models/gemini-pro:generateContent?key=${ apiKey } ` ,
67+ {
6668 method : 'POST' ,
6769 headers : { 'Content-Type' : 'application/json' } ,
6870 body : JSON . stringify ( {
69- contents : [ { parts : [ { text : prompt } ] } ] ,
70- generationConfig : { maxOutputTokens : 500 , temperature : 0.7 } ,
71+ contents : [
72+ {
73+ parts : [ { text : prompt } ] ,
74+ } ,
75+ ] ,
76+ generationConfig : {
77+ maxOutputTokens : 500 ,
78+ temperature : 0.7 ,
79+ } ,
7180 } ) ,
72- } ) ;
81+ }
82+ ) ;
83+
84+ const data = await response . json ( ) ;
7385
7486 if ( ! response . ok ) {
7587 const errorData = await response . json ( ) . catch ( ( ) => ( { } ) ) ;
You can’t perform that action at this time.
0 commit comments