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

Changes by create-pull-request action #530

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

github-actions[bot]
Copy link
Contributor

Automated changes by create-pull-request GitHub action

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR replaces enum classes with string literals across the infinity client models, focusing on simplifying type definitions while maintaining functionality.

  • Replaces EmbeddingObjectObject, ClassifyResultObject, and other enum classes with Literal types (e.g., Literal['embedding'], Literal['classify']) in model classes
  • Updates validation logic in from_dict methods to directly check string values instead of using enum comparisons
  • Removes multiple modality-related enum files (e.g., open_ai_embedding_input_audio_modality.py) and replaces with literal types
  • Adds health check assertion and docstring to test_colpali function in vision_client.py
  • Potential concern: Removal of enum classes could impact code that directly imports these types from the models package

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

19 file(s) reviewed, 12 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +97 to +99
object_ = cast(Union[Literal["classify"], Unset], d.pop("object", UNSET))
if object_ != "classify" and not isinstance(object_, Unset):
raise ValueError(f"object must match const 'classify', got '{object_}'")
Copy link
Contributor

Choose a reason for hiding this comment

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

style: The error message should include the actual type of the invalid value to help with debugging

Copy link
Contributor

Choose a reason for hiding this comment

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

logic: This file has been completely removed but is still imported and used in classify_result.py. This will cause runtime errors when validating the 'object_' field.

Comment on lines +84 to +86
object_ = cast(Union[Literal["model"], Unset], d.pop("object", UNSET))
if object_ != "model" and not isinstance(object_, Unset):
raise ValueError(f"object must match const 'model', got '{object_}'")
Copy link
Contributor

Choose a reason for hiding this comment

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

style: The error message should include the expected type. Consider 'object_ must be "model" or Unset' for better clarity.

Copy link
Contributor

Choose a reason for hiding this comment

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

logic: This file is being deleted but ModelInfo class in model_info.py still references 'infinity' as a default value for owned_by. Make sure all references to this enum are properly updated.

Copy link
Contributor

Choose a reason for hiding this comment

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

logic: This file is being deleted but ModelInfoObject appears to be used in model_info.py. Verify that all references to this enum are properly handled or removed to prevent runtime errors.

Comment on lines +114 to +116
modality = cast(Union[Literal["text"], Unset], d.pop("modality", UNSET))
if modality != "text" and not isinstance(modality, Unset):
raise ValueError(f"modality must match const 'text', got '{modality}'")
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: validation should happen before casting to avoid potential type errors if invalid value is passed

Suggested change
modality = cast(Union[Literal["text"], Unset], d.pop("modality", UNSET))
if modality != "text" and not isinstance(modality, Unset):
raise ValueError(f"modality must match const 'text', got '{modality}'")
modality = d.pop("modality", UNSET)
if modality != "text" and not isinstance(modality, Unset):
raise ValueError(f"modality must match const 'text', got '{modality}'")
modality = cast(Union[Literal["text"], Unset], modality)

Comment on lines +87 to +89
object_ = cast(Union[Literal["list"], Unset], d.pop("object", UNSET))
if object_ != "list" and not isinstance(object_, Unset):
raise ValueError(f"object must match const 'list', got '{object_}'")
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: The validation logic here is more strict than before - it will now raise an error for any value other than 'list', while previously it would accept any value that could be converted to an enum member. Make sure this aligns with the API's behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

logic: This file's complete removal may break code that imports OpenAIEmbeddingResultObject. Check all imports and usages across the codebase, particularly in open_ai_embedding_result.py which likely depends on this enum.

Copy link
Contributor

Choose a reason for hiding this comment

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

logic: This file is being completely removed but is still imported in init.py and may be used by other parts of the codebase. Need to verify all dependencies are updated or confirm this removal is intentional.

Comment on lines +88 to +90
object_ = cast(Union[Literal["rerank"], Unset], d.pop("object", UNSET))
if object_ != "rerank" and not isinstance(object_, Unset):
raise ValueError(f"object must match const 'rerank', got '{object_}'")
Copy link
Contributor

Choose a reason for hiding this comment

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

style: The cast and validation logic here could potentially allow non-string values through if they match 'rerank'. Consider adding an explicit type check for string values.

Suggested change
object_ = cast(Union[Literal["rerank"], Unset], d.pop("object", UNSET))
if object_ != "rerank" and not isinstance(object_, Unset):
raise ValueError(f"object must match const 'rerank', got '{object_}'")
object_ = cast(Union[Literal["rerank"], Unset], d.pop("object", UNSET))
if not isinstance(object_, Unset) and (not isinstance(object_, str) or object_ != "rerank"):
raise ValueError(f"object must be string 'rerank', got '{type(object_).__name__}' with value '{object_}'")

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