Skip to content

Commit

Permalink
Added Gemini AI Integration Interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Shariq2003 committed Oct 26, 2024
1 parent 3a3bee1 commit 0415b37
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
"lint": "next lint"
},
"dependencies": {
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@google/generative-ai": "^0.21.0",
"@mui/icons-material": "^6.1.5",
"@mui/material": "^6.1.5",
"@radix-ui/react-aspect-ratio": "^1.1.0",
"@radix-ui/react-collapsible": "^1.1.1",
"@radix-ui/react-dialog": "^1.1.2",
Expand Down
17 changes: 17 additions & 0 deletions src/app/(pages)/api/generate/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { GoogleGenerativeAI } from '@google/generative-ai';

const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY);

export async function POST(req) {
const { prompt } = await req.json();
try {
const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
const result = await model.generateContent(prompt);
const response = await result.response;
const generatedText = await response.text();

return new Response(JSON.stringify({ generatedText }), { status: 200 });
} catch (error) {
return new Response(error.message, { status: 500 });
}
}

0 comments on commit 0415b37

Please sign in to comment.