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

Fix parsing for streaming of objects more stable #1031

Merged
merged 3 commits into from
Oct 12, 2024
Merged

Conversation

hellovai
Copy link
Contributor

@hellovai hellovai commented Oct 12, 2024

We penalize objects that are throwing away data by picking default values.

For example, during parsing of complex objects, we sometimes prefer an empty object of default values, but instead we can prefer something else. This also works for handling bad union disambiguation.

Important

Improve object streaming stability by refining default value handling in deserialization and enhancing logging and tests.

  • Behavior:
    • Modify pick_best() in array_helper.rs to penalize default values like null or empty lists when selecting best values.
    • Add handling for BamlValueWithFlags::Class to check for default flags in properties.
  • Logging:
    • Replace println! with log::info! in macros.rs for better logging control.
    • Add log::trace! for score logging in macros.rs.
  • Tests:
    • Add test_partial_choppy in test_partials.rs to test partial deserialization with incomplete data.
    • Update test_partial_deserializer! macro in macros.rs to include score logging.

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

Copy link

vercel bot commented Oct 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
baml ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 12, 2024 5:33pm

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 916851c in 13 seconds

More details
  • Looked at 172 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. engine/baml-lib/jsonish/src/deserializer/coercer/array_helper.rs:85
  • Draft comment:
    The new condition for BamlValueWithFlags::Class in the sorting logic is a significant change. Ensure that this logic correctly identifies and handles default values as intended. Double-check the conditions and flags used here to avoid any logical errors.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The PR introduces a new condition in the sorting logic of pick_best function to handle BamlValueWithFlags::Class types. This is a significant change and should be carefully reviewed for correctness.
2. engine/baml-lib/jsonish/src/tests/test_partials.rs:262
  • Draft comment:
    The JSON string is incorrectly wrapped with backticks. Ensure that the JSON string is correctly formatted to avoid parsing issues.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The test case test_partial_choppy in test_partials.rs is using backticks incorrectly for JSON strings. This might cause issues in parsing or understanding the test data.

Workflow ID: wflow_auoK0viJlD1CnoHr


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

@hellovai hellovai changed the title Make streaming of objects more stable. We penelize objects that are throwing away data by picking default values Make parsing for streaming of objects more stable Oct 12, 2024
@hellovai hellovai changed the title Make parsing for streaming of objects more stable Fix parsing for streaming of objects more stable Oct 12, 2024
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 5cd5e65 in 12 seconds

More details
  • Looked at 190 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. engine/baml-lib/jsonish/src/deserializer/coercer/array_helper.rs:94
  • Draft comment:
    Consider refactoring the logic for checking FieldType::Union(_) and handling default values and coerced strings for better readability and performance. The current nested structure can be simplified.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The use of matches! for checking FieldType::Union(_) is correct, but the logic for handling default values and coerced strings could be optimized for readability and performance.
2. engine/baml-lib/jsonish/src/tests/test_partials.rs:336
  • Draft comment:
    Ensure that the expected output in test_partial_choppy_union_2 matches the intended behavior of the code changes, especially with the handling of union types and default values.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The test case test_partial_choppy_union_2 is correctly set up to test the union type handling, but ensure that the expected output matches the intended behavior of the code changes.

Workflow ID: wflow_uMOmdDzUYshT8KLk


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

@hellovai hellovai added this pull request to the merge queue Oct 12, 2024
Merged via the queue into canary with commit 8aa9c00 Oct 12, 2024
9 of 10 checks passed
@hellovai hellovai deleted the stable-stream branch October 12, 2024 17:29
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.

1 participant