Skip to main content

Provides a simple interface for interacting with the Wayfound Manager API.

Project description

Wayfound Python SDK

PyPI version Python 3.8+ MIT License

The official Python SDK for Wayfound AI - the observability and compliance platform designed specifically for conversational AI agents and agentic workflows.

🚀 Features

  • Simple Session Management - Track complete conversations between users and AI assistants and agentic workflows
  • Compliance Monitoring - Automatically detect guideline violations in AI responses
  • Async Support - Handle sessions synchronously or asynchronously
  • Flexible Message Format - Support for various message types and metadata
  • Easy Integration - Drop-in compatibility with existing Python applications

📦 Installation

Install the Wayfound SDK using pip:

pip install wayfound

🔧 Quick Start

1. Get Your API Credentials

First, you'll need to obtain your API credentials from the Wayfound dashboard:

  • WAYFOUND_API_KEY - Your authentication token
  • WAYFOUND_AGENT_ID - The ID of the agent you're tracking

2. Basic Usage

from wayfound import Session

# Initialize a session
session = Session(
    wayfound_api_key="your-api-key",
    agent_id="your-agent-id"
)

# Format your conversation messages
messages = [
    {
        "timestamp": "2025-01-15T10:00:00Z",
        "event_type": "assistant_message",
        "attributes": {
            "content": "Hello! How can I help you today?"
        }
    },
    {
        "timestamp": "2025-01-15T10:00:05Z",
        "event_type": "user_message",
        "attributes": {
            "content": "What's the weather like?"
        }
    },
    {
        "timestamp": "2025-01-15T10:00:10Z",
        "event_type": "assistant_message",
        "attributes": {
            "content": "I'd be happy to help with weather information. Could you please tell me your location?"
        }
    }
]

# Submit the session for analysis
result = session.create(messages=messages, is_async=False)

# Check for compliance violations
if 'compliance' in result:
    violations = [item for item in result['compliance'] if not item['result']['compliant']]
    if violations:
        print(f"Found {len(violations)} guideline violations")
        for violation in violations:
            print(f"- {violation['guideline']}: {violation['result']['reason']}")
    else:
        print("✅ No compliance violations detected!")

3. Environment Variables

For convenience, you can set environment variables instead of passing credentials directly:

export WAYFOUND_API_KEY="your-api-key"
export WAYFOUND_AGENT_ID="your-agent-id"

Then initialize without parameters:

from wayfound import Session

session = Session()  # Automatically uses environment variables

📚 API Reference

Session Class

Constructor Parameters

Parameter Type Description Required
wayfound_api_key str Your Wayfound API key Yes*
agent_id str The agent ID to track Yes*
session_id str Existing session ID (for appending) No
application_id str Application identifier No
visitor_id str Unique visitor identifier No
visitor_display_name str Human-readable visitor name No
account_id str Account identifier No
account_display_name str Human-readable account name No
metadata str or dict Optional metadata for the session No

*Required unless set as environment variables

Methods

create(messages=None, is_async=True)

Submits a complete conversation session for analysis.

Parameters:

  • messages (list): List of formatted message objects
  • is_async (bool): Whether to process asynchronously (default: True)

Returns: Dictionary with session results and compliance data

append_to_session(messages, is_async=True)

Adds additional messages to an existing session.

Parameters:

  • messages (list): List of formatted message objects to append
  • is_async (bool): Whether to process asynchronously (default: True)

Returns: Dictionary with updated session results

Message Format

Each message should follow this structure:

{
    "timestamp": "2025-01-15T10:00:00Z",  # ISO 8601 format
    "event_type": "assistant_message",     # or "user_message"
    "label": "greeting",                   # optional: message classification
    "description": "Initial greeting",     # optional: human-readable description
    "attributes": {
        "content": "Your message content here",
        # Additional custom attributes as needed
    }
}

🛠️ Advanced Usage

Working with Existing Sessions

# Start a new session
session = Session(wayfound_api_key="key", agent_id="agent")
result = session.create(initial_messages)

# Later, append more messages to the same session
additional_messages = [
    {
        "timestamp": "2025-01-15T10:05:00Z",
        "event_type": "user_message",
        "attributes": {"content": "Follow-up question"}
    }
]

session.append_to_session(additional_messages)

Custom Visitor and Account Tracking

session = Session(
    wayfound_api_key="your-key",
    agent_id="your-agent",
    visitor_id="visitor-123",
    visitor_display_name="John Doe",
    account_id="acct-456",
    account_display_name="Acme Corp"
)

🔍 Examples

Check out the examples/ directory for more detailed examples:

  • simple.py - Basic session tracking with compliance checking

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🆘 Support

🏷️ Version

Current version: 2.6.0

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

wayfound-2.6.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

wayfound-2.6.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file wayfound-2.6.0.tar.gz.

File metadata

  • Download URL: wayfound-2.6.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for wayfound-2.6.0.tar.gz
Algorithm Hash digest
SHA256 0be701f80be66d4dd95dc81e3d03af18e4ab887ec33bcfc3a6c935f87d4dc234
MD5 d24b797a3440dd726ac6117d54ab78e7
BLAKE2b-256 ef63ad41076b94b36fe91be09f92cd45bf63542ab0f00956d91e768283b9f9f2

See more details on using hashes here.

File details

Details for the file wayfound-2.6.0-py3-none-any.whl.

File metadata

  • Download URL: wayfound-2.6.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for wayfound-2.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7aa0f7183c2072e72ca0b844f7965b181496911c7e623480c06a9cfed11e39e1
MD5 ad1c3b0bef2aecc140764d81f5914ded
BLAKE2b-256 4bb3bf2d237ce59987a92dbd73b733582c0e3dbb7a777a31909777e298c39275

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