-
Notifications
You must be signed in to change notification settings - Fork 66
Expose max_distance as an optional setting in multi vector queries #478
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
base: main
Are you sure you want to change the base?
Changes from all commits
b731542
45898df
6d239f9
3624f42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -18,12 +18,20 @@ | |||||
| class Vector(BaseModel): | ||||||
| """ | ||||||
| Simple object containing the necessary arguments to perform a multi vector query. | ||||||
|
|
||||||
| Args: | ||||||
| vector: The vector values as a list of floats or bytes | ||||||
| field_name: The name of the vector field to search | ||||||
| dtype: The data type of the vector (default: "float32") | ||||||
| weight: The weight for this vector in the combined score (default: 1.0) | ||||||
| max_distance: The maximum distance for vector range search (default: 2.0, range: [0.0, 2.0]) | ||||||
| """ | ||||||
|
|
||||||
| vector: Union[List[float], bytes] | ||||||
| field_name: str | ||||||
| dtype: str = "float32" | ||||||
| weight: float = 1.0 | ||||||
| max_distance: float = 2.0 | ||||||
justin-cechmanek marked this conversation as resolved.
Show resolved
Hide resolved
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of a custom validation method, you could validate this with Pydantic's built-in
Suggested change
|
||||||
|
|
||||||
| @field_validator("dtype") | ||||||
| @classmethod | ||||||
|
|
@@ -36,6 +44,15 @@ def validate_dtype(cls, dtype: str) -> str: | |||||
| ) | ||||||
| return dtype | ||||||
|
|
||||||
| @field_validator("max_distance") | ||||||
| @classmethod | ||||||
| def validate_max_distance(cls, max_distance: float) -> float: | ||||||
| if not isinstance(max_distance, (float, int)): | ||||||
| raise ValueError("max_distance must be a value between 0.0 and 2.0") | ||||||
|
Comment on lines
+50
to
+51
|
||||||
| if not isinstance(max_distance, (float, int)): | |
| raise ValueError("max_distance must be a value between 0.0 and 2.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for providing the range!