Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	Update tools.py
Browse filesRemoving the retriever.
    	
        tools.py
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            # tools.py
         | 
| 2 | 
             
            import os
         | 
| 3 | 
             
            from dotenv import load_dotenv
         | 
| 4 | 
             
            from langchain_community.tools.tavily_search import TavilySearchResults
         | 
| @@ -10,6 +10,8 @@ from datetime import datetime # Added for get_current_datetime tool | |
| 10 | 
             
            from langchain.tools import Tool
         | 
| 11 | 
             
            from langchain.utilities import PythonREPL
         | 
| 12 |  | 
|  | |
|  | |
| 13 | 
             
            # Load environment variables
         | 
| 14 | 
             
            load_dotenv()
         | 
| 15 |  | 
| @@ -60,7 +62,7 @@ def wiki_search(query: str) -> dict: | |
| 60 | 
             
                Search Wikipedia for a given query and return up to 2 relevant document results.
         | 
| 61 | 
             
                Useful for factual questions about people, places, events, etc.
         | 
| 62 | 
             
                Input should be a string representing the search query.
         | 
| 63 | 
            -
                Example: "Barack Obama"
         | 
| 64 | 
             
                """
         | 
| 65 | 
             
                try:
         | 
| 66 | 
             
                    if not query.strip():
         | 
| @@ -85,7 +87,7 @@ def web_search(query: str) -> dict: | |
| 85 | 
             
                Search the web using Tavily for a given query and return up to 3 relevant snippets.
         | 
| 86 | 
             
                Useful for up-to-date information, current events, or general web searches.
         | 
| 87 | 
             
                Input should be a string representing the search query. Requires TAVILY_API_KEY environment variable.
         | 
| 88 | 
            -
                Example: "latest news on AI"
         | 
| 89 | 
             
                """
         | 
| 90 | 
             
                try:
         | 
| 91 | 
             
                    if not query.strip():
         | 
| @@ -169,8 +171,8 @@ if __name__ == "__main__": | |
| 169 |  | 
| 170 | 
             
                # Test Search Tools
         | 
| 171 | 
             
                print("\n--- Search Tools Test ---")
         | 
| 172 | 
            -
                print(f"Wiki Search 'Artificial Intelligence': {wiki_search.invoke('Artificial Intelligence')['wiki_results'][:200]}...") # Limit output for brevity
         | 
| 173 | 
            -
                print(f"Web Search 'Hugging Face new features': {web_search.invoke('Hugging Face new features')['web_results'][:200]}...") # Limit output for brevity
         | 
| 174 |  | 
| 175 | 
             
                # Test Utility Tool
         | 
| 176 | 
             
                print("\n--- Utility Tools Test ---")
         | 
|  | |
| 1 | 
            +
            # tools.py (VERSION MODIFICADA SIN RETRIEVER)
         | 
| 2 | 
             
            import os
         | 
| 3 | 
             
            from dotenv import load_dotenv
         | 
| 4 | 
             
            from langchain_community.tools.tavily_search import TavilySearchResults
         | 
|  | |
| 10 | 
             
            from langchain.tools import Tool
         | 
| 11 | 
             
            from langchain.utilities import PythonREPL
         | 
| 12 |  | 
| 13 | 
            +
            # REMOVED: from retriever import get_retriever # This import is removed
         | 
| 14 | 
            +
             | 
| 15 | 
             
            # Load environment variables
         | 
| 16 | 
             
            load_dotenv()
         | 
| 17 |  | 
|  | |
| 62 | 
             
                Search Wikipedia for a given query and return up to 2 relevant document results.
         | 
| 63 | 
             
                Useful for factual questions about people, places, events, etc.
         | 
| 64 | 
             
                Input should be a string representing the search query.
         | 
| 65 | 
            +
                Example: {"query": "Barack Obama"}
         | 
| 66 | 
             
                """
         | 
| 67 | 
             
                try:
         | 
| 68 | 
             
                    if not query.strip():
         | 
|  | |
| 87 | 
             
                Search the web using Tavily for a given query and return up to 3 relevant snippets.
         | 
| 88 | 
             
                Useful for up-to-date information, current events, or general web searches.
         | 
| 89 | 
             
                Input should be a string representing the search query. Requires TAVILY_API_KEY environment variable.
         | 
| 90 | 
            +
                Example: {"query": "latest news on AI"}
         | 
| 91 | 
             
                """
         | 
| 92 | 
             
                try:
         | 
| 93 | 
             
                    if not query.strip():
         | 
|  | |
| 171 |  | 
| 172 | 
             
                # Test Search Tools
         | 
| 173 | 
             
                print("\n--- Search Tools Test ---")
         | 
| 174 | 
            +
                print(f"Wiki Search 'Artificial Intelligence': {wiki_search.invoke({'query': 'Artificial Intelligence'})['wiki_results'][:200]}...") # Limit output for brevity
         | 
| 175 | 
            +
                print(f"Web Search 'Hugging Face new features': {web_search.invoke({'query': 'Hugging Face new features'})['web_results'][:200]}...") # Limit output for brevity
         | 
| 176 |  | 
| 177 | 
             
                # Test Utility Tool
         | 
| 178 | 
             
                print("\n--- Utility Tools Test ---")
         | 
 
			
