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

Refactor/make output schema mandatory #133

Merged
merged 5 commits into from
Jan 31, 2025

Conversation

srijanpatel
Copy link
Collaborator

@srijanpatel srijanpatel commented Jan 31, 2025

output_schema is made part of the config like regular schemas.
has_fixed_schema is also made part of the config. NodeSidebar is configured to not render it.

Refactoring Fixed Output Schema Handling:

  • backend/app/api/node_management.py: Removed the logic for adding the output schema to the configuration for fixed output nodes.
  • backend/app/nodes/base.py: Added output_schema and has_fixed_output fields to FixedOutputBaseNodeConfig and removed the abstract output_schema property from FixedOutputBaseNode. Updated the setup method to use the new output_schema field. [1] [2]
  • backend/app/nodes/llm/retriever.py: Updated RetrieverNodeConfig to include the output_schema field and removed the redundant output_schema property from RetrieverNode. [1] [2]

Code Readability Improvements:

Frontend Updates:


Important

Refactor to make output schema mandatory in node configuration, updating both backend and frontend to handle fixed output schemas appropriately.

  • Backend Changes:
    • node_management.py: Removed logic for adding output schema to config for fixed output nodes.
    • base.py: Added output_schema and has_fixed_output to FixedOutputBaseNodeConfig, removed abstract output_schema property.
    • retriever.py: Updated RetrieverNodeConfig to include output_schema, removed redundant output_schema property.
  • Frontend Changes:
    • NodeSidebar.tsx: Updated logic to check currentNodeConfig for has_fixed_output, prevented rendering of has_fixed_output field.
    • nodeTypesSlice.ts: Added has_fixed_schema to FlowWorkflowNodeType interface.

This description was created by Ellipsis for ca7e0a6. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Reviewed everything up to 5e40e5d in 1 minute and 25 seconds

More details
  • Looked at 285 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 drafted comments based on config settings.
1. backend/app/nodes/llm/retriever.py:27
  • Draft comment:
    The output_schema field is defined as Dict[str, str], but the schema types (e.g., list[RetrievalResultSchema]) are not strings. Consider using Dict[str, Any] for more accurate type representation.
  • Reason this comment was not posted:
    Marked as duplicate.
2. backend/app/nodes/base.py:276
  • Draft comment:
    The output_schema field is defined as Dict[str, str], but the schema types (e.g., list[RetrievalResultSchema]) are not strings. Consider using Dict[str, Any] for more accurate type representation. This comment also applies to RetrieverNodeConfig in retriever.py.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The code in create_output_model_class() shows that string type names are expected and handled properly. The field_type_to_python_type mapping converts string type names to actual types. If the type isn't in the mapping, it tries to use it as-is (line 121). This suggests the current design is intentional and working as expected.
    The comment might have a point - using Dict[str, Any] would be more technically accurate since non-string types can be passed. However, the current implementation handles both cases gracefully.
    The current implementation is working as designed - it expects string type names but has a fallback for direct type references. Changing to Dict[str, Any] wouldn't improve functionality.
    Delete the comment. The current typing is intentional and the implementation handles all cases correctly. This is not a real issue that needs fixing.
3. backend/app/nodes/llm/retriever.py:116
  • Draft comment:
    Instead of using assert embedding_model_info is not None, consider raising a ValueError with a descriptive message if embedding_model_info is None. This provides clearer error handling.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The assert embedding_model_info is not None is used to ensure embedding_model_info is not None, but it would be more informative to raise a specific error if this condition fails.
4. frontend/src/components/nodes/nodeSidebar/NodeSidebar.tsx:568
  • Draft comment:
    The hasFixedOutput logic is repeated in multiple places. Consider centralizing this logic to avoid redundancy and potential errors. This comment also applies to line 668.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The has_fixed_output field is being checked in multiple places in the frontend code. It might be beneficial to centralize this logic to avoid redundancy and potential errors.
