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: cohere type #431

Merged
merged 4 commits into from
Sep 23, 2024
Merged

fix: cohere type #431

merged 4 commits into from
Sep 23, 2024

Conversation

ashraq1455
Copy link
Contributor

@ashraq1455 ashraq1455 commented Sep 23, 2024

PR Type

Bug fix


Description

  • Fixed the import statement for EmbeddingsByTypeEmbedResponse in cohere.py.
  • Updated the type check to use the correct class EmbeddingsByTypeEmbedResponse instead of EmbedResponse_EmbeddingsByType.

Changes walkthrough 📝

Relevant files
Bug fix
cohere.py
Fix import and type check for Cohere embeddings                   

semantic_router/encoders/cohere.py

  • Fixed import statement for EmbeddingsByTypeEmbedResponse.
  • Updated type check from EmbedResponse_EmbeddingsByType to
    EmbeddingsByTypeEmbedResponse.
  • +2/-2     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Key issues to review

    Possible Bug
    The type check for EmbeddingsByTypeEmbedResponse is used to raise a NotImplementedError, but it's unclear if this is the correct behavior or if the implementation is missing. This could potentially be a bug if the handling for this type is supposed to be implemented.

    Copy link

    github-actions bot commented Sep 23, 2024

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Enhancement
    Update the exception message to match the checked type

    Update the exception message to match the type name used in the isinstance check to
    avoid confusion and maintain consistency in error handling.

    semantic_router/encoders/cohere.py [51]

     raise NotImplementedError(
    -    "Handling of EmbedByTypeResponseEmbeddings is not implemented."
    +    "Handling of EmbeddingsByTypeEmbedResponse is not implemented."
     )
     
    Suggestion importance[1-10]: 9

    Why: The suggestion improves clarity and consistency in error handling by ensuring the exception message matches the type used in the isinstance check, which is crucial for debugging and maintenance.

    9
    Possible issue
    Correct the import to use the consistent type

    Replace the EmbeddingsByTypeEmbedResponse with the correct type
    EmbedResponse_EmbeddingsByType to maintain consistency with the existing codebase,
    unless the type was intentionally changed.

    semantic_router/encoders/cohere.py [5]

    -from cohere.types.embed_response import EmbeddingsByTypeEmbedResponse
    +from cohere.types.embed_response import EmbedResponse_EmbeddingsByType
     
    Suggestion importance[1-10]: 8

    Why: The suggestion correctly identifies a potential inconsistency in the import statement. If the type was not intentionally changed, reverting to the original type would maintain consistency with the existing codebase.

    8

    Copy link

    codecov bot commented Sep 23, 2024

    Codecov Report

    All modified and coverable lines are covered by tests ✅

    Project coverage is 67.99%. Comparing base (c3fa297) to head (ed368b1).
    Report is 5 commits behind head on main.

    Additional details and impacted files
    @@           Coverage Diff           @@
    ##             main     #431   +/-   ##
    =======================================
      Coverage   67.99%   67.99%           
    =======================================
      Files          46       46           
      Lines        3465     3465           
    =======================================
      Hits         2356     2356           
      Misses       1109     1109           
    Flag Coverage Δ
    67.99% <100.00%> (ø)

    Flags with carried forward coverage won't be shown. Click here to find out more.

    ☔ View full report in Codecov by Sentry.
    📢 Have feedback on the report? Share it here.

    @jamescalam jamescalam merged commit e308619 into main Sep 23, 2024
    8 checks passed
    @jamescalam jamescalam deleted the ashraq/fix-cohere-types branch September 23, 2024 12:18
    @ashraq1455 ashraq1455 restored the ashraq/fix-cohere-types branch September 23, 2024 12:27
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    3 participants