Samuel Thomas commited on
Commit
f9d82ca
·
1 Parent(s): 26abdc4

ddgs another adjustment

Browse files
Files changed (1) hide show
  1. tools.py +17 -1
tools.py CHANGED
@@ -86,6 +86,7 @@ nltk.download('words', quiet=True)
86
  english_words = set(words.words())
87
 
88
  logger = logging.getLogger(__name__)
 
89
 
90
  # --- Model Configuration ---
91
  def create_llm_pipeline():
@@ -895,7 +896,22 @@ Snippet: {snippet}
895
  """
896
  return formatted
897
 
898
- def run(self, query: str) -> str:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
899
 
900
  """Execute the enhanced search."""
901
  if not query or not query.strip():
 
86
  english_words = set(words.words())
87
 
88
  logger = logging.getLogger(__name__)
89
+ logging.basicConfig(filename='app.log', level=logging.INFO)
90
 
91
  # --- Model Configuration ---
92
  def create_llm_pipeline():
 
896
  """
897
  return formatted
898
 
899
+ def run(self, tool_input: Union[str, Dict]) -> str:
900
+ query_str: Optional[str] = None
901
+
902
+ if isinstance(tool_input, dict):
903
+ # Try common keys where the actual query string might be stored
904
+ if "query" in tool_input and isinstance(tool_input["query"], str):
905
+ query_str = tool_input["query"]
906
+ elif "input" in tool_input and isinstance(tool_input["input"], str):
907
+ query_str = tool_input["input"]
908
+ # Add more checks if other dictionary structures are possible
909
+ else:
910
+ return "Invalid input: Dictionary received, but does not contain a recognizable string query under 'query' or 'input' keys."
911
+ elif isinstance(tool_input, str):
912
+ query_str = tool_input
913
+ else:
914
+ return f"Invalid input type: Expected a string or a dictionary, but got {type(tool_input).__name__}."
915
 
916
  """Execute the enhanced search."""
917
  if not query or not query.strip():