fixed formatting

This commit is contained in:
Ofer Mendelevitch 2023-08-19 16:51:53 -07:00
parent 47a6b4d674
commit 90fd840fb1
2 changed files with 9 additions and 7 deletions

View File

@ -311,9 +311,9 @@ class Vectara(VectorStore):
metadatas = []
for x in responses:
md = { m["name"]: m["value"] for m in x["metadata"] }
doc_num = x['documentIndex']
doc_md = { m["name"]: m["value"] for m in documents[doc_num]['metadata'] }
md = {m["name"]: m["value"] for m in x["metadata"]}
doc_num = x["documentIndex"]
doc_md = {m["name"]: m["value"] for m in documents[doc_num]["metadata"]}
md.update(doc_md)
metadatas.append(md)
@ -325,7 +325,7 @@ class Vectara(VectorStore):
),
x["score"],
)
for x,md in zip(responses,metadatas)
for x, md in zip(responses, metadatas)
]
return docs

View File

@ -14,6 +14,7 @@ from tests.integration_tests.vectorstores.fake_embeddings import FakeEmbeddings
# VECTARA_API_KEY, VECTARA_CORPUS_ID and VECTARA_CUSTOMER_ID
#
def get_abbr(s: str) -> str:
words = s.split(" ") # Split the string into words
first_letters = [word[0] for word in words] # Extract the first letter of each word
@ -51,9 +52,9 @@ def test_vectara_add_documents() -> None:
)
assert len(output1) == 2
assert output1[0].page_content == "large language model"
assert output1[0].metadata['abbr'] == "llm"
assert output1[0].metadata["abbr"] == "llm"
assert output1[1].page_content == "information retrieval"
assert output1[1].metadata['abbr'] == "ir"
assert output1[1].metadata["abbr"] == "ir"
# test with metadata filter (doc level)
# since the query does not match test_num=1 directly we get RAG as the matching result
@ -65,11 +66,12 @@ def test_vectara_add_documents() -> None:
)
assert len(output2) == 1
assert output2[0].page_content == "retrieval augmented generation"
assert output2[0].metadata['abbr'] == "rag"
assert output2[0].metadata["abbr"] == "rag"
for doc_id in doc_ids:
docsearch._delete_doc(doc_id)
def test_vectara_from_files() -> None:
"""Test end to end construction and search."""