|
|
|
import os |
|
import gradio as gr |
|
import google.generativeai as genai |
|
|
|
|
|
genai.configure(api_key=os.getenv("GEMINI_API_KEY")) |
|
|
|
|
|
model = genai.GenerativeModel("gemini-2.0-flash") |
|
chat = model.start_chat() |
|
|
|
|
|
def respond(message, history): |
|
reply = chat.send_message(message) |
|
return reply.text |
|
|
|
|
|
iface = gr.ChatInterface( |
|
fn=respond, |
|
title="Gemini Chatbot", |
|
chatbot=gr.Chatbot(height=600), |
|
textbox=gr.Textbox(placeholder="Ask anything…"), |
|
retry_btn="🔄 Retry", |
|
clear_btn="🗑️ Clear", |
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
iface.launch() |
|
|