from abc import ABC from deepsearcher.vector_db import RetrievalResult def describe_class(description): """ Decorator function to add a description to a class. This decorator adds a __description__ attribute to the decorated class, which can be used for documentation or introspection. Args: description: The description to add to the class. Returns: A decorator function that adds the description to the class. """ def decorator(cls): cls.__description__ = description return cls return decorator class BaseAgent(ABC): """ Abstract base class for all agents in the DeepSearcher system. This class defines the basic interface for agents, including initialization and invocation methods. """ def __init__(self, **kwargs): """ Initialize a BaseAgent object. Args: **kwargs: Arbitrary keyword arguments. """ pass def invoke(self, query: str, **kwargs) -> any: """ Invoke the agent and return the result. Args: query: The query string. **kwargs: Additional keyword arguments. Returns: The result of invoking the agent. """ def retrieve(self, query: str, **kwargs) -> tuple[list[RetrievalResult], dict]: """ Retrieve document results from the knowledge base. Args: query: The query string. **kwargs: Additional keyword arguments. Returns: A tuple containing: - the retrieved results - any additional metadata, which can be an empty dictionary """ def query(self, query: str, **kwargs) -> tuple[str, list[RetrievalResult]]: """ Query the agent and return the answer. Args: query: The query string. **kwargs: Additional keyword arguments. Returns: A tuple containing: - the result generated from LLM - the retrieved document results """