Skip to content

Commit a60753e

Browse files
authored
Store connector (#89)
1.knowledge_init.py config update 2.DB_GPT_wechat2
2 parents 55a1f51 + 1ed5ef4 commit a60753e

File tree

5 files changed

+17
-26
lines changed

5 files changed

+17
-26
lines changed

assets/DB_GPT_wechat.png

-99.9 KB
Loading

pilot/configs/config.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ def __init__(self) -> None:
3838
self.use_mac_os_tts = False
3939
self.use_mac_os_tts = os.getenv("USE_MAC_OS_TTS")
4040

41-
# milvus or zilliz cloud configuration
42-
self.milvus_addr = os.getenv("MILVUS_ADDR", "localhost:19530")
43-
self.milvus_username = os.getenv("MILVUS_USERNAME")
44-
self.milvus_password = os.getenv("MILVUS_PASSWORD")
45-
self.milvus_collection = os.getenv("MILVUS_COLLECTION", "dbgpt")
46-
self.milvus_secure = os.getenv("MILVUS_SECURE") == "True"
47-
48-
4941
self.authorise_key = os.getenv("AUTHORISE_COMMAND_KEY", "y")
5042
self.exit_key = os.getenv("EXIT_KEY", "n")
5143
self.image_provider = os.getenv("IMAGE_PROVIDER", True)

pilot/vector_store/milvus_store.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,29 +139,21 @@ def init_schema_and_load(self, vector_name, documents):
139139
fields.append(
140140
FieldSchema(text_field, DataType.VARCHAR, max_length=max_length + 1)
141141
)
142-
# create the primary key field
142+
# primary key field
143143
fields.append(
144144
FieldSchema(primary_field, DataType.INT64, is_primary=True, auto_id=True)
145145
)
146-
# create the vector field
146+
# vector field
147147
fields.append(FieldSchema(vector_field, DataType.FLOAT_VECTOR, dim=dim))
148-
# Create the schema for the collection
148+
# milvus the schema for the collection
149149
schema = CollectionSchema(fields)
150150
# Create the collection
151151
collection = Collection(collection_name, schema)
152152
self.col = collection
153-
# Index parameters for the collection
153+
# index parameters for the collection
154154
index = self.index_params
155-
# Create the index
155+
# milvus index
156156
collection.create_index(vector_field, index)
157-
# Create the VectorStore
158-
# milvus = cls(
159-
# embedding,
160-
# kwargs.get("connection_args", {"port": 19530}),
161-
# collection_name,
162-
# text_field,
163-
# )
164-
# Add the texts.
165157
schema = collection.schema
166158
for x in schema.fields:
167159
self.fields.append(x.name)

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ colorama
6969
playsound
7070
distro
7171
pypdf
72+
milvus-cli==0.3.2
7273

7374
# Testing dependencies
7475
pytest

tools/knowlege_init.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33
import argparse
4+
import os
5+
import sys
46

5-
from pilot.configs.model_config import DATASETS_DIR, LLM_MODEL_CONFIG, VECTOR_SEARCH_TOP_K, VECTOR_STORE_CONFIG, \
6-
VECTOR_STORE_TYPE
7-
from pilot.source_embedding.knowledge_embedding import KnowledgeEmbedding
87

8+
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
9+
10+
from pilot.configs.config import Config
11+
from pilot.configs.model_config import DATASETS_DIR, LLM_MODEL_CONFIG, VECTOR_SEARCH_TOP_K
12+
from pilot.source_embedding.knowledge_embedding import KnowledgeEmbedding
913

14+
CFG = Config()
1015
class LocalKnowledgeInit:
1116
embeddings: object = None
1217
model_name = LLM_MODEL_CONFIG["text2vec"]
@@ -32,6 +37,7 @@ def query(self, q):
3237
dc, s = doc
3338
yield s, dc
3439

40+
3541
if __name__ == "__main__":
3642
parser = argparse.ArgumentParser()
3743
parser.add_argument("--vector_name", type=str, default="default")
@@ -40,8 +46,8 @@ def query(self, q):
4046
args = parser.parse_args()
4147
vector_name = args.vector_name
4248
append_mode = args.append
43-
store_type = VECTOR_STORE_TYPE
44-
vector_store_config = {"url": VECTOR_STORE_CONFIG["url"], "port": VECTOR_STORE_CONFIG["port"], "vector_store_name":vector_name}
49+
store_type = CFG.VECTOR_STORE_TYPE
50+
vector_store_config = {"vector_store_name": vector_name}
4551
print(vector_store_config)
4652
kv = LocalKnowledgeInit(vector_store_config=vector_store_config)
4753
vector_store = kv.knowledge_persist(file_path=DATASETS_DIR, append_mode=append_mode)

0 commit comments

Comments
 (0)