Skip to content

Commit 315850d

Browse files
Update useAI.ts
1 parent acf6065 commit 315850d

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

src/hooks/useAI.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff 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(() => ({}));

0 commit comments

Comments
 (0)