mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-07 11:23:40 +00:00
commit
02bea46c9a
@ -10,7 +10,8 @@
|
||||
</a>
|
||||
</p>
|
||||
|
||||
[**简体中文**](README.zh.md)|[**Discord**](https://discord.gg/xfNDzZ9t)
|
||||
[**简体中文**](README.zh.md) |[**Discord**](https://discord.gg/xfNDzZ9t) |[**Documents**](https://db-gpt.readthedocs.io/en/latest/)
|
||||
|
||||
</div>
|
||||
|
||||
## What is DB-GPT?
|
||||
|
@ -9,7 +9,7 @@
|
||||
</a>
|
||||
</p>
|
||||
|
||||
[**English**](README.md)|[**Discord**](https://discord.gg/ea6BnZkY)
|
||||
[**English**](README.md)|[**Discord**](https://discord.gg/ea6BnZkY) |[**Documents**](https://db-gpt.readthedocs.io/projects/db-gpt-docs-zh-cn/zh_CN/latest/)
|
||||
</div>
|
||||
|
||||
## DB-GPT 是什么?
|
||||
|
@ -26,9 +26,7 @@ class WeaviateStore(VectorStoreBase):
|
||||
KNOWLEDGE_UPLOAD_ROOT_PATH, ctx["vector_store_name"] + ".vectordb"
|
||||
)
|
||||
|
||||
self.vector_store_client = weaviate.Client(
|
||||
self.weaviate_url
|
||||
)
|
||||
self.vector_store_client = weaviate.Client(self.weaviate_url)
|
||||
|
||||
def similar_search(self, text: str, topk: int) -> None:
|
||||
"""Perform similar search in Weaviate"""
|
||||
@ -37,8 +35,13 @@ class WeaviateStore(VectorStoreBase):
|
||||
"concepts": [text],
|
||||
"distance": 0.75, # prior to v1.14 use "certainty" instead of "distance"
|
||||
}
|
||||
response = (self.vector_store_client.query.get("Document", ["metadata", "text"]).with_near_vector(
|
||||
{"vector": nearText}).with_limit(topk).with_additional(["distance"]).do())
|
||||
response = (
|
||||
self.vector_store_client.query.get("Document", ["metadata", "text"])
|
||||
.with_near_vector({"vector": nearText})
|
||||
.with_limit(topk)
|
||||
.with_additional(["distance"])
|
||||
.do()
|
||||
)
|
||||
|
||||
return json.dumps(response, indent=2)
|
||||
|
||||
@ -61,25 +64,37 @@ class WeaviateStore(VectorStoreBase):
|
||||
{
|
||||
"class": "Document",
|
||||
"description": "A document with metadata and text",
|
||||
"moduleConfig": {"text2vec-transformers": {"poolingStrategy": "masked_mean", "vectorizeClassName": False}
|
||||
},
|
||||
"moduleConfig": {
|
||||
"text2vec-transformers": {
|
||||
"poolingStrategy": "masked_mean",
|
||||
"vectorizeClassName": False,
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"dataType": ["text"],
|
||||
"moduleConfig": {
|
||||
"text2vec-transformers": {"skip": False, "vectorizePropertyName": False}},
|
||||
"text2vec-transformers": {
|
||||
"skip": False,
|
||||
"vectorizePropertyName": False,
|
||||
}
|
||||
},
|
||||
"description": "Metadata of the document",
|
||||
"name": "metadata"
|
||||
"name": "metadata",
|
||||
},
|
||||
{
|
||||
"dataType": ["text"],
|
||||
"moduleConfig": {
|
||||
"text2vec-transformers": {"skip": False, "vectorizePropertyName": False}},
|
||||
"text2vec-transformers": {
|
||||
"skip": False,
|
||||
"vectorizePropertyName": False,
|
||||
}
|
||||
},
|
||||
"description": "Text content of the document",
|
||||
"name": "text"
|
||||
}
|
||||
"name": "text",
|
||||
},
|
||||
],
|
||||
"vectorizer": "text2vec-transformers"
|
||||
"vectorizer": "text2vec-transformers",
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -99,10 +114,6 @@ class WeaviateStore(VectorStoreBase):
|
||||
|
||||
# Batch import all documents
|
||||
for i in range(len(texts)):
|
||||
properties = {
|
||||
"metadata": metadatas[i],
|
||||
"text": texts[i]
|
||||
}
|
||||
properties = {"metadata": metadatas[i], "text": texts[i]}
|
||||
|
||||
self.vector_store_client.batch.add_data_object(
|
||||
properties, "Document")
|
||||
self.vector_store_client.batch.add_data_object(properties, "Document")
|
||||
|
Loading…
Reference in New Issue
Block a user