Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enhance StructuredOutputComponent and add trustcall dependency #7249

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ogabrielluiz
Copy link
Contributor

Introduce a new optional parameter for tool binding, improve structured output handling, and integrate comprehensive tests for the StructuredOutputComponent. Update starter projects to utilize the enhanced component and include the trustcall dependency in the project configuration.

…r for structured output and enhance result handling

* Replaced direct call to with_structured_output with create_extractor for improved flexibility.
* Added handling for "responses" in result to ensure proper data extraction.
* Introduced is_last_pydantic_output_parser method to check parser type in structured output processing.
…AI and NVIDIA models

* Implemented multiple test cases for StructuredOutputComponent using real OpenAI and NVIDIA models.
* Added tests for simple, complex, and nested schemas to validate structured output extraction.
* Included error handling tests to ensure proper response to model limitations and API errors.
* Utilized pytest for conditional test execution based on environment variables for API keys.
…ponent with enhanced input and output handling

* Integrated StructuredOutputComponent into Financial Report Parser and Portfolio Website Code Generator starter projects.
* Updated input fields to include detailed descriptions and requirements for structured output generation.
* Ensured consistent schema definitions and improved error handling for model limitations.
* Enhanced documentation for better clarity on component usage and expected outputs.
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Mar 24, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 24, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Mar 24, 2025
@@ -192,3 +197,8 @@ def as_dataframe(self) -> DataFrame:
if isinstance(output, list):
return DataFrame(data=output)
return DataFrame(data=[output])

def is_last_pydantic_output_parser(self, llm_with_structured_output: Runnable) -> bool:
return isinstance(llm_with_structured_output.last, PydanticOutputParser) and not issubclass(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not subclass? (Specifically, this wouldn't catch the nvidia behavior)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants