Skip to content

Commit

Permalink
fix: typo in upstashVector if id is always true, also fix some type h…
Browse files Browse the repository at this point in the history
…int (#11183)

Signed-off-by: yihong0618 <[email protected]>
  • Loading branch information
yihong0618 authored Nov 28, 2024
1 parent 18add94 commit d7160ee
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions api/core/rag/datasource/vdb/upstash/upstash_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def delete_by_ids(self, ids: list[str]) -> None:
item_ids = []
for doc_id in ids:
ids = self.get_ids_by_metadata_field("doc_id", doc_id)
if id:
if ids:
item_ids += ids
self._delete_by_ids(ids=item_ids)

Expand Down Expand Up @@ -95,9 +95,10 @@ def search_by_vector(self, query_vector: list[float], **kwargs: Any) -> list[Doc
metadata = record.metadata
text = record.data
score = record.score
metadata["score"] = score
if score > score_threshold:
docs.append(Document(page_content=text, metadata=metadata))
if metadata is not None and text is not None:
metadata["score"] = score
if score > score_threshold:
docs.append(Document(page_content=text, metadata=metadata))
return docs

def search_by_full_text(self, query: str, **kwargs: Any) -> list[Document]:
Expand All @@ -123,7 +124,7 @@ def init_vector(self, dataset: Dataset, attributes: list, embeddings: Embeddings
return UpstashVector(
collection_name=collection_name,
config=UpstashVectorConfig(
url=dify_config.UPSTASH_VECTOR_URL,
token=dify_config.UPSTASH_VECTOR_TOKEN,
url=dify_config.UPSTASH_VECTOR_URL or "",
token=dify_config.UPSTASH_VECTOR_TOKEN or "",
),
)

0 comments on commit d7160ee

Please sign in to comment.