Skip to main content

HatiData Agent SDK — RAM for Agents

Project description

HatiData Agent SDK

PyPI version Python versions License

RAM for Agents — Python SDK for AI agents to query HatiData's in-VPC data warehouse with sub-10ms latency via Postgres wire protocol.

Installation

pip install hatidata-agent

# With async support
pip install hatidata-agent[async]

# With LangChain support
pip install hatidata-agent[langchain]

# With MCP server
pip install hatidata-agent[mcp]

# Everything
pip install hatidata-agent[all]

Quick Start

from hatidata_agent import HatiDataAgent

agent = HatiDataAgent(
    host="proxy.internal",
    port=5439,
    agent_id="my-agent",
    framework="langchain",
)

# Simple query
rows = agent.query("SELECT * FROM customers WHERE status = 'active' LIMIT 10")
print(rows)  # [{"id": 1, "name": "Acme Corp", ...}, ...]

Features

  • Sub-10ms query latency -- In-VPC execution, no data leaves your network
  • Postgres wire protocol -- Works with any Postgres client library
  • Reasoning chain tracking -- Multi-step audit trails for agent workflows
  • RAG context retrieval -- Full-text and vector similarity search
  • LangChain integration -- Drop-in SQLDatabase replacement for LangChain agents
  • MCP server -- Expose HatiData as tools for Claude and other MCP-compatible agents
  • Agent identification -- Per-agent billing, priority scheduling, and audit via Postgres startup parameters
  • Snowflake SQL compatible -- Bring existing queries without rewrites

Hybrid SQL

Combine structured queries with semantic search. Standard SQL runs locally with zero cloud dependency. Hybrid SQL (JOIN_VECTOR, semantic_match, etc.) is transparently transpiled via the HatiData cloud API.

from hatidata_agent import HatiDataAgent

agent = HatiDataAgent(
    host="localhost", port=5439,
    cloud_key="hd_live_..."  # free at hatidata.com/signup
)

# Semantic search
rows = agent.query("""
    SELECT ticket_id, subject
    FROM support_tickets
    WHERE semantic_match(embedding, 'billing dispute refund')
    ORDER BY semantic_rank(embedding, 'billing dispute refund') DESC
    LIMIT 10
""")

# Hybrid join
rows = agent.query("""
    SELECT t.ticket_id, k.article_title, k.solution
    FROM support_tickets t
    JOIN_VECTOR knowledge_base k ON semantic_match(k.embedding, t.subject)
    WHERE t.status = 'open'
""")

Get a free cloud key (50 queries/day) at hatidata.com/signup. You can also set the HATIDATA_CLOUD_KEY env var or run hati login.

Reasoning Chain Tracking

Track multi-step reasoning chains for audit and debugging:

with agent.reasoning_chain("req-001") as chain:
    # Step 0: Discover tables
    tables = chain.query("SELECT table_name FROM information_schema.tables")

    # Step 1: Get relevant data
    customers = chain.query("SELECT * FROM customers WHERE tier = 'enterprise'", step=1)

    # Step 2: Aggregate
    revenue = chain.query("SELECT SUM(revenue) FROM orders WHERE customer_id IN (...)", step=2)

RAG Context Retrieval

# Full-text search
context = agent.get_context("customers", "enterprise accounts in US", top_k=5)

# Vector similarity search
context = agent.get_rag_context("docs", "embedding", query_vector, top_k=10)

LangChain Integration

from hatidata_agent.langchain import HatiDataSQLDatabase
from langchain.agents import create_sql_agent

db = HatiDataSQLDatabase(
    host="proxy.internal",
    port=5439,
    agent_id="sql-agent-1",
)

agent = create_sql_agent(llm=llm, db=db, verbose=True)
result = agent.run("How many enterprise customers do we have?")

MCP Server

Run as an MCP server for Claude and other MCP-compatible agents:

# Start the MCP server
hatidata-mcp-server --host proxy.internal --port 5439

# Or add to Claude Code's MCP config:
# ~/.claude/mcp.json
{
  "mcpServers": {
    "hatidata": {
      "command": "hatidata-mcp-server",
      "args": ["--host", "proxy.internal", "--port", "5439"]
    }
  }
}

MCP Tools

Tool Description
query Execute SQL and return JSON results
list_tables List available tables
describe_table Get table schema
get_context RAG context retrieval via full-text search

Agent Identification

The SDK automatically identifies agents via Postgres startup parameters:

Parameter Purpose
hatidata_agent_id Unique agent identifier
hatidata_framework AI framework (langchain, crewai, autogen, etc.)
hatidata_priority Scheduling priority (low, normal, high, critical)
hatidata_request_id Request/reasoning chain ID
hatidata_reasoning_step Step number within a chain

These enable per-agent billing, priority scheduling, audit trails, and the Agent Tax Report showing savings vs legacy cloud warehouses.

Documentation

Full documentation is available at docs.hatidata.com.

License

Apache License 2.0. Copyright (c) Marviy Pte Ltd. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hatidata_agent-0.3.0.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hatidata_agent-0.3.0-py3-none-any.whl (32.5 kB view details)

Uploaded Python 3

File details

Details for the file hatidata_agent-0.3.0.tar.gz.

File metadata

  • Download URL: hatidata_agent-0.3.0.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for hatidata_agent-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0f022abf1649e464616206fb3203cb517caddf5ddb5ed4fea6bb4dbc34fe2f16
MD5 9c0d2455fac66a665edf7859d33d94aa
BLAKE2b-256 62b3a6474625a09d64421fc3a1e08db24a0a00d03ba79350011effd89771b45f

See more details on using hashes here.

File details

Details for the file hatidata_agent-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: hatidata_agent-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 32.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for hatidata_agent-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d1025ff85882c3ea07030e487249031e5cd3d7ae1820134254209f7cdcec2d53
MD5 58246d5533d1cb82838f04ec2eec1c13
BLAKE2b-256 61d10d64158a182ff8e0a246072239c1396ffc5f11531a069e57fb7b0c043ccb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page