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

Added support for response_model = None in cohere #867

Merged
merged 6 commits into from
Jul 23, 2024

Conversation

ivanleomk
Copy link
Collaborator

@ivanleomk ivanleomk commented Jul 22, 2024

This adds support for passing in response_model = None for Cohere Sync and Async clients


🚀 This description was created by Ellipsis for commit 0aa258e

Summary:

Added support for response_model=None in Cohere Sync and Async clients, updated relevant functions, tests, and documentation.

Key points:

  • Added support for response_model=None in Cohere Sync and Async clients.
  • Modified instructor/retry.py to handle response_model=None in retry_sync and retry_async functions.
  • Updated reask_messages function to extend chat_history or messages based on the mode.
  • Formats messages and chat history according to Cohere's requirements.
  • Updates new_kwargs dictionary with formatted messages and chat history.
  • Added tests in tests/llm/test_cohere/test_none_response.py and tests/llm/test_cohere/test_json_schema.py to verify the new functionality.
  • Updated docs/index.md with examples demonstrating the new feature.

Generated with ❤️ by ellipsis.dev

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 157c68e in 25.955599 seconds

More details
  • Looked at 42 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. instructor/process_response.py:534
  • Draft comment:
    The removal of strict from new_kwargs is done without checking if it exists. This is generally safe but could be explicitly checked to avoid potential confusion or errors in future modifications.
new_kwargs.pop("strict", None)
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The PR adds support for handling response_model = None specifically for Mode.COHERE_JSON_SCHEMA and Mode.COHERE_TOOLS. The code checks if response_model is None and if the mode is either COHERE_JSON_SCHEMA or COHERE_TOOLS, then processes the messages to format them according to Cohere's requirements. The code seems to handle the chat history and the last message correctly, and it also handles the case where model_name is provided instead of model. However, the code removes the strict key from new_kwargs without checking if it exists, which is generally safe but could be explicitly checked to avoid confusion.

Workflow ID: wflow_FBvxOAQstYXab6jU


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

Copy link

cloudflare-pages bot commented Jul 22, 2024

Deploying instructor with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0aa258e
Status: ✅  Deploy successful!
Preview URL: https://05e1e14c.instructor.pages.dev
Branch Preview URL: https://fix-cohere-non.instructor.pages.dev

View logs

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 0525df4 in 40.51001 seconds

More details
  • Looked at 105 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. tests/llm/test_cohere/test_none_response.py:1
  • Draft comment:
    The new test file test_none_response.py should be added to mkdocs.yml to ensure it is included in the documentation. This is important for maintaining the discoverability and documentation of new features and tests.
  • Reason this comment was not posted:
    Confidence of 0% on close inspection, compared to threshold of 85%.

Workflow ID: wflow_hfMGGHxBYBJ8QBAm


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 cc84040 in 58.238597 seconds

More details
  • Looked at 11 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. tests/llm/test_cohere/test_none_response.py:1
  • Draft comment:
    The assertion assert response.text might not be appropriate if response_model=None alters the expected attributes of the response object. Consider adjusting the test to reflect the expected output when response_model is set to None.
  • Reason this comment was not posted:
    Confidence of 0% on close inspection, compared to threshold of 85%.

Workflow ID: wflow_6A8qeyzOZjPKHjyO


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 4d063c8 in 43.598173 seconds

More details
  • Looked at 11 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. tests/llm/test_cohere/test_none_response.py:5
  • Draft comment:
    The assertion assert response.text might not be appropriate if response_model=None is expected to alter the response structure. Consider revising the assertion to align with the expected output when response_model is None. This comment applies to both synchronous and asynchronous test cases.
  • Reason this comment was not posted:
    Confidence of 80% on close inspection, compared to threshold of 85%.

Workflow ID: wflow_rdzWS2fj4BNP2UJR


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 9ef4f5a in 43.868312 seconds

More details
  • Looked at 16 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. instructor/retry.py:247
  • Draft comment:
    The PR description mentions changes related to response_model=None, but the diff provided does not reflect these changes. Please clarify if the correct changes are included in the diff or if there is a discrepancy in the PR description.
  • Reason this comment was not posted:
    Confidence of 0% on close inspection, compared to threshold of 85%.

Workflow ID: wflow_M90H5ZLVRCn6Mbf2


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 0aa258e in 49.091434 seconds

More details
  • Looked at 135 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. tests/llm/test_cohere/test_json_schema.py:16
  • Draft comment:
    The function test_parse_user_sync is defined twice (lines 16 and 48), which will cause the second definition to overwrite the first one. Consider renaming one of these functions to ensure both functionalities are tested separately.
  • Reason this comment was not posted:
    Confidence of 0% on close inspection, compared to threshold of 85%.

Workflow ID: wflow_PWvpjyrElrHRAB1y


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

@ivanleomk ivanleomk merged commit 118a53c into cohere-json Jul 23, 2024
7 of 8 checks passed
@ivanleomk ivanleomk deleted the fix-cohere-non branch July 23, 2024 23:36
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.

None yet

2 participants