GPT5_Demo / app.py
Abs6187's picture
Update app.py
f1a0058 verified
raw
history blame
909 Bytes
import os
import gradio as gr
import google.generativeai as genai
# --- Gemini -------------------------------------------------------
genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
model = genai.GenerativeModel("gemini-2.0-flash")
chat = model.start_chat() # keeps its own history
def respond(message, history):
return chat.send_message(message).text # the reply only
# --- Gradio -------------------------------------------------------
iface = gr.ChatInterface(
fn = respond,
title = "Gemini Chatbot",
description = "Ask anything – powered by Google Gemini",
chatbot = gr.Chatbot(height=600, type="messages"), # <- new type
textbox = gr.Textbox(placeholder="Type a message…"),
retry_btn = "🔄 Retry", # works on Gradio >= 4.19
clear_btn = "🗑️ Clear",
)
if __name__ == "__main__":
iface.launch()