5. frontend/src/components/nodes/nodeSidebar/NodeSidebar.tsx:668
  • Draft comment:
    The hasFixedOutput logic is repeated in multiple places. Consider centralizing this logic to avoid redundancy and potential errors. This comment also applies to line 568.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The has_fixed_output field is being checked in multiple places in the frontend code. It might be beneficial to centralize this logic to avoid redundancy and potential errors.

Workflow ID: wflow_6tAv2h3elhpoukbf


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on ca7e0a6 in 57 seconds

More details
  • Looked at 878 lines of code in 19 files
  • Skipped 0 files when reviewing.
  • Skipped posting 6 drafted comments based on config settings.
1. backend/app/nodes/llm/generative/best_of_n.py:39
  • Draft comment:
    Ensure that output_json_schema is properly handled when it is not provided. Consider adding a check or default value to prevent inconsistencies in node configuration.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The code in backend/app/nodes/llm/generative/best_of_n.py has a potential issue with the output_schema field. The default value for output_schema is set to {"response": "string"}. However, in the setup_subworkflow method, the output_schema is used to configure nodes, and there is a possibility that the output_json_schema is not properly handled if it is not provided. This could lead to inconsistencies in the node configuration.
2. backend/app/nodes/logic/coalesce.py:53
  • Draft comment:
    The parameters __config__, __module__, __doc__, __validators__, and __cls_kwargs__ in create_model are set to None. These can be omitted for cleaner code. This applies to other instances in this file as well.
  • Reason this comment was not posted:
    Confidence changes required: 30%
    In backend/app/nodes/logic/coalesce.py, the create_model function is used to dynamically create models. However, the __config__, __module__, __doc__, __validators__, and __cls_kwargs__ parameters are set to None. This is unnecessary and can be omitted for cleaner code.
3. backend/app/nodes/logic/router.py:133
  • Draft comment:
    The parameters __config__, __module__, __doc__, __validators__, and __cls_kwargs__ in create_model are set to None. These can be omitted for cleaner code. This applies to other instances in this file as well.
  • Reason this comment was not posted:
    Confidence changes required: 30%
    In backend/app/nodes/logic/router.py, the create_model function is used to dynamically create models. However, the __config__, __module__, __doc__, __validators__, and __cls_kwargs__ parameters are set to None. This is unnecessary and can be omitted for cleaner code.
4. backend/app/nodes/loops/base_loop_subworkflow_node.py:105
  • Draft comment:
    The parameters __config__, __module__, __doc__, __validators__, and __cls_kwargs__ in create_model are set to None. These can be omitted for cleaner code.
  • Reason this comment was not posted:
    Confidence changes required: 30%
    In backend/app/nodes/loops/base_loop_subworkflow_node.py, the create_model function is used to dynamically create models. However, the __config__, __module__, __doc__, __validators__, and __cls_kwargs__ parameters are set to None. This is unnecessary and can be omitted for cleaner code.
5. backend/app/nodes/primitives/input.py:69
  • Draft comment:
    The parameters __config__, __module__, __doc__, __validators__, and __cls_kwargs__ in create_model are set to None. These can be omitted for cleaner code.
  • Reason this comment was not posted:
    Confidence changes required: 30%
    In backend/app/nodes/primitives/input.py, the create_model function is used to dynamically create models. However, the __config__, __module__, __doc__, __validators__, and __cls_kwargs__ parameters are set to None. This is unnecessary and can be omitted for cleaner code.
6. backend/app/nodes/primitives/output.py:58
  • Draft comment:
    The parameters __config__, __module__, __doc__, __validators__, and __cls_kwargs__ in create_model are set to None. These can be omitted for cleaner code.
  • Reason this comment was not posted:
    Confidence changes required: 30%
    In backend/app/nodes/primitives/output.py, the create_model function is used to dynamically create models. However, the __config__, __module__, __doc__, __validators__, and __cls_kwargs__ parameters are set to None. This is unnecessary and can be omitted for cleaner code.

Workflow ID: wflow_9oLg5yO9sij0aPsN


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@JeanKaddour JeanKaddour merged commit 6e29a15 into main Jan 31, 2025
1 check passed
@srijanpatel srijanpatel deleted the refactor/make-output-schema-mandatory branch February 7, 2025 19:47
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.

2 participants