mahadewa commited on
Commit
0dad5de
·
verified ·
1 Parent(s): 58232ea

Update base_agent.py

Browse files
Files changed (1) hide show
  1. base_agent.py +22 -0
base_agent.py CHANGED
@@ -27,6 +27,28 @@ class BaseAgent:
27
  def __call__(self, question: str, file_name: str = None, **kwargs) -> str:
28
  """Process the question and return an answer."""
29
  raise NotImplementedError("Subclasses must implement this method")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  def llm_call(self, system_prompt: str, user_prompt: str,
32
  temperature: float = 0.1, model: Optional[str] = None) -> str:
 
27
  def __call__(self, question: str, file_name: str = None, **kwargs) -> str:
28
  """Process the question and return an answer."""
29
  raise NotImplementedError("Subclasses must implement this method")
30
+
31
+ def extract_search_query(self, question: str) -> str:
32
+ """
33
+ Extract the key search terms from the question.
34
+
35
+ Args:
36
+ question: The original question
37
+
38
+ Returns:
39
+ A reformulated search query
40
+ """
41
+ system_prompt = """
42
+ You are an expert at extracting search terms from questions.
43
+ Given a question, identify the key terms that would be most effective for a web search.
44
+ Remove any unnecessary words and focus on specific names, dates, or key concepts.
45
+ Return only the search terms, with no additional text.
46
+ """
47
+
48
+ user_prompt = f"Extract the most effective search terms from this question: {question}"
49
+
50
+ response = self.llm_call(system_prompt, user_prompt)
51
+ return response.strip()
52
 
53
  def llm_call(self, system_prompt: str, user_prompt: str,
54
  temperature: float = 0.1, model: Optional[str] = None) -> str: