kpbotla commited on
Commit
792b439
·
verified ·
1 Parent(s): b8994a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -15
app.py CHANGED
@@ -7,40 +7,38 @@ from duckduckgo_search import DDGS
7
  from transformers import pipeline
8
 
9
  # --- Tool Definitions ---
10
- from tools.search_tool import WebSearchTool
11
- from tools.citation_tool import CiteTool
12
- from tools.summarizer_tool import SummarizerTool
13
- from tools.math_tool import PythonTool
14
- from tools.fallback_tool import FallbackTool
15
 
16
  class BasicAgent:
17
  def __init__(self):
18
- self.search = WebSearchTool()
19
- self.cite = CiteTool()
20
- self.summarizer = SummarizerTool()
21
- self.math = PythonTool()
22
- self.fallback = FallbackTool()
23
 
24
  def __call__(self, question: str) -> str:
25
  question_lower = question.lower()
26
 
27
  try:
28
  if any(keyword in question_lower for keyword in ["latest", "news", "who", "what", "where", "when"]):
29
- return self.search.use(question)
30
  elif any(keyword in question_lower for keyword in ["summarize", "summary", "explain"]):
31
- return self.summarizer.use(question)
32
  elif any(char.isdigit() for char in question) and any(op in question for op in ["+", "-", "*", "/"]):
33
- return self.math.use(question)
34
  elif "|||" in question:
35
- return self.cite.use(question)
36
  else:
37
- return self.fallback.use(question)
38
  except Exception as e:
39
  return f"Error during processing: {str(e)}"
40
 
41
 
42
 
43
 
 
 
44
  # --- Evaluation Logic ---
45
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
46
 
 
7
  from transformers import pipeline
8
 
9
  # --- Tool Definitions ---
10
+ from tools.search_tool import web_search
11
+ from tools.citation_tool import cite
12
+ from tools.summarizer_tool import summarize
13
+ from tools.math_tool import python
14
+ from tools.fallback_tool import fallback
15
 
16
  class BasicAgent:
17
  def __init__(self):
18
+ pass
 
 
 
 
19
 
20
  def __call__(self, question: str) -> str:
21
  question_lower = question.lower()
22
 
23
  try:
24
  if any(keyword in question_lower for keyword in ["latest", "news", "who", "what", "where", "when"]):
25
+ return web_search(question)
26
  elif any(keyword in question_lower for keyword in ["summarize", "summary", "explain"]):
27
+ return summarize(question)
28
  elif any(char.isdigit() for char in question) and any(op in question for op in ["+", "-", "*", "/"]):
29
+ return python(question)
30
  elif "|||" in question:
31
+ return cite(question)
32
  else:
33
+ return fallback(question)
34
  except Exception as e:
35
  return f"Error during processing: {str(e)}"
36
 
37
 
38
 
39
 
40
+
41
+
42
  # --- Evaluation Logic ---
43
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
44