-
Notifications
You must be signed in to change notification settings - Fork 770
Description
Today, we support prompt templates and schemas for system, user, and assistant. You can mix structured and non-structured inputs by completing them with raw_text.
However, there's a case for using multiple prompt templates and schemas for a given role, e.g. a structured multi-turn or multi-block conversation. We might want multiple user messages with different templates, or even a message with multiple content blocks with different templates.
In the config, today you can specify {system|user|assistant}_{schema|template}.
We can generalize this further with "named input templates". You'd specify:
[functions.my_function]
# ...
input_schemas.abc = "path/to/schema.json"
input_schemas.def = "path/to/schema.json"
output_schema = "path/to/schema.json" # no change
# Deprecate: user_schema
# Deprecate: assistant_schema
# ...
[functions.my_function.variants.my_function]
# ...
input_templates.abc = "path/to/template.minijinja"
input_templates.def = "path/to/template.minijinja"
# Deprecate: user_template
# Deprecate: assistant_template
# ...
input_wrappers.system = "path/to/template.minijinja"
input_wrappers.assistant = "path/to/template.minijinja"
input_wrappers.user = "path/to/template.minijinja"
# ...The values input_schemas."tensorzero::*", input_templates."tensorzero::*", and input_wrappers."tensorzero::*" are reserved.
If you define a schema, you must define the corresponding input template, and vice-versa.
At inference time, you'd send messages like:
{
"role": "user",
"content": [
{
"type": "template",
"name": "abc",
"arguments": {
"x": 1
}
}
]
}We'll gradually deprecate arguments in text content blocks.
For system, if you provide an object, it will try to use the input_templates.system template and error if not present.
input_wrappers templates support a single variable, text, which is the text content block. (Any other values currently supported will be gradually deprecated.)