Spaces:
Runtime error
Runtime error
| from dotenv import load_dotenv | |
| load_dotenv() | |
| import os | |
| import google.generativeai as genai | |
| import gradio as gr | |
| GOOGLE_API_KEY=os.environ.get("google_api_key") | |
| genai.configure(api_key=(GOOGLE_API_KEY)) | |
| # Configure Google Generative AI | |
| #genai.configure(api_key=os.getenv(GOOGLE_API_KEY)) | |
| model = genai.GenerativeModel("gemini-pro") | |
| def get_gemini_responces(message, chat_history): | |
| # Assuming the message is a question for the Gemini model | |
| responce = model.generate_content(message) | |
| # Append the model's response to the chat history | |
| chat_history.append((message, responce.text)) | |
| return "", chat_history | |
| # Define the Gradio interface with a Chatbot component | |
| with gr.Blocks() as demo: | |
| chatbot = gr.Chatbot() | |
| msg = gr.Textbox() | |
| clear = gr.ClearButton([msg, chatbot]) | |
| msg.submit(get_gemini_responces, [msg, chatbot], [msg, chatbot]) | |
| # Launch the Gradio app | |
| if __name__ == "__main__": | |
| demo.launch() | |