Skip to main content

Python client for dotprompt - requires dotprompt/runtime or dotprompt/runtime-dev Docker container. Website: https://dotprompt.run

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.6.tar.gz (9.6 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.6-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file dotprompt_client-0.1.6.tar.gz.

File metadata

  • Download URL: dotprompt_client-0.1.6.tar.gz
  • Upload date:
  • Size: 9.6 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.6.tar.gz
Algorithm Hash digest
SHA256 48801e3fcc5e13b1e7f5b9d2e65d039d84b8c7f9ff125d993cc504fcb0d8c650
MD5 df612abc9384ccb3dd37a83b32475f78
BLAKE2b-256 682bc38b182908b808b6d0718224efeddf88a5ba6a5b5abb79f7198714f8ac26

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dotprompt_client-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9fdc410ec9c9d680866ac68212dff0bb84da69e3d27217dc2e5493611ba4fccb
MD5 7a64084c019979de1ea365ab4919704c
BLAKE2b-256 00dfb0d18b0bc1188bca6eae08fabed012dbdfa74a86fb8b62701af56bdb8621

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