mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-27 08:58:48 +00:00
community[patch]: Adding validation when vector does not exist (#19698)
Adding validation when vector does not exist Co-authored-by: gaoyuan <gaoyuan.20001218@bytedance.com>
This commit is contained in:
parent
f55b11fb73
commit
688ca48019
@ -289,9 +289,13 @@ class VikingDB(VectorStore):
|
|||||||
|
|
||||||
ret = []
|
ret = []
|
||||||
for item in res:
|
for item in res:
|
||||||
item.fields.pop("primary_key")
|
if "primary_key" in item.fields:
|
||||||
item.fields.pop("vector")
|
item.fields.pop("primary_key")
|
||||||
page_content = item.fields.pop("text")
|
if "vector" in item.fields:
|
||||||
|
item.fields.pop("vector")
|
||||||
|
page_content = ""
|
||||||
|
if "text" in item.fields:
|
||||||
|
page_content = item.fields.pop("text")
|
||||||
doc = Document(page_content=page_content, metadata=item.fields)
|
doc = Document(page_content=page_content, metadata=item.fields)
|
||||||
pair = (doc, item.score)
|
pair = (doc, item.score)
|
||||||
ret.append(pair)
|
ret.append(pair)
|
||||||
@ -351,6 +355,12 @@ class VikingDB(VectorStore):
|
|||||||
documents = []
|
documents = []
|
||||||
ordered_result_embeddings = []
|
ordered_result_embeddings = []
|
||||||
for item in res:
|
for item in res:
|
||||||
|
if (
|
||||||
|
"vector" not in item.fields
|
||||||
|
or "primary_key" not in item.fields
|
||||||
|
or "text" not in item.fields
|
||||||
|
):
|
||||||
|
continue
|
||||||
ordered_result_embeddings.append(item.fields.pop("vector"))
|
ordered_result_embeddings.append(item.fields.pop("vector"))
|
||||||
item.fields.pop("primary_key")
|
item.fields.pop("primary_key")
|
||||||
page_content = item.fields.pop("text")
|
page_content = item.fields.pop("text")
|
||||||
|
Loading…
Reference in New Issue
Block a user