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_testsendpoints
Installation
To install the AMPA SDK, use pip:
pip install the37lab_ampa_sdk
Configuration
You can configure the SDK via parameters or environment variables:
ampa_url: The base URL of the AMPA API (default: https://ampa.the37lab.com:13002/)username: API usernamepassword: API password
Environment variables:
AMPA_API_URLAMPA_API_USERNAMEAMPA_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
PromptAPIto 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file the37lab_ampa_sdk-0.1.1756971985.tar.gz.
File metadata
- Download URL: the37lab_ampa_sdk-0.1.1756971985.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81a8a40e2815e3e69771a357368aabd2368524df9e117611ad9d3facf2f4b60d
|
|
| MD5 |
89c3e6fd28a4d08ffa4fcdabd5d5478c
|
|
| BLAKE2b-256 |
e9e8a1b0b4fd9da03a2c566fce3606276ab29c2ef4731ec1a9aefb86ef78fc70
|
File details
Details for the file the37lab_ampa_sdk-0.1.1756971985-py3-none-any.whl.
File metadata
- Download URL: the37lab_ampa_sdk-0.1.1756971985-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5831f7d9758459c7302160de43d002e5b3da7511a30ede7e2b555eff42d6200c
|
|
| MD5 |
52a3b79508f12893e9b2320b3ad88697
|
|
| BLAKE2b-256 |
3cfe2942d6f8ee216ac33eb57b6256e2f950528df2d08cfa78dda47657acd422
|