Skip to content

Add Structured Output#1443

Merged
collindutter merged 13 commits intomainfrom
feature/structured-output
Jan 6, 2025
Merged

Add Structured Output#1443
collindutter merged 13 commits intomainfrom
feature/structured-output

Conversation

@collindutter
Copy link
Member

@collindutter collindutter commented Dec 13, 2024

Describe your changes

Added

  • Structured Output support for all Prompt Drivers.
  • PromptTask.output_schema for setting an output schema to be used with Structured Output.
  • Agent.output_schema for setting an output schema to be used on the Agent's Prompt Task.
  • BasePromptDriver.structured_output_strategy for changing the Structured Output strategy between native, tool, and rule.

Issue ticket number and link

Closes #1468

@codecov
Copy link

codecov bot commented Dec 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@collindutter collindutter force-pushed the feature/structured-output branch 3 times, most recently from a7ed072 to f74e2e6 Compare December 18, 2024 23:56
@collindutter collindutter changed the title Add StructuredOutputTool Add Structured Output Dec 19, 2024
@collindutter collindutter force-pushed the feature/structured-output branch 15 times, most recently from d2c0827 to d07d699 Compare December 24, 2024 18:54
@collindutter collindutter marked this pull request as ready for review December 24, 2024 19:05
@collindutter
Copy link
Member Author

@dylanholmes @vachillo still working through docs and some final cleanup, but the PR is certainly developed/large enough for first pass of reviews.

@collindutter collindutter self-assigned this Dec 24, 2024
@collindutter collindutter force-pushed the feature/structured-output branch 2 times, most recently from 896e534 to 3a07430 Compare December 26, 2024 19:08
@collindutter collindutter force-pushed the feature/structured-output branch from 5d6adf5 to d068967 Compare January 3, 2025 23:47
@collindutter collindutter added this to the 1.2 milestone Jan 6, 2025
@collindutter collindutter force-pushed the feature/structured-output branch from d068967 to d03d71b Compare January 6, 2025 17:51
@collindutter collindutter force-pushed the feature/structured-output branch from d03d71b to c80f087 Compare January 6, 2025 18:33
@collindutter collindutter force-pushed the feature/structured-output branch from 4d99d8c to 3fd4d20 Compare January 6, 2025 19:21
@collindutter collindutter enabled auto-merge January 6, 2025 19:21
@collindutter collindutter disabled auto-merge January 6, 2025 19:34
@collindutter collindutter force-pushed the feature/structured-output branch from 3fd4d20 to 8ab92dc Compare January 6, 2025 19:51
@vachillo
Copy link
Member

vachillo commented Jan 6, 2025

offline discussion: support a json schema for output_schem, rather than a schema.Schema object

def _init_structured_output(self, prompt_stack: PromptStack) -> None:
from griptape.tools import StructuredOutputTool

if (output_schema := prompt_stack.output_schema) is not None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional, but I think avoiding nesting is cleaner:

output_schema = prompt_stack.output_schema

if output_schema is None:
    return
    
...

@collindutter collindutter added this pull request to the merge queue Jan 6, 2025
Merged via the queue into main with commit 36d5d2c Jan 6, 2025
15 checks passed
@collindutter collindutter deleted the feature/structured-output branch January 6, 2025 23:23
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.

Structured Output

3 participants