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
Release history Release notifications | RSS feed
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.8.tar.gz
(4.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gateagent-0.1.8.tar.gz.
File metadata
- Download URL: gateagent-0.1.8.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c329d32e6abd1a1f040cab2c3e70986dbb1f41d85177d79f36fb048a598a961
|
|
| MD5 |
5a62d23c365cf13dc6c7318a870524ce
|
|
| BLAKE2b-256 |
101faaec185ce650976afbfa8625a547a51ef6930e72a86a73b7fbd41e711217
|
File details
Details for the file gateagent-0.1.8-py3-none-any.whl.
File metadata
- Download URL: gateagent-0.1.8-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
535cf62a51a536a1b091dc240a8d8121af470c56a21b5bb9ee4bc86acddc31d4
|
|
| MD5 |
82db957c9cc5cc02aaaf41ee72ef4dfe
|
|
| BLAKE2b-256 |
0f6734c9072b663227684d0968b49505296d22faa1f146d3e451590a6116961a
|