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

Pass strict through from create to from_response #119

Merged
merged 1 commit into from
Oct 20, 2023
Merged

Pass strict through from create to from_response #119

merged 1 commit into from
Oct 20, 2023

Conversation

jxnl
Copy link
Collaborator

@jxnl jxnl commented Oct 15, 2023

Might help with #117

Summary by CodeRabbit

  • New Feature: Enhanced the flexibility of data processing in the OpenAISchema and patch functions. Users can now choose to apply a stricter or more lenient data validation process by using the new strict parameter.
  • Improvement: The process_response, retry_async, and retry_sync functions have been updated to support the new strict parameter, improving the robustness of error handling.
  • Bug Fix: Removed a duplicate process_response function, reducing potential confusion and improving code maintainability.

Please note, these changes are under-the-hood improvements and won't affect the user interface. They are designed to enhance the reliability and flexibility of our backend processes.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 15, 2023

Walkthrough

The changes introduced an additional strict parameter to various functions and methods across the OpenAISchema class and patch.py file. This parameter enhances the flexibility of JSON parsing and validation, improving the robustness of the system.

Changes

File Summary
instructor/function_calls.py The from_response method in the OpenAISchema class now accepts and utilizes an additional strict parameter for JSON parsing and validation.
instructor/patch.py The process_response, retry_async, and retry_sync functions now accept an additional strict parameter. Duplicate process_response function removed. The patch function has been updated to include the new features and parameters.

🐇

In the land of code, where the shadows lie,

A rabbit hopped, with a twinkle in its eye.

With every hop, a change was made,

In the realm of bytes, where the bugs invade.

A parameter new, to the functions came,

'Strict' by name, enhancing the game.

The rabbit hopped away, its job well done,

In the land of code, under the binary sun. 🌞


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
  • Additionally, enter @coderabbitai pause to halt the bot's ongoing reviews as any issue or review comment. To
    resume reviews, enter @coderabbitai resume as any issue or review comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Commits Files that changed from the base of the PR and between 9fe3c83 and 6f66fd7.
Files selected for processing (2)
  • instructor/function_calls.py (4 hunks)
  • instructor/patch.py (5 hunks)
Additional comments (Suppressed): 9
instructor/function_calls.py (4)
  • 101-104: The from_response method now includes a strict parameter. Ensure that all calls to this method throughout the codebase have been updated to match the new signature.

  • 121-122: The strict parameter is now passed to the json.loads function. This allows for stricter control over JSON parsing, which can help prevent errors due to unexpected data types.

  • 212-228: The from_response class method now includes a strict parameter. Ensure that all calls to this method throughout the codebase have been updated to match the new signature.

  • 238-242: The strict parameter is now passed to the model_validate_json method. This allows for stricter control over model validation, which can help prevent errors due to unexpected data types.

instructor/patch.py (5)
  • 49-59: The process_response function now includes a strict parameter. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, the default value of validation_context has been explicitly set to None.

  • 76-88: The retry_async function now includes a strict parameter. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

  • 111-123: The retry_sync function now includes a strict parameter. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

  • 183-193: The patch function's documentation has been updated to include the strict parameter. Ensure that the documentation accurately reflects the function's behavior.

  • 213-218: The strict parameter is being used in a function call. Ensure that the function being called supports this parameter and that it behaves as expected.

@jxnl jxnl merged commit b77fd5d into main Oct 20, 2023
@jxnl jxnl deleted the pass-strict branch November 7, 2023 04:10
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