Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,47 +1,91 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
#
|
| 4 |
def hydraulics_assistant(message, history):
|
| 5 |
message = message.lower()
|
| 6 |
|
| 7 |
-
if "
|
| 8 |
-
return
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
| 12 |
|
| 13 |
elif "oil" in message and "200 bar" in message:
|
| 14 |
-
return
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
elif "
|
| 20 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
elif "
|
| 23 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
elif "
|
| 26 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
elif "
|
| 29 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
elif "
|
| 32 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
else:
|
| 35 |
-
return
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
#
|
| 38 |
demo = gr.ChatInterface(
|
| 39 |
hydraulics_assistant,
|
| 40 |
title="Hydraulic Maintenance Assistant Bot",
|
| 41 |
description="Ask your hydraulic maintenance questions β get instant answers to common issues!"
|
| 42 |
)
|
| 43 |
|
| 44 |
-
# Run the app
|
| 45 |
if __name__ == "__main__":
|
| 46 |
demo.launch()
|
| 47 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
# Enhanced Hydraulic Q&A
|
| 4 |
def hydraulics_assistant(message, history):
|
| 5 |
message = message.lower()
|
| 6 |
|
| 7 |
+
if "pressure range" in message or "operating pressure" in message:
|
| 8 |
+
return (
|
| 9 |
+
"π§ **Recommended Pressure Range:**\n"
|
| 10 |
+
"For standard hydraulic presses, the operating pressure is typically between 120 and 180 bar. "
|
| 11 |
+
"However, this can vary based on the type of machinery and application. Always consult your equipment manual "
|
| 12 |
+
"or manufacturer to ensure the pressure setting aligns with system requirements."
|
| 13 |
+
)
|
| 14 |
|
| 15 |
elif "oil" in message and "200 bar" in message:
|
| 16 |
+
return (
|
| 17 |
+
"π’οΈ **Oil Type for 200 Bar Press:**\n"
|
| 18 |
+
"Use ISO VG 46 or VG 68 grade hydraulic oil for 200 bar hydraulic systems. These oils provide a good balance of viscosity, "
|
| 19 |
+
"thermal stability, and wear protection. Selection depends on ambient operating temperatures:\n"
|
| 20 |
+
"- Use VG 46 in moderate climates\n"
|
| 21 |
+
"- Use VG 68 in hotter environments\n"
|
| 22 |
+
"β
Always verify compatibility with OEM recommendations or consult your equipment supplier."
|
| 23 |
+
)
|
| 24 |
|
| 25 |
+
elif "overheating" in message or "too hot" in message:
|
| 26 |
+
return (
|
| 27 |
+
"π₯ **Hydraulic System Overheating β Possible Causes & Fixes:**\n"
|
| 28 |
+
"- Dirty or clogged filters causing restricted flow\n"
|
| 29 |
+
"- Low fluid levels or poor-quality oil\n"
|
| 30 |
+
"- Undersized or failing heat exchanger\n"
|
| 31 |
+
"- Continuous high-duty cycle without rest\n\n"
|
| 32 |
+
"**Fix:**\n"
|
| 33 |
+
"Clean or replace filters, top-up fluid, inspect cooling system, and monitor temperature with a thermal gun. "
|
| 34 |
+
"If persistent, consider upgrading the cooling system."
|
| 35 |
+
)
|
| 36 |
|
| 37 |
+
elif "noise" in message or "whining" in message:
|
| 38 |
+
return (
|
| 39 |
+
"π **Why Your Pump is Making a Whining Noise:**\n"
|
| 40 |
+
"This could be caused by:\n"
|
| 41 |
+
"- Cavitation due to air bubbles in the fluid\n"
|
| 42 |
+
"- Low hydraulic fluid level\n"
|
| 43 |
+
"- Clogged suction line or filter\n"
|
| 44 |
+
"- Failing pump bearings\n\n"
|
| 45 |
+
"π Check fluid level, inspect for air leaks, and clean the filters. Prolonged noise may damage components, so act promptly."
|
| 46 |
+
)
|
| 47 |
|
| 48 |
+
elif "fluid change" in message or "oil change" in message:
|
| 49 |
+
return (
|
| 50 |
+
"π **Hydraulic Fluid Change Frequency:**\n"
|
| 51 |
+
"Hydraulic oil should typically be replaced every 2000 operating hours, but this can vary depending on:\n"
|
| 52 |
+
"- Operating environment (dusty, hot, etc.)\n"
|
| 53 |
+
"- Load cycles and pressure\n"
|
| 54 |
+
"- Fluid quality and contamination\n\n"
|
| 55 |
+
"π Tip: Monitor oil condition using sampling kits and follow the OEM schedule."
|
| 56 |
+
)
|
| 57 |
|
| 58 |
+
elif "pressure drop" in message:
|
| 59 |
+
return (
|
| 60 |
+
"π **Pressure Drop in Hydraulic Systems:**\n"
|
| 61 |
+
"Potential reasons include:\n"
|
| 62 |
+
"- Leaks in hoses, fittings, or seals\n"
|
| 63 |
+
"- Clogged return filters\n"
|
| 64 |
+
"- Faulty pressure relief valves\n"
|
| 65 |
+
"- Air in the hydraulic lines\n\n"
|
| 66 |
+
"π Start by inspecting visible components, then move to internal checks if needed."
|
| 67 |
+
)
|
| 68 |
|
| 69 |
+
elif "spare part" in message or "replacement" in message:
|
| 70 |
+
return (
|
| 71 |
+
"π§ **Spare Parts or Replacements:**\n"
|
| 72 |
+
"Please contact your authorized dealer or the maintenance support team with your equipment model number. "
|
| 73 |
+
"They can guide you to compatible parts or help verify the specifications for ordering replacements."
|
| 74 |
+
)
|
| 75 |
|
| 76 |
else:
|
| 77 |
+
return (
|
| 78 |
+
"π€ Sorry, I don't have information on that specific query.\n"
|
| 79 |
+
"Please consult your maintenance engineer or refer to the equipment manual for detailed guidance."
|
| 80 |
+
)
|
| 81 |
|
| 82 |
+
# Launch the Gradio chatbot
|
| 83 |
demo = gr.ChatInterface(
|
| 84 |
hydraulics_assistant,
|
| 85 |
title="Hydraulic Maintenance Assistant Bot",
|
| 86 |
description="Ask your hydraulic maintenance questions β get instant answers to common issues!"
|
| 87 |
)
|
| 88 |
|
|
|
|
| 89 |
if __name__ == "__main__":
|
| 90 |
demo.launch()
|
| 91 |
|