Skip to main content

A Python SDK for Trinity Agent Monitoring API

Project description

Trinity Agent Monitoring SDK

A comprehensive Python SDK for monitoring AI agents with advanced tracing, metrics collection, and observability capabilities powered by Langfuse.

Features

  • Comprehensive Agent Monitoring: Track agent execution, tool usage, and performance metrics
  • Rich Metrics Collection: Monitor tokens, costs, latency, and tool utilization
  • Tool Usage Analytics: Detailed analysis of which tools your agents use and how often
  • Easy Integration: Simple decorator-based monitoring with minimal code changes

Installation

pip install trinity-agent-monitoring

Quick Start

1. Initialize the Monitor

from trinity_agent_monitoring import create_monitor, set_monitor

# Create and set up the global monitor
monitor = create_monitor(
    public_key="your_trinity_public_key",
    secret_key="your_trinity_secret_key"
)

# Set as global monitor for easy access
set_monitor(monitor)

2. Monitor Your Agent

from trinity_agent_monitoring import get_monitor

# Get the global monitor
monitor = get_monitor()

# Use the decorator to monitor your agent
@monitor.monitor_agent(agent_name="my_ai_agent")
def my_agent_function(agent_executor,user_input):
    # Your agent logic here
    response = process_user_input(user_input)
    return response

# Call your monitored function
result = my_agent_function(agent_executor, "Hello, agent!")

3. Instance-based Monitoring

from trinity_agent_monitoring import TrinityAgentMonitor

# Create a dedicated monitor instance
monitor = TrinityAgentMonitor(
    public_key="your_public_key",
    secret_key="your_secret_key"
)

# Use with your agent
@monitor.monitor_agent("custom_agent")
def custom_agent_function():
    # Agent logic
    pass

Get Callback Handler for LangChain

# Get the callback handler for LangChain integration
callback_handler = monitor.get_callback_handler()

# Use with your LangChain agent
from langchain.agents import AgentExecutor
from langchain.llms import OpenAI

agent = AgentExecutor.from_agent_and_tools(
    agent=your_agent,
    tools=your_tools,
    callbacks=[callback_handler]
)

API Reference

TrinityAgentMonitor

Main monitoring class that provides comprehensive agent monitoring capabilities.

Utility Functions

  • create_monitor(public_key, secret_key, host): Create a new monitor instance
  • get_monitor(): Get the global monitor instance
  • set_monitor(monitor): Set the global monitor instance

Metrics Collected

The SDK automatically collects the following metrics:

  • Token Usage: Input, output, and total tokens
  • Cost Analysis: Calculated costs for each operation
  • Latency: Start time, end time, and duration
  • Tool Usage: Which tools were used and how many times
  • Input/Output: Raw input and output data for analysis
  • Metadata: Custom metadata for additional context

Support

For support and questions, contact us at support@giggso.com

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

trinity_agent_monitoring-0.1.2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

trinity_agent_monitoring-0.1.2-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file trinity_agent_monitoring-0.1.2.tar.gz.

File metadata

  • Download URL: trinity_agent_monitoring-0.1.2.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for trinity_agent_monitoring-0.1.2.tar.gz
Algorithm Hash digest
SHA256 de0924e1c5bc5b189e52b159d8c51954e92ded5d6e332618d4cf48f24f43362e
MD5 c975df67c1bd4a46a4bc6d4640802a99
BLAKE2b-256 8a352bcf319ea052488f0261d6150f22093297de1966c1f686d36e3da951872e

See more details on using hashes here.

File details

Details for the file trinity_agent_monitoring-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for trinity_agent_monitoring-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3b306ef8644129659552b3806bcb46967a63c8dc1f787d55f0f984323078705d
MD5 52f964787ef493ce60fbe96b58c36d77
BLAKE2b-256 f5a491a8d6d07c09eda2eeb0307c22a3d62c3f8794b3cc2c451cf0d7d26272ba

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