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.7.tar.gz (4.7 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.7-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gateagent-0.1.7.tar.gz
  • Upload date:
  • Size: 4.7 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.7.tar.gz
Algorithm Hash digest
SHA256 39797916faabd2f47834abae25b0eaca03b5d8bdf9763436c91e3d4e01ca1776
MD5 cdf99e9eb30a088d7498e51ddadfc696
BLAKE2b-256 8bbdfe20246949c0c417ae603be5219dd80d03dcba42df6e5e022c0cf46501f1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gateagent-0.1.7-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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a288e6b69b543b86422b97cb6332d0ce20e44a03376e00e68bcee5a5cf0f017f
MD5 e64a77f804680fe26458fdcd0ee7cc8c
BLAKE2b-256 6b37b6c0316a6f70c9a56dfc1de3b41f14e97c5650b649c5fec81c0da6dc8a8b

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