Category: SearchTool

  • Wikipedia Tool

    from langchain_community.tools import WikipediaQueryRun
    from langchain_community.utilities import WikipediaAPIWrapper
    from langchain_core.pydantic_v1 import BaseModel, Field
    
    
    class WikiInputs(BaseModel):
        """Inputs to the wikipedia tool."""
    
        query: str = Field(
            description="query to look up in Wikipedia, should be 3 or less words"
        )
    
    
    api_wrapper = WikipediaAPIWrapper(api_key="Enter your key here")
    
    tool = WikipediaQueryRun(
        name="wiki-tool",
        description="look up things in wikipedia",
        args_schema=WikiInputs,
        api_wrapper=api_wrapper,
        return_direct=True,
    )
    
    print(tool.run("Who is Dwayne Johnson?"))
  • Exa Search Tool

    from exa_py import Exa
    from praisonai_tools import BaseTool
    
    class ExaSearchTool:
        name: str = "ExaSearchTool"
        description: str = "Perform a search using Exa and retrieve contents with specified options"
    
        def __init__(self, api_key: str):
            self.exa = Exa(api_key="Enter your key here")
    
        def _run(self, query: str):
            results = self.exa.search_and_contents(
                query,
                text={"include_html_tags": True, "max_characters": 1000},
            )
            return results
    # Example usage
    if __name__ == "__main__":
        api_key = "ExaSearchTool"
        tool = ExaSearchTool(api_key=api_key)
        search_query = "recent midjourney news"
        results = tool._run(search_query)
        print(results)