google / google/dotprompt

[FR] Add "metadata=" on `role` helper, add newPart helper.

Open
#311 0 comments 1 reaction 0 assignees View on GitHub
feature
Dominant language
Starlark
Stars
563
Forks
68
Avg merge
6m
Merged PRs (30d)
2

Description

To allow prompts to annotate themselves with metadata, I propose two additions:

### 1. A metadata hash argument for the role and media helpers

```handlebars
{{role "system" metadata.foo="bar"}}
{{media url="..." metadata.foo="bar"}}
```

**Note:** I believe the `metadata.foo` syntax style is necessary because Handlebars doesn't support object literals. The algorithm should be to iterate through hash arguments for anything beginning with `metadata.*` and add each of those as metadata keys. Metadata should be merged with existing metadata (if any).

### 2. A `newPart` helper.

This helper creates a new text part with optional metadata:

```handlebars
{{newPart metadata.foo="bar"}}
```

This allows the user to create custom "sections" within their prompt for better observability and understanding.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.