)
        if results is None or len(results) == 0:
            return ["No good DuckDuckGo Search Result was found"]
        snippets = [result["body"] for result in results]
        return snippets
[docs]    def run(self, query: str) -> str:
        snippets = self.get_snippets(query)
        return " ".join(snippets)
[docs]    def results(self, query: str, num_results: int) -> List[Dict[str, str]]:
        """Run query through DuckDuckGo and return metadata.
        Args:
            query: The query to search for.
            num_results: The number of results to return.
        Returns:
            A list of dictionaries with the following keys:
                snippet - The description of the result.
                title - The title of the result.
                link - The link to the result.
        """
        from duckduckgo_search import ddg
        results = ddg(
            query,
            region=self.region,
            safesearch=self.safesearch,
            time=self.time,
            max_results=num_results,
        )
        if results is None or len(results) == 0:
            return [{"Result": "No good DuckDuckGo Search Result was found"}]
        def to_metadata(result: Dict) -> Dict[str, str]:
            return {
                "snippet": result["body"],
                "title": result["title"],
                "link": result["href"],
            }
        return [to_metadata(result) for result in results]
By Harrison Chase
    
      © Copyright 2023, Harrison Chase.
      
  Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/_modules/langchain/utilities/duckduckgo_search.html