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.6.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.6-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gateagent-0.1.6.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.6.tar.gz
Algorithm Hash digest
SHA256 5268615d6fc84b11778296278871098a0907eaa59fca7dd8d10889e2b69dbe0e
MD5 56edd0ad8895c6e49b30d1b84495bca1
BLAKE2b-256 180852809c0369d5de43a76607b4d26c394458dfb7df1cf48ac35b6669e64fbf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gateagent-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 5.3 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2ff69e84b743f1818a85ceb678930d3d19340a32c54df11e5876029acbcb415d
MD5 454be6e561a3fd37b75251aac353d342
BLAKE2b-256 18ed743276ca8a029e59f636a7343c37f15c67176b215ecef1beab03a958f3bb

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