File tree Expand file tree Collapse file tree 3 files changed +44
-2
lines changed
Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change 1414#
1515# SPDX-License-Identifier: Apache-2.0
1616
17- """Dotpromptz is a library for generating prompts using Handlebars templates."""
17+ """Dotpromptz is a library for generating prompts using Handlebars templates.
18+
19+ This module provides the core Dotprompt class, which extends the Handlebars
20+ template engine for use with generative AI prompts. It supports parsing
21+ templates, rendering metadata, resolving tools and partials, and managing
22+ schemas.
23+
24+ Key features include:
25+
26+ | Feature | Description |
27+ |----------------------|-----------------------------------------------------------------------------------------|
28+ | Template Parsing | Parsing of templates with YAML frontmatter for metadata. |
29+ | Metadata Rendering | Rendering of prompt metadata, including merging and resolving tools and schemas. |
30+ | Tool Resolution | Resolving tool names to tool definitions using a resolver or a static mapping. |
31+ | Partial Resolution | Resolving partial template names to their content using a resolver or a static mapping. |
32+ | Schema Management | Handling of JSON schemas, including Picoschema conversion. |
33+ | Helper Functions | Registration and management of custom helper functions. |
34+ | Partial Templates | Registration and management of partial templates. |
35+ | Model Configuration | Support for default models and model-specific configurations. |
36+ | Prompt Store | Integration with a prompt store for loading prompts and partials. |
37+ | Extensibility | Designed to be extensible with custom helpers, resolvers, and stores. |
38+ """
1839
1940from __future__ import annotations
2041
Original file line number Diff line number Diff line change 1414#
1515# SPDX-License-Identifier: Apache-2.0
1616
17- """Parse dotprompt templates and extract metadata."""
17+ """Parses dotprompt templates and extracts metadata.
18+
19+ This module is responsible for parsing dotprompt templates. It handles extracting
20+ metadata from YAML frontmatter and converting the template content into a
21+ structured format, specifically a list of messages and their parts (text,
22+ media, or metadata).
23+
24+ Key functionalities include:
25+
26+ - Extracting YAML frontmatter and the main template body.
27+ - Parsing the YAML frontmatter into a structured metadata object, handling
28+ reserved keywords and namespaced entries.
29+ - Splitting the template body into message sources based on role and history
30+ markers.
31+ - Converting message sources into structured messages, processing media and
32+ section markers within the content.
33+ - Handling the insertion of historical messages into the conversation flow.
34+ """
1835
1936import re
2037from dataclasses import dataclass , field
Original file line number Diff line number Diff line change @@ -556,3 +556,7 @@ def wrapper(
556556 resolve_metadata_mock .assert_called_with (PromptMetadata (config = {'temperature' : 0.7 }), parsed_source , None )
557557
558558 assert result .config == {'temperature' : 0.7 }
559+
560+
561+ if __name__ == '__main__' :
562+ unittest .main ()
You can’t perform that action at this time.
0 commit comments