Spaces:
Sleeping
Sleeping
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() |