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: clean up cohere templating #1030

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

fix: clean up cohere templating #1030

wants to merge 4 commits into from

Conversation

jxnl
Copy link
Owner

@jxnl jxnl commented Sep 30, 2024

Important

Refactor Cohere templating by integrating it into handle_templating in templating.py, simplifying code, and updating tests.

  • Refactoring:
    • Remove handle_cohere_templating from patch.py and integrate its logic into handle_templating in templating.py.
    • Simplify from_cohere in client_cohere.py by removing new_create_async and using instructor.patch directly.
  • Functionality:
    • handle_templating in templating.py now processes kwargs for Cohere, OpenAI, Anthropic, VertexAI, and Gemini formats.
    • Ensure kwargs contains message, messages, or contents in handle_templating.
  • Tests:
    • Update tests in test_formatting.py to use handle_templating from templating.py and cover various message formats.
  • Misc:
    • Remove unused imports in client_cohere.py.

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

@jxnl jxnl requested a review from ivanleomk September 30, 2024 01:30
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 c4ccc42 in 10 seconds

More details
  • Looked at 230 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. instructor/patch.py:96
  • Draft comment:
    The return type in the docstring is incorrect. It should be dict[str, Any] instead of list[dict[str, Any]].
  • Reason this comment was not posted:
    Comment was on unchanged code.
2. instructor/patch.py:110
  • Draft comment:
    Assertion error messages should be more descriptive. Consider providing more context in the error message to help with debugging.
  • Reason this comment was not posted:
    Confidence changes required: 80%
    The assertion error messages in the handle_templating function should be more descriptive.

Workflow ID: wflow_KECPvk0OQBJZn4E3


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

Copy link

cloudflare-workers-and-pages bot commented Sep 30, 2024

Deploying instructor with  Cloudflare Pages  Cloudflare Pages

Latest commit: 497093a
Status: ✅  Deploy successful!
Preview URL: https://327108a1.instructor.pages.dev
Branch Preview URL: https://fix-cohere-formatting.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 9629f48 in 9 seconds

More details
  • Looked at 444 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. instructor/templating.py:15
  • Draft comment:
    Consider moving the import statement for vertexai.generative_models to the top of the file to avoid repeated imports and improve performance.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The import statement for vertexai.generative_models is inside a function, which can lead to performance issues if the function is called frequently. It's better to move the import to the top of the file.
2. instructor/templating.py:56
  • Draft comment:
    If handle_templating is part of the library's public API, ensure the documentation is updated to reflect the changes made to this function.
  • Reason this comment was not posted:
    Confidence changes required: 80%
    The function handle_templating in instructor/templating.py has been updated, but there is no corresponding update in the documentation. Since this is a library code change, the documentation should be updated accordingly.
3. tests/test_formatting.py:1
  • Draft comment:
    Ensure that the documentation is updated to reflect the changes made to handle_templating if it's part of the public API.
  • Reason this comment was not posted:
    Confidence changes required: 80%
    The function handle_templating in instructor/templating.py has been updated, but there is no corresponding update in the documentation. Since this is a library code change, the documentation should be updated accordingly.

Workflow ID: wflow_QHjPdv0hUUBG83Zy


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.

❌ Changes requested. Incremental review on d2a5c7c in 17 seconds

More details
  • Looked at 9 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. instructor/templating.py:1
  • Draft comment:
    Avoid using # type: ignore[all]. Instead, address specific type issues to ensure type safety.
  • Reason this comment was not posted:
    Confidence changes required: 80%
    The use of # type: ignore[all] suppresses all type checking for this file, which can hide potential type-related issues. It's better to address specific type errors rather than ignoring all of them.

Workflow ID: wflow_azrUW2ProRxOjWzd


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -0,0 +1,97 @@
# type: ignore[all]
Copy link
Contributor

Choose a reason for hiding this comment

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

The # type: ignore[all] comment should be justified with a reason or removed if not necessary, especially in library code.

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