Skip to main content

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 prompts
  • list_collections() - List root-level collections
  • get_schema(prompt) - Get prompt schema
  • compile(prompt, params, seed=None, version=None) - Compile a prompt
  • render(prompt, params, runtime=None, seed=None, version=None) - Render a prompt
  • inject(template, runtime) - Inject runtime into template
  • events() - Stream real-time events
  • validate_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 metadata
  • CompileResult - Compile operation result
  • RenderResult - Render operation result
  • InjectResult - Inject operation result
  • ResponseContract - Response contract definition

Exceptions

  • DotPromptError - Base exception
  • ConnectionError - Connection failed
  • TimeoutError - Request timed out
  • PromptNotFoundError - Prompt not found
  • ValidationError - Validation failed
  • ServerError - Server error (5xx)

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

dotprompt_client-0.1.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

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

dotprompt_client-0.1.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

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

Hashes for dotprompt_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 681e925c0f59c65ae1e1320f248b2090a6521ac945d1ec03dde163d4fc47a21c
MD5 8877a646ace9754f48438c3feb9a8a5f
BLAKE2b-256 0446f887b9c28ad59d19e85567f690f0be7548356dc48e03dbfcd7fafee501f7

See more details on using hashes here.

File details

Details for the file dotprompt_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dotprompt_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 080b618cf02abea2206b1fdb2c7ed016b807d1e26b5e80b84a82f9334e5d603e
MD5 555205d2c27a74db837b8a3c62aca7af
BLAKE2b-256 e718f2b45de106364603af00d886fb504b0ac713c127bdd30e0c601c02199d11

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