mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-22 14:49:29 +00:00
Improve weaviate vectorstore docs (#5201)
# Improve weaviate vectorstore docs
This commit is contained in:
parent
fd866d1801
commit
b00c77dc62
File diff suppressed because one or more lines are too long
@ -322,12 +322,24 @@ class Weaviate(VectorStore):
|
|||||||
if kwargs.get("search_distance"):
|
if kwargs.get("search_distance"):
|
||||||
content["certainty"] = kwargs.get("search_distance")
|
content["certainty"] = kwargs.get("search_distance")
|
||||||
query_obj = self._client.query.get(self._index_name, self._query_attrs)
|
query_obj = self._client.query.get(self._index_name, self._query_attrs)
|
||||||
result = (
|
|
||||||
query_obj.with_near_text(content)
|
if not self._by_text:
|
||||||
.with_limit(k)
|
embedding = self._embedding.embed_query(query)
|
||||||
.with_additional("vector")
|
vector = {"vector": embedding}
|
||||||
.do()
|
result = (
|
||||||
)
|
query_obj.with_near_vector(vector)
|
||||||
|
.with_limit(k)
|
||||||
|
.with_additional("vector")
|
||||||
|
.do()
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
result = (
|
||||||
|
query_obj.with_near_text(content)
|
||||||
|
.with_limit(k)
|
||||||
|
.with_additional("vector")
|
||||||
|
.do()
|
||||||
|
)
|
||||||
|
|
||||||
if "errors" in result:
|
if "errors" in result:
|
||||||
raise ValueError(f"Error during query: {result['errors']}")
|
raise ValueError(f"Error during query: {result['errors']}")
|
||||||
|
|
||||||
@ -436,6 +448,15 @@ class Weaviate(VectorStore):
|
|||||||
|
|
||||||
batch.flush()
|
batch.flush()
|
||||||
|
|
||||||
|
relevance_score_fn = kwargs.get("relevance_score_fn")
|
||||||
|
by_text: bool = kwargs.get("by_text", False)
|
||||||
|
|
||||||
return cls(
|
return cls(
|
||||||
client, index_name, text_key, embedding=embedding, attributes=attributes
|
client,
|
||||||
|
index_name,
|
||||||
|
text_key,
|
||||||
|
embedding=embedding,
|
||||||
|
attributes=attributes,
|
||||||
|
relevance_score_fn=relevance_score_fn,
|
||||||
|
by_text=by_text,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user