Efficiency-Agent / src /agent /tools /check_downtines.py
mriusero
feat: get downtimes
3d63627
raw
history blame
772 Bytes
import json
from src.agent.utils.tooling import tool
@tool
def get_downtimes() -> str:
"""
This tool retrieves the production downtimes including :
- Timestamps of downtimes starts and endings,
- Event, Error Code and Error Description
"""
try:
with open("data/downtimes.json", "r") as f:
json_string = f.read()
data = json.loads(json_string)
if data is None or len(data) == 0:
result = "No downtimes recorded yet. Please check the production status or wait for downtimes to occur."
else:
result = "## Downtimes:\n\n"
result += json_string
return result
except Exception as e:
print(f"Error getting production status: {e}")
return None