Skip to main content

Python SDK for the AMPA API

Project description

AMPA SDK

The AMPA SDK is a Python library that provides a convenient, high-level interface for interacting with the AMPA API. It is designed to simplify prompt management, versioning, and execution from any Python application, script, or notebook.

Overview

  • Easy integration: Manage prompts and their versions with simple Python calls
  • Handles authentication: Securely connect to the AMPA API with username/password or environment variables
  • Request/response abstraction: No need to manually format HTTP requests
  • Extensible: Add custom methods or extend for new API endpoints

Features

  • Create, update, delete, and run prompts from Python
  • List and manage prompt versions
  • Automatic handling of API authentication and errors
  • Works with both local and remote AMPA API deployments
  • CRUD and search for the prompt_tests endpoints

Installation

To install the AMPA SDK, use pip:

pip install the37lab_ampa_sdk

Configuration

You can configure the SDK via parameters or environment variables:

Environment variables:

  • AMPA_API_URL
  • AMPA_API_USERNAME
  • AMPA_API_PASSWORD

Usage Example

from the37lab_ampa_sdk import PromptAPI

# Initialize the client (parameters or env vars)
client = PromptAPI(
    ampa_url="http://localhost:8000",
    username="your_username",
    password="your_password",
)

# Create an prompt
data = {
    "prompt_name": "My Prompt",
    "description": "A helpful assistant",
    "purpose": "You are a helpful assistant",
    "instruction": "Tell a story about Sweden"
}
prompt = client.create_prompt(data)

# Run the prompt
response = client.call_prompt(
    "My Prompt",
    variables={"name": "John"},
    prompt="Tell me a story"
)

# List prompt versions
versions = client.list_prompt_versions(prompt["id"])

Use Cases

  • Integrate prompt management into Python apps, scripts, or notebooks
  • Automate prompt creation and execution in pipelines
  • Rapid prototyping and experimentation with LLM prompts

Extensibility

  • Add new methods for custom API endpoints
  • Subclass PromptAPI to add custom logic or error handling

Troubleshooting

  • Ensure the AMPA API is running and accessible
  • Check credentials and API URL
  • Review exception messages for error details

License

This project is proprietary software. All rights reserved.

prompt_tests Table Usage

The SDK supports CRUD and search for the prompt_tests endpoints:

from the37lab_ampa_sdk import PromptAPI
client = PromptAPI(...)

# Create
data = {
    'name': 'Test',
    'description': 'desc',
    'data': {'foo': 'bar'},
    'prompt': 'Say hi',
    'prompt_ids': [1, 2]
}
r = client.create_prompt_test(**data)

# Get by id
r = client.get_prompt_test(r['id'])

# Update
r = client.update_prompt_test(r['id'], description='new desc')

# Delete
client.delete_prompt_test(r['id'])

# List all
rows = client.list_prompt_tests()

# List by prompt id
rows = client.list_prompt_tests_by_prompt_id(1)

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

the37lab_ampa_sdk-0.1.1750938947.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

the37lab_ampa_sdk-0.1.1750938947-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file the37lab_ampa_sdk-0.1.1750938947.tar.gz.

File metadata

File hashes

Hashes for the37lab_ampa_sdk-0.1.1750938947.tar.gz
Algorithm Hash digest
SHA256 c6c4d1a02e5058aa0919036f1925fe578f4f139900f725945580ba65ccacfb1c
MD5 2ad62d06ff35786251a38e920d67918d
BLAKE2b-256 19d30e2a059194e53f4ca3bdc915192a496afd1ecf98fc42e9939fdd15ac5a2e

See more details on using hashes here.

File details

Details for the file the37lab_ampa_sdk-0.1.1750938947-py3-none-any.whl.

File metadata

File hashes

Hashes for the37lab_ampa_sdk-0.1.1750938947-py3-none-any.whl
Algorithm Hash digest
SHA256 abf819004b23f8ee02fe7b74f9386907f669b9f9bfdfa5cc69413cde54f49a2b
MD5 2b22f4d0a25fe0bc7fae0a6b5d14caa2
BLAKE2b-256 2af43c07c9c37644d45ce3f8f830d3812b3bf135ab68acbdc3ccaf1110380223

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