HyperSaaS
BackendAI Chat

Tools

Plain Python tools available to AI agents.

Tools in HyperSaaS are plain Python functions with no framework-specific decorators. Each agent handler wraps them for its own runtime.

Available Tools

ToolFileDescription
Web Searchchat/tools/web_search.pySearch the web using SerpAPI or DuckDuckGo
Weatherchat/tools/weather.pyGet current weather via WeatherAPI.com
Locationchat/tools/location.pySearch for places via Google Maps
Knowledge Basedocuments/rag_tool.pySearch attached knowledge bases (RAG)
URL Ingestdocuments/url_ingest_tool.pyIngest content from a URL

Tool Architecture

Tools are defined as plain functions in chat/tools/:

# chat/tools/weather.py
def get_weather(location: str) -> str:
    """Get current weather for a location."""
    # Pure Python — no @tool decorator, no framework imports
    response = requests.get(WEATHER_API_URL, params={"q": location, "key": API_KEY})
    return response.json()

Each handler wraps them differently:

LangGraph (in chat/handlers/langgraph/tools.py):

from langchain_core.tools import tool
from backend.chat.tools.weather import get_weather as get_weather_impl

@tool
def get_weather(location: str) -> str:
    """Get current weather for a location."""
    return get_weather_impl(location)

PydanticAI (in chat/handlers/pydantic_ai/agent.py):

@agent.tool_plain
def get_weather(location: str) -> str:
    """Get current weather for a location."""
    return get_weather_impl(location)

Knowledge Base Search Tool

The RAG tool is special — it needs access to the chat session to know which knowledge bases to search:

# documents/rag_tool.py
def search_knowledge_base_impl(query: str, session) -> str:
    """Pure function — no framework dependency."""
    results = search_documents(
        query=query,
        session_id=str(session.id),
        workspace_id=str(session.workspace_id),
    )
    return json.dumps(results)

The LangGraph wrapper uses InjectedToolArg to inject the session at runtime:

@tool
def search_knowledge_base(
    query: str,
    config: Annotated[RunnableConfig, InjectedToolArg],
) -> str:
    session = config["configurable"]["session"]
    return search_knowledge_base_impl(query, session)

Adding a New Tool

  1. Create chat/tools/your_tool.py with a plain Python function
  2. Add the LangChain wrapper in chat/handlers/langgraph/tools.py
  3. Add the PydanticAI wrapper in chat/handlers/pydantic_ai/agent.py
  4. Update the system prompt in chat/handlers/langgraph/nodes.py to describe the tool

Required API Keys

ToolEnvironment Variable
Web SearchSERPAPI_API_KEY
WeatherWEATHERAPI_COM_API_KEY
LocationGOOGLE_MAPS_API_KEY
Knowledge BaseOPENAI_API_KEY (for embeddings)

On this page