Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 16 additions & 96 deletions docs/api/python/dotpromptz.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,120 +6,40 @@ format—an executable prompt template format for Generative AI.
## Installation

```bash
pip install dotpromptz
uv add dotpromptz
```

## Quick Start

```python
from dotpromptz import Dotprompt
from dotpromptz.typing import DataArgument
from dotpromptz import DataArgument, Dotprompt

# Create a Dotprompt instance
# 1. Create a Dotprompt instance
dp = Dotprompt()

# Parse and render a prompt
# 2. Parse and render a prompt
source = '''
---
model: gemini-pro
model: googleai/gemini-flash-latest
input:
schema:
name: string
---
Hello, {{name}}!
'''

rendered = await dp.render(source, data=DataArgument(input={'name': 'World'}))
```

## Core Classes

### Dotprompt

::: dotpromptz.dotprompt.Dotprompt
options:
show\_root\_heading: false
show\_source: true
members\_order: source
show\_docstring\_description: true
show\_docstring\_examples: false

## Parsing

::: dotpromptz.parse
options:
show\_root\_heading: false
show\_source: true
members\_order: source
show\_docstring\_description: true
show\_docstring\_examples: false

## Picoschema

::: dotpromptz.picoschema
options:
show\_root\_heading: false
show\_source: true
members\_order: source
show\_docstring\_description: true
show\_docstring\_examples: false

## Helpers
rendered = await dp.render(source, data=DataArgument(input={'name': 'Ada'}))

::: dotpromptz.helpers
options:
show\_root\_heading: false
show\_source: true
members\_order: source
show\_docstring\_description: true
show\_docstring\_examples: false

## Resolvers

::: dotpromptz.resolvers
options:
show\_root\_heading: false
show\_source: true
members\_order: source
show\_docstring\_description: true
show\_docstring\_examples: false

## Types

::: dotpromptz.typing
options:
show\_root\_heading: false
show\_source: true
members\_order: source
show\_docstring\_description: true
show\_docstring\_examples: false

## Stores

::: dotpromptz.stores
options:
show\_root\_heading: false
show\_source: true
members\_order: source
show\_docstring\_description: true
show\_docstring\_examples: false

## Errors
# 3. Access rendered message
print(rendered.messages[0].content[0].text)
# => Hello, Ada!
```

::: dotpromptz.errors
options:
show\_root\_heading: false
show\_source: true
members\_order: source
show\_docstring\_description: true
show\_docstring\_examples: false
## API Reference

## Utilities
::: dotpromptz
options:
show_root_heading: false
members_order: source
heading_level: 3

::: dotpromptz.util
options:
show\_root\_heading: false
show\_source: true
members\_order: source
show\_docstring\_description: true
show\_docstring\_examples: false
4 changes: 4 additions & 0 deletions python/dotpromptz/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
### ⚠ BREAKING CHANGES

* **helpers:** `{{json ...}}` in prompt templates now raises `TypeError` (standard Python `json.dumps()` behavior) instead of `ValueError` when passed non-serializable objects.
* **api:** implementation modules moved behind private `_`-prefixed names; import from the `dotpromptz` root instead ([#626](https://github.com/google/dotprompt/pull/626)). `dotprompt`, `typing`, `stores`, `errors`, `helpers`, `parse`, `picoschema`, `resolvers`, and `util` remain as compatibility re-exports and will be removed in a future release. These 0.1.6 import paths no longer resolve:
* `dotpromptz.picoschema_reverse`: use `from dotpromptz import json_schema_to_picoschema`.
* `dotpromptz.adapters`, `dotpromptz.models`, `dotpromptz.validate`: removed with no public replacement.
* `dotpromptz.package_name()`: removed.

### Features

Expand Down
14 changes: 10 additions & 4 deletions python/dotpromptz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Here's an example of a Dotprompt file that extracts structured data from provide

```handlebars
---
model: googleai/gemini-2.5-pro
model: googleai/gemini-flash-latest
input:
schema:
text: string
Expand All @@ -62,7 +62,7 @@ present, omit that field from the output. Text:

This Dotprompt file:

1. Specifies the use of the `googleai/gemini-2.5-pro` model.
1. Specifies the use of the `googleai/gemini-flash-latest` model.
2. Defines an input schema expecting a `text` string.
3. Specifies that the output should be in JSON format.
4. Provides a schema for the expected output, including fields for name, age, and occupation.
Expand All @@ -78,15 +78,21 @@ Prompt input and runtime context are separate namespaces. Use `{{name}}` for
input and `{{@name}}` for context:

```python
from dotpromptz import Dotprompt
from dotpromptz.typing import DataArgument
from dotpromptz import DataArgument, Dotprompt

# 1. Initialize compiler
prompt = Dotprompt()

# 2. Render prompt with isolated input and context
result = await prompt.render(
'{{name}} is signed in as {{@name}}',
DataArgument(
input={'name': 'Ada'},
context={'name': 'admin'},
),
)

# 3. Access rendered output
print(result.messages[0].content[0].text)
# => Ada is signed in as admin
```
Loading
Loading