Mephesto1 commited on
Commit
d580990
Β·
verified Β·
1 Parent(s): 01cc141

Upload 2 files

Browse files
Files changed (2) hide show
  1. agents/_init_.py +10 -1
  2. agents/chat_agent.py +16 -15
agents/_init_.py CHANGED
@@ -1 +1,10 @@
1
-
 
 
 
 
 
 
 
 
 
 
1
+ self.entries = [
2
+ {"date": "06/15/2025", "type": "Pod", "site": "left_stomach"},
3
+ {"date": "06/16/2025", "type": "Sensor", "site": "left_leg"},
4
+ {"date": "06/18/2025", "type": "Pod", "site": "left_arm"},
5
+ {"date": "06/21/2025", "type": "Pod", "site": "left_stomach"},
6
+ {"date": "06/24/2025", "type": "Pod", "site": "left_leg"},
7
+ {"date": "06/26/2025", "type": "Sensor", "site": "right_leg"},
8
+ {"date": "06/27/2025", "type": "Pod", "site": "right_leg"},
9
+ {"date": "06/30/2025", "type": "Pod", "site": "right_arm"}
10
+ ]
agents/chat_agent.py CHANGED
@@ -2,40 +2,41 @@
2
  # agents/chat_agent.py
3
 
4
  import gradio as gr
 
 
5
 
6
  class ChatAgent:
7
  def __init__(self):
8
  self.chat_history = []
 
9
 
10
  def respond_to_query(self, message: str) -> str:
11
  message = message.lower()
12
 
13
  if "next pod" in message:
14
- return "Your next pod site is right_leg."
 
 
15
  elif "sensor" in message:
16
- return "Your next sensor site is left_arm."
 
 
17
  elif "i used" in message:
18
  site = message.split("i used")[1].strip().replace(".", "")
19
- self.chat_history.append((message, f"Logged {site} as your most recent site."))
 
20
  return f"Thanks, I’ve logged {site} as your most recent pod site."
 
21
  elif "schedule" in message or "show me" in message:
22
  return self.get_schedule()
 
23
  else:
24
  return "Try asking about your next pod or sensor site."
25
 
26
  def get_schedule(self) -> str:
27
- # Replace with dynamic logic or dataset later
28
- schedule = [
29
- "08/24/2025 β€” Sensor (left_arm)",
30
- "08/24/2025 β€” Pod (left_arm)",
31
- "08/27/2025 β€” Pod (left_leg)",
32
- "08/30/2025 β€” Pod (left_stomach)",
33
- "09/02/2025 β€” Sensor (right_leg)",
34
- "09/02/2025 β€” Pod (right_arm)",
35
- "09/05/2025 β€” Pod (right_leg)",
36
- "09/08/2025 β€” Pod (right_stomach)",
37
- ]
38
- return "πŸ“… Upcoming Schedule:\n" + "\n".join(schedule)
39
 
40
  def handle_message(self, user_message):
41
  response = self.respond_to_query(user_message)
 
2
  # agents/chat_agent.py
3
 
4
  import gradio as gr
5
+ from datetime import datetime
6
+ from agents.history_agent import HistoryAgent
7
 
8
  class ChatAgent:
9
  def __init__(self):
10
  self.chat_history = []
11
+ self.history_agent = HistoryAgent()
12
 
13
  def respond_to_query(self, message: str) -> str:
14
  message = message.lower()
15
 
16
  if "next pod" in message:
17
+ latest = self.history_agent.get_latest("Pod")
18
+ return f"Your last pod site was {latest['site']}. Next site will be rotated accordingly." if latest else "No pod history found yet."
19
+
20
  elif "sensor" in message:
21
+ latest = self.history_agent.get_latest("Sensor")
22
+ return f"Your last sensor site was {latest['site']}. Next site will be rotated accordingly." if latest else "No sensor history found yet."
23
+
24
  elif "i used" in message:
25
  site = message.split("i used")[1].strip().replace(".", "")
26
+ today = datetime.today().strftime("%m/%d/%Y")
27
+ self.history_agent.log_entry(date=today, entry_type="Pod", site=site)
28
  return f"Thanks, I’ve logged {site} as your most recent pod site."
29
+
30
  elif "schedule" in message or "show me" in message:
31
  return self.get_schedule()
32
+
33
  else:
34
  return "Try asking about your next pod or sensor site."
35
 
36
  def get_schedule(self) -> str:
37
+ history = self.history_agent.get_history()
38
+ lines = [f"{entry['date']} β€” {entry['type']} ({entry['site']})" for entry in history]
39
+ return "πŸ“… Full Schedule:\n" + "\n".join(lines)
 
 
 
 
 
 
 
 
 
40
 
41
  def handle_message(self, user_message):
42
  response = self.respond_to_query(user_message)