Spaces:
Build error
Build error
Update app.py
Browse files12345678910import gradio as grdef chatbot_response(message):return f"You said: {message}"# Create a simple Gradio chat interfaceiface = gr.ChatInterface(fn=chatbot_response, title="Simple Chatbot")# Launch the appiface.launch()123456789101112131415161718192021222324252627282930313233343536import gradio as grimport google.generativeai as genaiimport osfrom process_docs import load_documents # Import our document processing script# Load API Key from Hugging Face SecretsGEMINI_API_KEY = os.getenv("GEMINI_API_KEY")# Configure Gemini APIgenai.configure(api_key=GEMINI_API_KEY)model = genai.GenerativeModel("gemini-pro")# Load document text into memorydocuments_text = load_documents()def chatbot_response(user_input, history=[]):"""Handles user queries and generates responses using Gemini API.It considers chat history and document context."""# Combine user input with document contextprompt = f"Use the following document data to answer:\n{documents_text}\n\nUser: {user_input}"# Call Gemini APIresponse = model.generate_content(prompt)# Extract response textanswer = response.text if hasattr(response, "text") else "Sorry, I couldn't generate a response."return answer # Send response back to Gradio UI# Create a Gradio chat interfaceiface = gr.ChatInterface(fn=chatbot_response, title="Document-Aware Chatbot")# Launch the chatbot appiface.launch()
app.py+31-5