Skip to main content

pypeprompts

PyPI version Python Versions Downloads

A Python SDK for tracking and sending analytics data to Pype App.

Important Notice

This package is designed to send data to Pype App, a SaaS application. By using this package, you agree to the terms of service of Pype App. Please ensure you have the necessary rights and permissions to send this data.

Installation

For Production Use (PyPI Package)

You can install pypeprompts using pip:

pip install --upgrade pypeprompts

Or if you prefer using Poetry:

poetry add pypeprompts

For Development Use

If you're developing or contributing to pypeprompts, clone the repository and install it in editable mode:

git clone https://github.com/yourusername/pypeprompts.git
cd pypeprompts
poetry install

This will install the package in editable mode, allowing you to make changes to the code and immediately see the effects without reinstalling.

Requirements

  • Python 3.8.1 or higher

Obtaining Your Project Token

To use pypeprompts, you'll need a project token. This token is used to authenticate your requests and associate the analytics data with your account. You can obtain your project token by following these steps:

  1. Visit pypeai.com and log in to your account.
  2. Create a project.
  3. Click on Publish to generate the token.

If you encounter any issues or need assistance obtaining your project token, please contact dhruv@pypeai.com

Usage

Here's a quick example of how to use pypeprompts:

from pypeprompts import PromptAnalyticsTracker

# Initialize the tracker with your project token from pypeai.com
tracker = PromptAnalyticsTracker(project_token="your_project_token")

# Track an event and get the promptId
prompt_id = tracker.track("workflow_name", {
    "prompt": "Your input prompt",
    "output": "Generated output",
    "processingTime": 1.5,
    "tags": ["tag1", "tag2"],
    "attributes": {"key": "value"}
})
print(f"Prompt ID: {prompt_id}")

# Async tracking
import asyncio

async def async_track():
    prompt_id = await tracker.track_async("async_workflow", {
        "prompt": "Async input prompt",
        "output": "Async generated output",
        "processingTime": 0.8,
        "tags": ["async", "example"],
        "attributes": {"async_key": "async_value"}
    })
    print(f"Async Prompt ID: {prompt_id}")

asyncio.run(async_track())

Access Prompt Versions

You can use the accessPromptVersions method to retrieve prompt versions.

Get the Latest Prompt Version

prompt_text = tracker.accessPromptVersions()
print(prompt_text)

Get Specific Prompt Version

prompt_text = tracker.accessPromptVersions(version=2)
print(prompt_text)

Development Server Usage

When using pypeprompts in a development environment:

  1. Set up environment variables:

    export PYPE_PROJECT_TOKEN=your_development_token
    export PYPE_ENV=development
    
  2. In your development code:

    import os
    from pypeprompts import PromptAnalyticsTracker
    
    tracker = PromptAnalyticsTracker(
        project_token=os.getenv('PYPE_PROJECT_TOKEN'),
        enabled=os.getenv('PYPE_ENV') == 'development'
    )
    
    # Use tracker as normal...
    

This setup allows you to easily switch between development and production environments by changing the PYPE_ENV variable.

Features

  • Simple API for tracking and sending analytics data to Pype App
  • Synchronous and asynchronous tracking methods
  • Returns a unique promptId for each tracked event
  • Customizable logging
  • Error handling and reporting
  • Development mode for testing without affecting production data

Configuration

You can configure the PromptAnalyticsTracker with the following parameters:

  • project_token (required): Your project token for authentication (obtained from pypeai.com)
  • enabled (optional): Set to False to disable tracking (default: True)

Error Handling

The package uses a custom PromptAnalyticsError for error handling. Make sure to catch this exception in your code for proper error management.

Logging

pypeprompts uses Python's built-in logging module. Logs are written to both a file (prompt_analytics.log) and the console. You can adjust the log level as needed.

Data Privacy and Security

This package sends data to Pype App. Please ensure you comply with all applicable data protection laws and regulations when using this package. Do not send sensitive or personal information unless you have the necessary permissions and security measures in place.

Contributing

We welcome contributions! Please see our Contributing Guide for more details on how to get started.

License

This project is proprietary software. All rights reserved. You are granted a limited license to use this software in conjunction with Pype App services, subject to the terms of service of Pype App.

Support

If you encounter any problems or have any questions, please open an issue on the GitHub repository or contact the author at dhruv@pypeai.com.

Metadata

Release files for pypeprompts 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pypeprompts 0.0.8
File Size Uploaded Provenance Actions
pypeprompts-0.0.8.tar.gz 6.2 kB Without provenance Details for pypeprompts-0.0.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pypeprompts 0.0.8
File Interpreter ABI Platform Actions
pypeprompts-0.0.8-py3-none-any.whl Python 3 none any Details for pypeprompts-0.0.8-py3-none-any.whl

Total release size: 13.3 kB

Release files / pypeprompts-0.0.8.tar.gz

Download URL pypeprompts-0.0.8.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
eee7c38847983d89e771d336fbf8fec1987732dc93ef448c16cd55d890e19647
BLAKE2b-256 checksum
How to use checksums
775334393091640cb676ab9f865d5cec435e8b744c612eb680f065b8af7d4d2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.13.1 Darwin/24.2.0

Release files / pypeprompts-0.0.8-py3-none-any.whl

Download URL pypeprompts-0.0.8-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1fc70f1847d57f37d7d3aa523f8d08c0b44431363e40d4da97de9622c9529370
BLAKE2b-256 checksum
How to use checksums
b21343929e179aa65c31a588e39baa9237697d2b537ca2da8d98354640565510
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.13.1 Darwin/24.2.0

Security for pypeprompts 0.0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page