Skip to main content

Get insights on your agent and app interations.

Project description

Gateagent Python SDK

Track and analyze your AI agent's tool interactions with deep insights.

Installation

pip install gateagent

Example: Math Agent

Here is a complete example of how to use gateagent with a LangChain agent:

from langchain_openai import ChatOpenAI
from langchain.tools import tool
from langchain_core.prompts import ChatPromptTemplate
from langsmith import traceable 
from gateagent import InteractionTracer

# 1. Initialize the Tracer
callbacks = [
    InteractionTracer(
        project_name="math-agent-playground",
        # tenant_id is derived from API Key on backend
        default_metadata={
            "agent": "math-agent-v1",
            "environment": "local",
        },
    )
]

# 2. Define Tools
@tool
def add_numbers(a: int, b: int) -> int:
    """Add two numbers."""
    return a + b

tools = [add_numbers]
tool_map = {t.name: t for t in tools}

llm = ChatOpenAI(model="gpt-4o-mini", temperature=0).bind_tools(tools)
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a math assistant."),
    ("human", "{input}"),
])
chain = prompt | llm

# 3. Use in execution (with @traceable or directly in config)
@traceable(run_type="chain", name="math-agent")
def run(input_text: str):
    response = chain.invoke(
        {"input": input_text},
        config={
            "callbacks": callbacks,
            "run_name": "math-agent-llm",
            "metadata": {"agent": "math-agent-v1"},
        },
    )
    
    if response.tool_calls:
        # Pass callbacks to tool execution logic
        tool_call = response.tool_calls[0]
        return tool_map[tool_call["name"]].invoke(
            tool_call["args"], 
            config={"callbacks": callbacks}
        )
    return response.content

Configuration

Set your API key via environment variable:

export GATEAGENT_API_KEY="your-api-key"

Or pass it to the Client explicitly if needed (advanced usage).

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

gateagent-0.1.9.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

gateagent-0.1.9-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file gateagent-0.1.9.tar.gz.

File metadata

  • Download URL: gateagent-0.1.9.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for gateagent-0.1.9.tar.gz
Algorithm Hash digest
SHA256 03a79a09c1acbcad1c40be694d55d3705547ae0107aa3032cfd19157ad0c0090
MD5 91d43d3ce2accad16365d37bb6db51d2
BLAKE2b-256 0ed88d37e694a55ccd1285d5ed019c8c84a7a56abb43ed4f497df4c34ebe29b7

See more details on using hashes here.

File details

Details for the file gateagent-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: gateagent-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for gateagent-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 4dd94b5ff8fb10d60274b90748527289fd10cf4052995a8bef3bb9baace3a7d6
MD5 6e074e6f5e0302bac06e64fc61ae6012
BLAKE2b-256 94b84ae1859de559ac26ba5d193e8c771c3c42478e8c8152d62eb4b7953afebc

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