-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: add StructuredOutput component #4024
Merged
Merged
Conversation
This file contains 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
This pull request is automatically being deployed by Amplify Hosting (learn more). |
I'm assuming this also applies to this PR |
It could but I'm considering something different. I'll push it as soon as I can. I'm considering building a component that builds the structured output using an llm. |
676fce7
to
46835a1
Compare
italojohnny
approved these changes
Oct 7, 2024
a5162c0
to
dc20c45
Compare
5e4935a
to
fd8cdd3
Compare
4ebd887
to
495b329
Compare
…l.py - Implement various test cases to validate the functionality of build_model_from_schema. - Test cases cover scenarios such as handling valid and empty schemas, managing unknown field types, and processing schemas with missing optional keys. - Ensure proper handling of nested list and dict types, and verify the function's efficiency with large schemas. - Confirm that the function raises exceptions for invalid input and handles duplicate field names correctly.
- Refactor `OpenAIModelComponent` to use `TableInput` for `output_schema` and integrate `build_model_from_schema`. - Modify `HierarchicalCrewComponent` to use unpacking for base inputs. - Ensure consistent import statements across JSON files. - Improve error handling and logging for vector store operations.
- Implement `build_messages_and_runnable` to construct message lists and configure runnable models. - Add `get_chat_result` to execute language models with input messages, supporting streaming and custom configurations. - Handle exceptions with optional custom error messages.
…and schema naming
…e from field creation
- Implement various test cases to ensure correct functionality of StructuredOutputComponent. - Test successful structured output generation, handling of unsupported language models, and correct output model building. - Validate handling of multiple outputs, empty and invalid output schemas, and nested schemas. - Include tests for large input values and invalid language model configurations.
Rename the test_base_model.py file to test_base_model_from_schema.py to better reflect its purpose of testing the build_model_from_schema function. This change improves code clarity and maintainability.
…odel_from_schema" This reverts commit 2e84a86.
- Refactored `OpenAIModelComponent` to use `operator.ior` and `functools.reduce` for converting `output_schema` to a dictionary. - Deprecated the `output_schema` field, updating its info to reflect the deprecation. - Simplified the `_docs_to_data` method in `SplitTextComponent` for better readability. - Updated import statements and removed unused imports across multiple JSON files.
7e22b93
to
fe4dbd7
Compare
diogocabral
pushed a commit
to headlinevc/langflow
that referenced
this pull request
Nov 26, 2024
* Add utility functions to build Pydantic models from schema definitions * Add unit tests for build_model_from_schema function in test_base_model.py - Implement various test cases to validate the functionality of build_model_from_schema. - Test cases cover scenarios such as handling valid and empty schemas, managing unknown field types, and processing schemas with missing optional keys. - Ensure proper handling of nested list and dict types, and verify the function's efficiency with large schemas. - Confirm that the function raises exceptions for invalid input and handles duplicate field names correctly. * Refactor tests in `test_base_model.py` to improve type handling and error checking * Refactor output schema handling to use TableInput and build_model_from_schema * Update OpenAI model components and hierarchical crew setup - Refactor `OpenAIModelComponent` to use `TableInput` for `output_schema` and integrate `build_model_from_schema`. - Modify `HierarchicalCrewComponent` to use unpacking for base inputs. - Ensure consistent import statements across JSON files. - Improve error handling and logging for vector store operations. * Add chat result model with message building and execution logic - Implement `build_messages_and_runnable` to construct message lists and configure runnable models. - Add `get_chat_result` to execute language models with input messages, supporting streaming and custom configurations. - Handle exceptions with optional custom error messages. * Add "table" to DIRECT_TYPES in constants.py * Add support for DataFrame input validation in TableInput class * Add StructuredOutputComponent for generating structured outputs from language models * Enhance structured output component with improved input descriptions and schema naming * Convert DataFrame to list of dictionaries in TableInput validation * Remove pandas dependency and refactor schema handling in structured_output.py * Remove 'default' field from structured output schema and update field initialization * Add 'number' and 'text' types to type mapping and remove default value from field creation * Enhance error handling in structured output building process * Improve error message for non-BaseModel output in structured_output.py * Add unit tests for StructuredOutputComponent in helpers module - Implement various test cases to ensure correct functionality of StructuredOutputComponent. - Test successful structured output generation, handling of unsupported language models, and correct output model building. - Validate handling of multiple outputs, empty and invalid output schemas, and nested schemas. - Include tests for large input values and invalid language model configurations. * Update description for StructuredOutputComponent to clarify functionality * Add default values and error handling for structured output in helpers * Remove unused 'method' parameter from 'with_structured_output' in MockLanguageModel * refactor: rename test_base_model.py to test_base_model_from_schema.py Rename the test_base_model.py file to test_base_model_from_schema.py to better reflect its purpose of testing the build_model_from_schema function. This change improves code clarity and maintainability. * Add type ignore comments to suppress type checking errors * Add Generic typing to StructuredOutputComponent and fix method call * Revert "Refactor output schema handling to use TableInput and build_model_from_schema" This reverts commit 2e84a86. * Deprecate JSON mode in OpenAIModel output schema documentation * Remove unused Generic import and add type ignore comment in StructuredOutputComponent * Refactor OpenAI model components and deprecate output schema - Refactored `OpenAIModelComponent` to use `operator.ior` and `functools.reduce` for converting `output_schema` to a dictionary. - Deprecated the `output_schema` field, updating its info to reflect the deprecation. - Simplified the `_docs_to_data` method in `SplitTextComponent` for better readability. - Updated import statements and removed unused imports across multiple JSON files. * Add specific type ignore comments and update exception types in backend code
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
enhancement
New feature or request
lgtm
This PR has been approved by a maintainer
size:XL
This PR changes 500-999 lines, ignoring generated files.
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.
OpenAIModelComponent
to useTableInput
foroutput_schema
and integratebuild_model_from_schema
.HierarchicalCrewComponent
to use unpacking for base inputs.