@@ -83,87 +83,6 @@ def vectordb(self, db_id: str):
8383 print (resp )
8484 raise Exception ("Failed to get db info" )
8585
86- # Create DB
87- def create_db (
88- self ,
89- db_name : str = Field (pattern = r"^[a-zA-Z-0-9]{4,32}$" , strict = True ),
90- db_id : Optional [str ] = None ,
91- project_id : Optional [str ] = "default" ,
92- min_replicas : Optional [int ] = 0 ,
93- max_replicas : Optional [int ] = 1 ,
94- sharding_init_number : Optional [int ] = 1 ,
95- sharding_increase_step : Optional [int ] = 2 ,
96- sharding_capacity : Optional [int ] = 150000 ,
97- sharding_increase_threshold : Optional [float ] = 0.9 ,
98- ):
99- req_url = "{}/vectordb/create" .format (self ._baseurl )
100- req_data = {
101- "db_name" : db_name ,
102- "db_uuid" : db_id ,
103- "project_id" : project_id ,
104- "min_replicas" : min_replicas ,
105- "max_replicas" : max_replicas ,
106- "sharding_init_number" : sharding_init_number ,
107- "sharding_increase_step" : sharding_increase_step ,
108- "sharding_capacity" : sharding_capacity ,
109- "sharding_increase_threshold" : sharding_increase_threshold ,
110- }
111- resp = requests .post (
112- url = req_url ,
113- data = json .dumps (req_data ),
114- headers = self ._header ,
115- verify = False ,
116- )
117- status_code = resp .status_code
118- body = resp .json ()
119- resp .close ()
120- return status_code , body
121-
122- # Load DB
123- def load_db (self , db_id : str ):
124- req_url = "{}/vectordb/{}/load" .format (self ._baseurl , db_id )
125- req_data = {}
126- resp = requests .post (
127- url = req_url ,
128- data = json .dumps (req_data ),
129- headers = self ._header ,
130- verify = False ,
131- )
132- status_code = resp .status_code
133- body = resp .json ()
134- resp .close ()
135- return status_code , body
136-
137- # Unload DB
138- def unload_db (self , db_id : str ):
139- req_url = "{}/vectordb/{}/unload" .format (self ._baseurl , db_id )
140- req_data = {}
141- resp = requests .post (
142- url = req_url ,
143- data = json .dumps (req_data ),
144- headers = self ._header ,
145- verify = False ,
146- )
147- status_code = resp .status_code
148- body = resp .json ()
149- resp .close ()
150- return status_code , body
151-
152- # Delete DB
153- def drop_db (self , db_id : str ):
154- req_url = "{}/vectordb/{}" .format (self ._baseurl , db_id )
155- req_data = {}
156- resp = requests .delete (
157- url = req_url ,
158- data = json .dumps (req_data ),
159- headers = self ._header ,
160- verify = False ,
161- )
162- status_code = resp .status_code
163- body = resp .json ()
164- resp .close ()
165- return status_code , body
166-
16786
16887class Vectordb (Client ):
16988 def __init__ (self , project_id : str , db_id : str , api_key : str , public_endpoint : str ):
0 commit comments