Skip to main content

Python SDK for Pied Piper multimodal compression

Project description

Pied Piper Python SDK

Pied Piper is a lightweight Python SDK for the Pied Piper multimodal compression service.

Install

python -m pip install -e app/packaging

Configure

Set your API key:

export PIED_PIPER_API_KEY="your-shared-api-key"

The SDK defaults to the production Pied Piper service URL. PIED_PIPER_BASE_URL is only needed if you want to override that for local development or a non-production deployment.

Quickstart

import pied_piper

result = pied_piper.compress("Long inline text to compress")
print(result.status)
print(result.text)

Default fidelity behavior:

  • if you do not pass fidelity, the SDK uses 0.9
  • higher fidelity preserves more content
  • for text, fidelity maps to LLMLingua rate
  • fidelity=0.9 therefore means "keep roughly 90% of the original tokens", not "drop 90%"
  • for video, fidelity maps directly to the target kept-duration budget before padding and merge
  • the returned compression_rate is the observed output ratio compressed_tokens / origin_tokens, so it may differ from the requested fidelity

Mixed inputs

from pathlib import Path

from pied_piper import Client

client = Client()
result = client.compress(
    [
        "inline text",
        Path("paper.pdf"),
        Path("diagram.png"),
        Path("demo.mp4"),
    ],
    fidelity=0.55,
)

Current behavior:

  • text is extracted and compressed remotely
  • images are accepted as passthrough items
  • video inputs return an inline MP4 artifact on item.output_file
video_item = next(item for item in result.items if item.modality == "video")
video_bytes = video_item.output_file.as_bytes()

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

piedpiper_sdk-0.2.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

piedpiper_sdk-0.2.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file piedpiper_sdk-0.2.1.tar.gz.

File metadata

  • Download URL: piedpiper_sdk-0.2.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for piedpiper_sdk-0.2.1.tar.gz
Algorithm Hash digest
SHA256 feedc203b0c43f32c05c4741ced27a447d35e1db6305949663761f896271a3d8
MD5 b32c3660dee61526347acae35dec1a02
BLAKE2b-256 fbda77ddac2c9e4b8e962f1bf41827054ce3d6f7f0ac2730d3d256954cd07cb9

See more details on using hashes here.

File details

Details for the file piedpiper_sdk-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: piedpiper_sdk-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for piedpiper_sdk-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 30c1813bf835fd4ea1822be37250f1b0de556398bf83772e067da0f465de7b12
MD5 aa6f897a46056633bb8d4d4dfd69c1e7
BLAKE2b-256 a86dd5274822baed687bc62a7268b1b8d937fcb8b50db372032d51a33250f0f0

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