Skip to content

Commit

Permalink
addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
eavanvalkenburg committed Nov 14, 2024
1 parent 62c0161 commit 0596755
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
6 changes: 4 additions & 2 deletions python/samples/concepts/memory/new_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ class DataModelArray:
deserialize_function=np.array,
),
] = None
other: str | None = None
id: Annotated[str, VectorStoreRecordKeyField()] = field(default_factory=lambda: str(uuid4()))
content: Annotated[
str, VectorStoreRecordDataField(has_embedding=True, embedding_property_name="vector", property_type="str")
] = "content1"
title: Annotated[str, VectorStoreRecordDataField(property_type="str", is_full_text_searchable=True)] = "title"
tag: Annotated[str, VectorStoreRecordDataField(property_type="str", is_filterable=True)] = "tag"

return DataModelArray

Expand All @@ -77,11 +78,12 @@ class DataModelList:
property_type="float",
),
] = None
other: str | None = None
id: Annotated[str, VectorStoreRecordKeyField()] = field(default_factory=lambda: str(uuid4()))
content: Annotated[
str, VectorStoreRecordDataField(has_embedding=True, embedding_property_name="vector", property_type="str")
] = "content1"
title: Annotated[str, VectorStoreRecordDataField(property_type="str", is_full_text_searchable=True)] = "title"
tag: Annotated[str, VectorStoreRecordDataField(property_type="str", is_filterable=True)] = "tag"

return DataModelList

Expand Down
23 changes: 13 additions & 10 deletions python/semantic_kernel/connectors/memory/azure_ai_search/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,21 @@ def data_model_definition_to_azure_ai_search_index(
try:
algo_class, algo_params = INDEX_ALGORITHM_MAP[field.index_kind or "default"]
except KeyError as e:
raise ServiceInitializationError(f"Error: {e} not found in INDEX_ALGORITHM_MAP.") from e
raise ServiceInitializationError(f"Error: {field.index_kind} not found in INDEX_ALGORITHM_MAP.") from e
try:
search_algos.append(
algo_class(
name=algo_name,
parameters=algo_params(
metric=DISTANCE_FUNCTION_MAP[field.distance_function or "default"],
),
)
)
distance_metric = DISTANCE_FUNCTION_MAP[field.distance_function or "default"]
except KeyError as e:
raise ServiceInitializationError(f"Error: {e} not found in DISTANCE_FUNCTION_MAP.") from e
raise ServiceInitializationError(
f"Error: {field.distance_function} not found in DISTANCE_FUNCTION_MAP."
) from e
search_algos.append(
algo_class(
name=algo_name,
parameters=algo_params(
metric=distance_metric,
),
)
)
return SearchIndex(
name=collection_name,
fields=fields,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,18 +467,14 @@ def _serialize_dicts_to_store_models(
def _deserialize_store_models_to_dicts(
self,
records: Sequence[dict[str, Any]],
keys: Sequence[str] | None = None,
**kwargs: Any,
) -> Sequence[dict[str, Any]]:
key_field_name = self.data_model_definition.key_field_name
if keys is None:
if key_field_name in records[0]:
return records
raise MemoryConnectorException("Key field not found in records, and not supplied.")
results = []
for key, record in zip(keys, records):
record[self.data_model_definition.key_field_name] = self._unget_redis_key(key)
results.append(record)
key_field_name = self.data_model_definition.key_field_name
for record in records:
rec = record.copy()
rec[key_field_name] = self._unget_redis_key(record[key_field_name])
results.append(rec)
return results

def _add_return_fields(self, query: TQuery, include_vectors: bool) -> TQuery:
Expand Down

0 comments on commit 0596755

Please sign in to comment.