or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/posthog@6.7.x
tile.json

tessl/pypi-posthog

tessl install tessl/pypi-posthog@6.7.0

Integrate PostHog into any python application.

Agent Success

Agent success rate when using this tile

89%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.03x

Baseline

Agent success rate without this tile

86%

task.mdevals/scenario-6/

Claude AI Chat with Analytics

Build a Python script that sends messages to Claude AI via AWS Bedrock and automatically tracks usage analytics.

Requirements

Create a Python application that:

  1. AI Interaction: Sends a user message to Claude AI through AWS Bedrock and receives a response
  2. Automatic Analytics Tracking: Automatically tracks AI interaction metrics including token usage and latency for each API call
  3. User Association: Links all analytics events to a specific user identifier
  4. Analytics Retrieval: Provides a way to query and display the tracked analytics

Constraints

  • Use Python 3.8+
  • Analytics must be tracked automatically for AI API calls without manual event creation
  • Must work with Claude 3.5 Sonnet model on AWS Bedrock

Test Cases

  • Given a message "What is the capital of France?" is sent to Claude via Bedrock, when the response is received, then an analytics event is automatically created with input_tokens > 0 and output_tokens > 0 @test
  • Given multiple messages are sent in sequence, when analytics are queried, then each interaction is tracked as a separate event @test

Implementation

@generates

API

def send_message(user_id: str, message: str, model: str = "anthropic.claude-3-5-sonnet-20241022-v2:0") -> str:
    """
    Sends a message to Claude AI via AWS Bedrock with automatic analytics tracking.

    Args:
        user_id: Unique identifier for the user making the request
        message: The message to send to Claude
        model: Bedrock model ID (default: Claude 3.5 Sonnet)

    Returns:
        The response text from Claude
    """
    pass

def get_analytics_summary(user_id: str) -> dict:
    """
    Retrieves analytics summary for a user's AI interactions.

    Args:
        user_id: Unique identifier for the user

    Returns:
        Dictionary containing analytics metrics (total_interactions,
        total_input_tokens, total_output_tokens, average_latency)
    """
    pass

Dependencies { .dependencies }

posthog-python { .dependency }

Provides analytics and observability tracking for AI interactions.

boto3 { .dependency }

AWS SDK for Python to interact with AWS Bedrock service.