MBG0903's picture
Update app.py
57b2968 verified
import gradio as gr
# Enhanced Hydraulic Q&A
def hydraulics_assistant(message, history):
message = message.lower()
if "pressure range" in message or "operating pressure" in message:
return (
"🧭 **Recommended Pressure Range:**\n"
"For standard hydraulic presses, the operating pressure is typically between 120 and 180 bar. "
"However, this can vary based on the type of machinery and application. Always consult your equipment manual "
"or manufacturer to ensure the pressure setting aligns with system requirements."
)
elif "oil" in message and "200 bar" in message:
return (
"πŸ›’οΈ **Oil Type for 200 Bar Press:**\n"
"Use ISO VG 46 or VG 68 grade hydraulic oil for 200 bar hydraulic systems. These oils provide a good balance of viscosity, "
"thermal stability, and wear protection. Selection depends on ambient operating temperatures:\n"
"- Use VG 46 in moderate climates\n"
"- Use VG 68 in hotter environments\n"
"βœ… Always verify compatibility with OEM recommendations or consult your equipment supplier."
)
elif "overheating" in message or "too hot" in message:
return (
"πŸ”₯ **Hydraulic System Overheating – Possible Causes & Fixes:**\n"
"- Dirty or clogged filters causing restricted flow\n"
"- Low fluid levels or poor-quality oil\n"
"- Undersized or failing heat exchanger\n"
"- Continuous high-duty cycle without rest\n\n"
"**Fix:**\n"
"Clean or replace filters, top-up fluid, inspect cooling system, and monitor temperature with a thermal gun. "
"If persistent, consider upgrading the cooling system."
)
elif "noise" in message or "whining" in message:
return (
"πŸ”Š **Why Your Pump is Making a Whining Noise:**\n"
"This could be caused by:\n"
"- Cavitation due to air bubbles in the fluid\n"
"- Low hydraulic fluid level\n"
"- Clogged suction line or filter\n"
"- Failing pump bearings\n\n"
"πŸ‘‰ Check fluid level, inspect for air leaks, and clean the filters. Prolonged noise may damage components, so act promptly."
)
elif "fluid change" in message or "oil change" in message:
return (
"πŸ”„ **Hydraulic Fluid Change Frequency:**\n"
"Hydraulic oil should typically be replaced every 2000 operating hours, but this can vary depending on:\n"
"- Operating environment (dusty, hot, etc.)\n"
"- Load cycles and pressure\n"
"- Fluid quality and contamination\n\n"
"πŸ“˜ Tip: Monitor oil condition using sampling kits and follow the OEM schedule."
)
elif "pressure drop" in message:
return (
"πŸ“‰ **Pressure Drop in Hydraulic Systems:**\n"
"Potential reasons include:\n"
"- Leaks in hoses, fittings, or seals\n"
"- Clogged return filters\n"
"- Faulty pressure relief valves\n"
"- Air in the hydraulic lines\n\n"
"πŸ” Start by inspecting visible components, then move to internal checks if needed."
)
elif "spare part" in message or "replacement" in message:
return (
"πŸ”§ **Spare Parts or Replacements:**\n"
"Please contact your authorized dealer or the maintenance support team with your equipment model number. "
"They can guide you to compatible parts or help verify the specifications for ordering replacements."
)
else:
return (
"πŸ€– Sorry, I don't have information on that specific query.\n"
"Please consult your maintenance engineer or refer to the equipment manual for detailed guidance."
)
# Launch the Gradio chatbot
demo = gr.ChatInterface(
hydraulics_assistant,
title="Hydraulic Maintenance Assistant Bot",
description="Ask your hydraulic maintenance questions β€” get instant answers to common issues!"
)
if __name__ == "__main__":
demo.launch()