Spaces:
Sleeping
Sleeping
| import chainlit as cl | |
| import os | |
| import google.generativeai as genai | |
| # Configure Gemini | |
| GOOGLE_API_KEY = os.environ.get("GEMINI_API_KEY") | |
| if not GOOGLE_API_KEY: | |
| raise ValueError("GEMINI_API_KEY not found") | |
| genai.configure(api_key=GOOGLE_API_KEY) | |
| # Initialize the Gemini Flash model | |
| model = genai.GenerativeModel('gemini-2.0-flash') | |
| async def start_chat(): | |
| await cl.Message( | |
| content="Hello! I'm a chatbot powered by Gemini Flash. How can I help you today?" | |
| ).send() | |
| async def main(message: cl.Message): | |
| # Generate response using Gemini | |
| response = model.generate_content(message.content) | |
| # Send response | |
| await cl.Message( | |
| content=response.text | |
| ).send() |