Skip to content

fix: render uploaded file prompts without inline data - #959

Draft
Kayvan Zahiri (Kayvan-Zahiri) wants to merge 1 commit into
braintrustdata:mainfrom
Kayvan-Zahiri:codex/fix-file-id-prompt-rendering
Draft

Kayvan Zahiri (Kayvan-Zahiri) wants to merge 1 commit into
braintrustdata:mainfrom
Kayvan-Zahiri:codex/fix-file-id-prompt-rendering

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

Prompt.build() raises KeyError: 'file_data' for a chat prompt containing an uploaded PDF reference such as {"type": "file", "file": {"file_id": "{{report_file_id}}"}}. Uploaded files do not require inline file_data (file-input guide).

Render file_data only when present, matching the existing treatment of file_id and filename. Add public Prompt.build() regressions for uploaded and inline files in strict and non-strict mode, checking the complete message payload and preservation of the source template.

Validation:

  • Before the fix: the two uploaded-file cases fail with KeyError: 'file_data'; the two inline-file controls pass.
  • Logger suite: 199 passed, 4 skipped, 23 subtests passed (Python 3.13.4).
  • Final focused prompt/message tests: 13 passed.
  • All repository pre-commit hooks passed, including pinned Ruff format/check.

This exercises local SDK prompt rendering; it does not upload a file or make a model request. Tools and dependencies were installed only in an isolated virtual environment. mise is unavailable locally, so the pinned pre-commit hooks were run directly.

AI assistance: Codex identified, reproduced, implemented, and tested this local SDK fix. Submitted as a draft for human review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant