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 = "Enter your key here"
    tool = ExaSearchTool(api_key=api_key)
    search_query = "recent midjourney news"
    results = tool._run(search_query)
    print(results)