mirror of
				https://github.com/hwchase17/langchain.git
				synced 2025-10-30 07:16:16 +00:00 
			
		
		
		
	Tools for Bing, DDG and Google weren't consistent even though the underlying implementations were. All three services now have the same tools and implementations to easily switch and experiment when building chains.
		
			
				
	
	
		
			23 lines
		
	
	
		
			573 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			573 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| import pytest
 | |
| 
 | |
| from langchain.tools.ddg_search.tool import DuckDuckGoSearchRun
 | |
| 
 | |
| 
 | |
| def ddg_installed() -> bool:
 | |
|     try:
 | |
|         from duckduckgo_search import ddg  # noqa: F401
 | |
| 
 | |
|         return True
 | |
|     except Exception as e:
 | |
|         print(f"duckduckgo not installed, skipping test {e}")
 | |
|         return False
 | |
| 
 | |
| 
 | |
| @pytest.mark.skipif(not ddg_installed(), reason="requires duckduckgo-search package")
 | |
| def test_ddg_search_tool() -> None:
 | |
|     keywords = "Bella Ciao"
 | |
|     tool = DuckDuckGoSearchRun()
 | |
|     result = tool(keywords)
 | |
|     print(result)
 | |
|     assert len(result.split()) > 20
 |