Python client for the dot-prompt container API
Project description
dot-prompt Python Client
Python client library for the dot-prompt container API.
Installation
pip install dot-prompt
Quick Start
Synchronous Client
from dotprompt import DotPromptClient
with DotPromptClient() as client:
prompts = client.list_prompts()
print(prompts)
result = client.compile("my_prompt", params={"name": "world"})
print(result.template)
Async Client
import asyncio
from dotprompt import DotPromptAsyncClient
async def main():
async with DotPromptAsyncClient() as client:
prompts = await client.list_prompts()
print(prompts)
result = await client.compile("my_prompt", params={"name": "world"})
print(result.template)
asyncio.run(main())
API Reference
DotPromptClient
Synchronous client wrapper.
list_prompts()- List all available promptslist_collections()- List root-level collectionsget_schema(prompt)- Get prompt schemacompile(prompt, params, seed=None, version=None)- Compile a promptrender(prompt, params, runtime=None, seed=None, version=None)- Render a promptinject(template, runtime)- Inject runtime into templateevents()- Stream real-time eventsvalidate_response(response, contract)- Validate response against contract
DotPromptAsyncClient
Async client with the same methods as above but async.
Configuration
client = DotPromptClient(
base_url="http://localhost:4041", # container URL
timeout=30.0,
verify_ssl=True,
api_key="your-api-key", # optional
max_retries=3,
)
Models
PromptSchema- Prompt metadataCompileResult- Compile operation resultRenderResult- Render operation resultInjectResult- Inject operation resultResponseContract- Response contract definition
Exceptions
DotPromptError- Base exceptionConnectionError- Connection failedTimeoutError- Request timed outPromptNotFoundError- Prompt not foundValidationError- Validation failedServerError- Server error (5xx)
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 dotprompt_client-0.1.0.tar.gz.
File metadata
- Download URL: dotprompt_client-0.1.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
681e925c0f59c65ae1e1320f248b2090a6521ac945d1ec03dde163d4fc47a21c
|
|
| MD5 |
8877a646ace9754f48438c3feb9a8a5f
|
|
| BLAKE2b-256 |
0446f887b9c28ad59d19e85567f690f0be7548356dc48e03dbfcd7fafee501f7
|
File details
Details for the file dotprompt_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dotprompt_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
080b618cf02abea2206b1fdb2c7ed016b807d1e26b5e80b84a82f9334e5d603e
|
|
| MD5 |
555205d2c27a74db837b8a3c62aca7af
|
|
| BLAKE2b-256 |
e718f2b45de106364603af00d886fb504b0ac713c127bdd30e0c601c02199d11
|