Skip to content

Commit

Permalink
removes comments. imports constants to router and session manager
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-cechmanek committed Sep 27, 2024
1 parent 8e708e7 commit 3e87469
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
3 changes: 2 additions & 1 deletion redisvl/extensions/router/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from pydantic.v1 import BaseModel, Field, validator

from redisvl.extensions.constants import ROUTE_VECTOR_FIELD_NAME
from redisvl.schema import IndexInfo, IndexSchema


Expand Down Expand Up @@ -104,7 +105,7 @@ def from_params(cls, name: str, vector_dims: int) -> "SemanticRouterIndexSchema"
{"name": "route_name", "type": "tag"},
{"name": "reference", "type": "text"},
{
"name": "vector",
"name": ROUTE_VECTOR_FIELD_NAME,
"type": "vector",
"attrs": {
"algorithm": "flat",
Expand Down
5 changes: 3 additions & 2 deletions redisvl/extensions/router/semantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from redis.commands.search.aggregation import AggregateRequest, AggregateResult, Reducer
from redis.exceptions import ResponseError

from redisvl.extensions.constants import ROUTE_VECTOR_FIELD_NAME
from redisvl.extensions.router.schema import (
DistanceAggregationMethod,
Route,
Expand Down Expand Up @@ -226,7 +227,7 @@ def _classify_route(
"""Classify to a single route using a vector."""
vector_range_query = RangeQuery(
vector=vector,
vector_field_name="vector",
vector_field_name=ROUTE_VECTOR_FIELD_NAME,
distance_threshold=distance_threshold,
return_fields=["route_name"],
)
Expand Down Expand Up @@ -278,7 +279,7 @@ def _classify_multi_route(
"""Classify to multiple routes, up to max_k (int), using a vector."""
vector_range_query = RangeQuery(
vector=vector,
vector_field_name="vector",
vector_field_name=ROUTE_VECTOR_FIELD_NAME,
distance_threshold=distance_threshold,
return_fields=["route_name"],
)
Expand Down
14 changes: 4 additions & 10 deletions redisvl/extensions/session_manager/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,18 @@ class Config:
@root_validator(pre=True)
@classmethod
def generate_id(cls, values):
###if "timestamp" not in values:
### values["timestamp"] = current_timestamp()
if TIMESTAMP_FIELD_NAME not in values: ###
values[TIMESTAMP_FIELD_NAME] = current_timestamp() ###
###if "entry_id" not in values:
### values["entry_id"] = f'{values["session_tag"]}:{values["timestamp"]}'
if ID_FIELD_NAME not in values: ###
if TIMESTAMP_FIELD_NAME not in values:
values[TIMESTAMP_FIELD_NAME] = current_timestamp()
if ID_FIELD_NAME not in values:
values[ID_FIELD_NAME] = (
f"{values[SESSION_FIELD_NAME]}:{values[TIMESTAMP_FIELD_NAME]}" ###
f"{values[SESSION_FIELD_NAME]}:{values[TIMESTAMP_FIELD_NAME]}"
)
return values

def to_dict(self) -> Dict:
data = self.dict(exclude_none=True)

# handle optional fields
###if "vector_field" in data:
### data["vector_field"] = array_to_buffer(data["vector_field"])
if SESSION_VECTOR_FIELD_NAME in data:
data[SESSION_VECTOR_FIELD_NAME] = array_to_buffer(
data[SESSION_VECTOR_FIELD_NAME]
Expand Down

0 comments on commit 3e87469

Please sign in to comment.