GeminiChatBot / app.py
hanspaa2017108's picture
Update app.py
86eea3d verified
raw
history blame contribute delete
669 Bytes
import gradio as gr
import google.generativeai as genai
import os
# Configure the Gemini API with your API key
api_key = os.getenv("GEMINI_API_KEY")
genai.configure(api_key=api_key)
# Define function to handle user inputs and interact with Gemini API
def chatbot(message, history):
# Call Gemini API to generate response based on user input
model = genai.GenerativeModel('gemini-1.0-pro-latest')
response = model.generate_content(message)
return response.text
# Create Gradio chat interface for the chatbot
chatbot_interface = gr.ChatInterface(
fn=chatbot,
title="Gemini Chatbot"
)
# Launch the chatbot interface
chatbot_interface.launch()