Jayashree Sridhar commited on
Commit
d0f6de1
·
1 Parent(s): b28635c

calling run instead of call for basetool import

Browse files
agents/tools/knowledge_tools.py CHANGED
@@ -12,7 +12,7 @@ class SearchKnowledgeTool(BaseTool):
12
  def __init__(self, config=None):
13
  super().__init__()
14
  self.kb = KnowledgeBase(config)
15
- def __call__(self, query: str, k: int = 5):
16
  return self.kb.search(query, k=k) if self.kb.is_initialized() else \
17
  [{"text": "General wisdom", "score": 1.0}]
18
 
@@ -21,7 +21,7 @@ class ExtractWisdomTool(BaseTool):
21
  description: str = "Extract most relevant wisdom for a given query."
22
  def __init__(self, config=None):
23
  super().__init__()
24
- def __call__(self, search_results: list, user_context: dict):
25
  return search_results[:3]
26
 
27
  class SuggestPracticesTool(BaseTool):
@@ -29,7 +29,7 @@ class SuggestPracticesTool(BaseTool):
29
  description: str = "Recommend meditations or self-care practices."
30
  def __init__(self, config=None):
31
  super().__init__()
32
- def __call__(self, emotional_state: str, cultural_context: str = None):
33
  return {"name": "Mindful Breathing", "description": "Focus on your breath to calm the mind."}
34
 
35
  class KnowledgeTools:
 
12
  def __init__(self, config=None):
13
  super().__init__()
14
  self.kb = KnowledgeBase(config)
15
+ def _run(self, query: str, k: int = 5):
16
  return self.kb.search(query, k=k) if self.kb.is_initialized() else \
17
  [{"text": "General wisdom", "score": 1.0}]
18
 
 
21
  description: str = "Extract most relevant wisdom for a given query."
22
  def __init__(self, config=None):
23
  super().__init__()
24
+ def _run(self, search_results: list, user_context: dict):
25
  return search_results[:3]
26
 
27
  class SuggestPracticesTool(BaseTool):
 
29
  description: str = "Recommend meditations or self-care practices."
30
  def __init__(self, config=None):
31
  super().__init__()
32
+ def _run(self, emotional_state: str, cultural_context: str = None):
33
  return {"name": "Mindful Breathing", "description": "Focus on your breath to calm the mind."}
34
 
35
  class KnowledgeTools:
agents/tools/llm_tools.py CHANGED
@@ -12,7 +12,7 @@ class MistralChatTool(BaseTool):
12
  def __init__(self, config=None):
13
  super().__init__()
14
  self.model = TinyGPT2Model()
15
- def __call__(self, prompt: str, context: dict = None):
16
  msg = f"Context: {context}\nUser: {prompt}" if context else prompt
17
  return self.model.generate(msg)
18
 
@@ -23,7 +23,7 @@ class GenerateAdviceTool(BaseTool):
23
  def __init__(self, config=None):
24
  super().__init__()
25
  self.model = TinyGPT2Model()
26
- def __call__(self, user_analysis: dict, wisdom_quotes: list):
27
  prompt = f"Advice for: {user_analysis}, with wisdom: {wisdom_quotes}"
28
  return self.model.generate(prompt, max_length=300)
29
 
@@ -34,7 +34,7 @@ class SummarizeConversationTool(BaseTool):
34
  def __init__(self, config=None):
35
  super().__init__()
36
  self.model = TinyGPT2Model()
37
- def __call__(self, conversation: list):
38
  prompt = f"Summarize: {conversation}"
39
  return self.model.generate(prompt, max_length=200)
40
 
 
12
  def __init__(self, config=None):
13
  super().__init__()
14
  self.model = TinyGPT2Model()
15
+ def _run(self, prompt: str, context: dict = None):
16
  msg = f"Context: {context}\nUser: {prompt}" if context else prompt
17
  return self.model.generate(msg)
18
 
 
23
  def __init__(self, config=None):
24
  super().__init__()
25
  self.model = TinyGPT2Model()
26
+ def _run(self, user_analysis: dict, wisdom_quotes: list):
27
  prompt = f"Advice for: {user_analysis}, with wisdom: {wisdom_quotes}"
28
  return self.model.generate(prompt, max_length=300)
29
 
 
34
  def __init__(self, config=None):
35
  super().__init__()
36
  self.model = TinyGPT2Model()
37
+ def _run(self, conversation: list):
38
  prompt = f"Summarize: {conversation}"
39
  return self.model.generate(prompt, max_length=200)
40
 
agents/tools/validation_tools.py CHANGED
@@ -412,7 +412,7 @@ class ValidateResponseTool(BaseTool):
412
  super().__init__(**data)
413
  self.config = config
414
  # ... any required initialization ...
415
- def __call__(self, response: str, context: dict = None):
416
  # Place your actual validation logic here, include dummy for illustration
417
  # For full validation logic, use your own code!
418
  # """Result of validation check"""
 
412
  super().__init__(**data)
413
  self.config = config
414
  # ... any required initialization ...
415
+ def _run(self, response: str, context: dict = None):
416
  # Place your actual validation logic here, include dummy for illustration
417
  # For full validation logic, use your own code!
418
  # """Result of validation check"""
agents/tools/voice_tools.py CHANGED
@@ -56,7 +56,7 @@ class TranscribeAudioTool(BaseTool):
56
  def __init__(self, config=None):
57
  super().__init__()
58
  self.vp = MultilingualVoiceProcessor()
59
- def __call__(self, audio_data: np.ndarray, language=None):
60
  text, detected_lang = asyncio.run(self.vp.transcribe(audio_data, language))
61
  return {"text": text, "language": detected_lang}
62
 
@@ -65,7 +65,7 @@ class DetectEmotionTool(BaseTool):
65
  description: str = "Detect the emotional state from text."
66
  def __init__(self, config=None):
67
  super().__init__()
68
- def __call__(self, text: str):
69
  model = TinyGPT2Model()
70
  prompt = f'Analyse emotions in: "{text}". Format: JSON with primary_emotion, intensity, feelings, concerns.'
71
  response = model.generate(prompt)
@@ -79,7 +79,7 @@ class GenerateReflectiveQuestionsTool(BaseTool):
79
  description: str = "Generate reflective questions."
80
  def __init__(self, config=None):
81
  super().__init__()
82
- def __call__(self, context: dict):
83
  emotion = context.get("primary_emotion", "neutral")
84
  questions_map = {
85
  "anxiety": ["What triggers your anxiety?", "How do you cope?"],
 
56
  def __init__(self, config=None):
57
  super().__init__()
58
  self.vp = MultilingualVoiceProcessor()
59
+ def _run(self, audio_data: np.ndarray, language=None):
60
  text, detected_lang = asyncio.run(self.vp.transcribe(audio_data, language))
61
  return {"text": text, "language": detected_lang}
62
 
 
65
  description: str = "Detect the emotional state from text."
66
  def __init__(self, config=None):
67
  super().__init__()
68
+ def _run(self, text: str):
69
  model = TinyGPT2Model()
70
  prompt = f'Analyse emotions in: "{text}". Format: JSON with primary_emotion, intensity, feelings, concerns.'
71
  response = model.generate(prompt)
 
79
  description: str = "Generate reflective questions."
80
  def __init__(self, config=None):
81
  super().__init__()
82
+ def _run(self, context: dict):
83
  emotion = context.get("primary_emotion", "neutral")
84
  questions_map = {
85
  "anxiety": ["What triggers your anxiety?", "How do you cope?"],