Spaces:
Build error
Build error
Update app.py
Browse files37 unmodified lines38394041414243444526 unmodified lines72737474757676777879805 unmodified lines86878888899091923 unmodified lines969798989910010110210310310410510610713 unmodified lines12112212312312412512612712812913013013113213313436 unmodified lines17117217317417517617717817918018137 unmodified lines global chat_history try: if not user_message.strip(): return [("system", "Please enter a question.")] chat_history.append(("AI: ", "Please enter a question."))
# Add user message to chat history 26 unmodified lines img.save(buffered, format="PNG") img_str = base64.b64encode(buffered.getvalue()).decode("utf-8")
img = f'<img src="data:image/png;base64,{img_str}" style="width:450px; height:400px;">' img = f'<img src="data:image/png;base64,{img_str}" style="width:600px; height:500px;">'
ai_response = img + ai_response ai_response = img + ai_response user_message = visual_query.strip() 5 unmodified lines return chat_history
except Exception as e: chat_history.append((visual_query, f"Sorry, I couldn't process your request. Please try after some time.")) chat_history.append((visual_query, f"As you know I am still learning at this moment I am not able to respond to your question.\nThank you for your patience!")) return chat_history # Chat handling functiondef chat_interaction(user_message):3 unmodified lines
with gr.Blocks(theme="soft") as app: # Use the 'soft' theme gr.Markdown( "<h1 style='color:blue;'>Agentic AI - Chat with Documents & Database</h1>", "<h1 style='color:blue;'>Material Forecast - Generative AI Agent</h1>", elem_id="title" )
with gr.Tab("Chat"): chat_box = gr.Chatbot(label="Chat History") chat_box = gr.Chatbot(label="Chat History",elem_id="chatbot_gpt") with gr.Row(): # Place elements in the same row with gr.Column(scale=2): user_input = gr.Textbox(13 unmodified lines outputs=[chat_box, user_input] )
with gr.Tab("File Upload"): """with gr.Tab("File Upload"): upload_button = gr.UploadButton( label="Upload your file (PDF, Excel, Docx, Txt, CSV)", file_types=[".pdf", ".xlsx", ".docx", ".txt", ".csv"], file_count="single" ) file_output = gr.Textbox(label="File Processing Output") upload_button.upload(fn=handle_file_uploads, inputs=upload_button, outputs=[file_output]) upload_button.upload(fn=handle_file_uploads, inputs=upload_button, outputs=[file_output])"""
# Clear input field function def clear_input():36 unmodified lines#title { margin-bottom: 10px; /* Space below the title */ text-align: center;
#chatbot_gpt { height: 600px !important; /* Adjust height as needed */}
}"""
app.py+14-8