rizalsaad commited on
Commit
d002eed
·
verified ·
1 Parent(s): 1ac9050

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import google.generativeai as genai
3
+ import os
4
+
5
+ # Replace with your actual Gemini API key
6
+ API_KEY = "AIzaSyBo8ZumjaR32q-wm-75lXxceQkhc5xZMmE"
7
+ genai.configure(api_key=API_KEY)
8
+
9
+ # Initialize the model
10
+ model = genai.GenerativeModel("gemini-2.0-flash")
11
+
12
+ # Function to handle chat
13
+ def chat_with_gemini(message, history):
14
+ try:
15
+ response = model.generate_content(message)
16
+ return response.text
17
+ except Exception as e:
18
+ return f"❌ Error: {str(e)}"
19
+
20
+ # Gradio interface
21
+ gr.ChatInterface(
22
+ fn=chat_with_gemini,
23
+ title="Gemini Chatbot",
24
+ description="Ask me anything!",
25
+ theme="soft"
26
+ ).launch(debug=True)