aymnsk commited on
Commit
acad99d
·
verified ·
1 Parent(s): de22488

Update agents/base_agent.py

Browse files
Files changed (1) hide show
  1. agents/base_agent.py +19 -4
agents/base_agent.py CHANGED
@@ -1,5 +1,7 @@
1
  from typing import Literal
2
  from dataclasses import dataclass
 
 
3
 
4
  @dataclass
5
  class ACPMessage:
@@ -30,7 +32,20 @@ class BaseAgent:
30
  )
31
 
32
  def is_greeting(self, text: str) -> bool:
33
- return text.lower().strip() in {
34
- "hi", "hello", "hey", "yo", "hii", "hiii", "sup", "👋", "🖐️", "🫱",
35
- "how are you", "how are you both", "hi! how are you both doing today?"
36
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from typing import Literal
2
  from dataclasses import dataclass
3
+ import json
4
+ import os
5
 
6
  @dataclass
7
  class ACPMessage:
 
32
  )
33
 
34
  def is_greeting(self, text: str) -> bool:
35
+ greetings = ["hi", "hello", "hey", "how are you", "good morning", "good evening"]
36
+ text_lower = text.lower()
37
+ return any(greet in text_lower for greet in greetings)
38
+
39
+ def load_json_prompts(self, filepath: str) -> list:
40
+ if not os.path.exists(filepath):
41
+ return []
42
+ try:
43
+ with open(filepath, "r", encoding="utf-8") as f:
44
+ data = json.load(f)
45
+ if isinstance(data, list):
46
+ return data
47
+ elif isinstance(data, dict) and "prompts" in data:
48
+ return data["prompts"]
49
+ except Exception as e:
50
+ print(f"[ERROR loading prompts from {filepath}]: {e}")
51
+ return []