1818
1919class QueryAnalyzerAgent (BaseAgent ):
2020 """Agent responsible for analyzing the user query."""
21- def run (self , query : str ) -> dict :
21+ def run (self , query : str , chat_history : list = None ) -> dict : # Add chat_history parameter
2222 start_time = time .time ()
23- logger .debug (f"Analyzing query: '{ query } '" )
23+ logger .debug (f"Analyzing query: '{ query } ' with history: { chat_history is not None } " ) # Log if history is present
2424 if not nlp :
2525 logger .warning ("spaCy model not loaded, falling back to basic analysis." )
2626 # Fallback basic extraction (similar to previous web.py logic)
@@ -29,7 +29,8 @@ def run(self, query: str) -> dict:
2929 keywords = list (set ([k .strip ().lower () for k in keywords if k ]))
3030 entities = list (set ([e .strip () for e in entities if len (e .split ()) > 1 or e in keywords ]))
3131 else :
32- # Use spaCy for extraction
32+ # TODO: Incorporate chat_history into spaCy analysis if needed
33+ # For now, just process the current query
3334 doc = nlp (query )
3435
3536 # Extract Named Entities (GPE, PERSON, ORG, LOC, EVENT, DATE etc.)
@@ -60,7 +61,9 @@ def run(self, query: str) -> dict:
6061 "original_query" : query , # Add the original query here
6162 "keywords" : keywords ,
6263 "entities" : entities ,
63- "query_type" : query_type
64+ "query_type" : query_type ,
65+ # Optionally include history info if used
66+ # "history_considered": chat_history is not None
6467 }
6568
6669 end_time = time .time ()
0 commit comments