feat(describegpt): inferred date format for Min/Max in JSON/TOON/JSONSchema#3922
Merged
Conversation
…/JSONSchema The markdown dictionary already renders Date/DateTime Min/Max in the LLM- inferred strftime format (via the datefmt template filter), but the structured outputs serialized them raw (RFC3339). Make them consistent: - Add dictionary::content_type_date_format() + format_date_value() helpers (Rust mirror of the markdown template's datefmt logic). - JSON/TOON (format_dictionary_json): reformat Min/Max for date/datetime fields carrying an inferred format; bare tokens and non-date fields unchanged. - JSONSchema: Date/DateTime Min/Max aren't expressible as JSON Schema minimum/maximum (those stay numeric-only), so surface the formatted range in the per-property x-qsv annotation (x-qsv.min / x-qsv.max) for date fields with an inferred format. Add formatters unit tests for JSON (date, datetime-with-colons, bare-token, non-date) and JSONSchema x-qsv. Regenerate the JSON/TOON/JSONSchema NYC 311 examples (openai/gpt-oss-20b on LM Studio). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
…prose) The prior TOON example reused the JSON run's cache; regenerate with --fresh so its Label/Description/Tags prose is independently generated. Date Min/Max are shown in the inferred format (e.g. Created Date 01/01/2010, Due Date 01/02/1900 12:00:00 AM) as in the other formats. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes describegpt structured dictionary outputs align with markdown output by formatting inferred date/datetime min/max values using their inferred strftime format.
Changes:
- Adds helpers to extract date/datetime format suffixes and reformat min/max values.
- Applies formatted date min/max to JSON/TOON output and JSONSchema
x-qsvannotations. - Adds formatter unit tests and regenerates NYC 311 example artifacts.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/cmd/describegpt/dictionary.rs |
Adds date-format extraction and date-value formatting helpers. |
src/cmd/describegpt/formatters.rs |
Uses formatted min/max values in JSON and JSONSchema outputs; adds tests. |
docs/describegpt/nyc311-describegpt.json |
Regenerated JSON example showing formatted date min/max. |
docs/describegpt/nyc311-describegpt.toon |
Regenerated TOON example showing formatted date min/max. |
docs/describegpt/nyc311-describegpt-schema.json |
Regenerated JSONSchema example with formatted date min/max in x-qsv. |
…type Per Copilot review: format_dictionary_json reformatted Min/Max based on e.content_type alone, so a flag-off entry carrying a date content_type would change the legacy (byte-identical) JSON output while omitting content_type. Gate the reformatting on infer_content_type so the flag-off path is unchanged. Add a flag-off regression test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Follow-up to the markdown dictionary date-formatting feature (already on
master). The markdown dictionary rendersDate/DateTimeMin/Max in the LLM-inferred strftime format (e.g.01/01/2010,06/17/2021 04:34:13 PM) via thedatefmttemplate filter, but the structured outputs still serialized them raw (RFC 3339). This makes them consistent.Changes
src/cmd/describegpt/dictionary.rs:content_type_date_format()— extracts the validated strftime suffix from adate:/datetime:content type.format_date_value()— Rust mirror of the markdown template'sdatefmtlogic (parse viaqsv-dateparser, reformat; unchanged on empty/no-format/parse-failure).format_dictionary_json): Min/Max reformatted for date fields with an inferred format. Baredate/datetimetokens and non-date fields are unchanged.minimum/maximum(those stay numeric-only), so the formatted range is surfaced in the per-propertyx-qsvannotation (x-qsv.min/x-qsv.max) for date fields with an inferred format. This is new info in the schema (previously dates had no Min/Max anywhere in the schema output).Scope / non-goals
master).--infer-content-type, or for fields with no inferred date format, output is unchanged.Testing
formattersunit tests: JSON (date%m/%d/%Y, datetime-with-colons, bare-token unchanged, non-date unchanged) and JSONSchemax-qsv(formatted min/max present for inferred-format dates, absent for bare tokens).cargo clippy -F all_featuresclean;cargo +nightly fmtapplied.openai/gpt-oss-20bon LM Studio) — they now show formatted Min/Max (e.g. JSONCreated Date01/01/2010→12/23/2020; schemax-qsv.min/maxlikewise).🤖 Generated with Claude Code