[codex] add input field render facet with jinja templates#62
Draft
darinkishore wants to merge 1 commit intomainfrom
Draft
[codex] add input field render facet with jinja templates#62darinkishore wants to merge 1 commit intomainfrom
darinkishore wants to merge 1 commit intomainfrom
Conversation
41ff448 to
f0b2b99
Compare
Collaborator
Author
|
todo: this is no longer the right solution lmao |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds first-class input-field rendering facets for typed signatures, including custom Jinja templates, while preserving the existing
#[format("json"|"yaml"|"toon")]path.Problem
Input rendering previously relied on a stringly
FieldSpec.formatand only supported a fixed format list. There was no explicit way to define per-input Jinja rendering templates from the signature macro.That made custom prompt shaping hard, and it also made validation/error reporting less precise for invalid render declarations.
Root Cause
The signature metadata and derive macro only modeled input formatting as
Option<&'static str>, and the typed chat renderer only consumed that format string.There was no first-class render spec enum, no macro grammar for Jinja templates, and no compile-time Jinja syntax validation.
What Changed
InputRenderSpecto signature metadata withDefault,Format(&'static str), andJinja(&'static str).#[derive(Signature)]with#[render(jinja = "...")]for#[input]fields.ChatAdapterand added strict-undefined Jinja runtime context:thisinputfield(name,rust_name,type)vars#[format(...)]input behavior.Behavior Notes
OutputFormatContent-aware JSON rendering.inputcontext includes both rust names and alias names at top level for input fields.Validation
Ran:
cargo fmt --allcargo test -p dsrs_macroscargo test -p dspy-rs --test test_input_formatcargo test -p dspy-rs --test test_adaptersAlso ran adversarial review passes and fixed the findings before opening this PR.