crewplus 0.2.38__tar.gz → 0.2.39__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of crewplus might be problematic. Click here for more details.
- {crewplus-0.2.38 → crewplus-0.2.39}/PKG-INFO +1 -1
- {crewplus-0.2.38 → crewplus-0.2.39}/crewplus/vectorstores/milvus/schema_milvus.py +53 -20
- {crewplus-0.2.38 → crewplus-0.2.39}/pyproject.toml +1 -1
- {crewplus-0.2.38 → crewplus-0.2.39}/LICENSE +0 -0
- {crewplus-0.2.38 → crewplus-0.2.39}/README.md +0 -0
- {crewplus-0.2.38 → crewplus-0.2.39}/crewplus/__init__.py +0 -0
- {crewplus-0.2.38 → crewplus-0.2.39}/crewplus/services/__init__.py +0 -0
- {crewplus-0.2.38 → crewplus-0.2.39}/crewplus/services/azure_chat_model.py +0 -0
- {crewplus-0.2.38 → crewplus-0.2.39}/crewplus/services/gemini_chat_model.py +0 -0
- {crewplus-0.2.38 → crewplus-0.2.39}/crewplus/services/init_services.py +0 -0
- {crewplus-0.2.38 → crewplus-0.2.39}/crewplus/services/model_load_balancer.py +0 -0
- {crewplus-0.2.38 → crewplus-0.2.39}/crewplus/services/tracing_manager.py +0 -0
- {crewplus-0.2.38 → crewplus-0.2.39}/crewplus/utils/__init__.py +0 -0
- {crewplus-0.2.38 → crewplus-0.2.39}/crewplus/utils/schema_action.py +0 -0
- {crewplus-0.2.38 → crewplus-0.2.39}/crewplus/utils/schema_document_updater.py +0 -0
- {crewplus-0.2.38 → crewplus-0.2.39}/crewplus/vectorstores/milvus/__init__.py +0 -0
- {crewplus-0.2.38 → crewplus-0.2.39}/crewplus/vectorstores/milvus/milvus_schema_manager.py +0 -0
- {crewplus-0.2.38 → crewplus-0.2.39}/crewplus/vectorstores/milvus/vdb_service.py +0 -0
- {crewplus-0.2.38 → crewplus-0.2.39}/docs/GeminiChatModel.md +0 -0
- {crewplus-0.2.38 → crewplus-0.2.39}/docs/ModelLoadBalancer.md +0 -0
- {crewplus-0.2.38 → crewplus-0.2.39}/docs/VDBService.md +0 -0
- {crewplus-0.2.38 → crewplus-0.2.39}/docs/index.md +0 -0
|
@@ -195,26 +195,16 @@ class SchemaMilvus(Milvus):
|
|
|
195
195
|
doc.metadata = existing_metadata
|
|
196
196
|
return doc
|
|
197
197
|
|
|
198
|
-
def
|
|
199
|
-
"""
|
|
200
|
-
Updates the metadata of documents in the Milvus vector store based on the provided expression.
|
|
201
|
-
|
|
202
|
-
Args:
|
|
203
|
-
expr: Expression to filter the target documents.
|
|
204
|
-
metadata: New metadata to update the documents with.
|
|
205
|
-
|
|
206
|
-
Returns:
|
|
207
|
-
List of updated documents.
|
|
208
|
-
"""
|
|
198
|
+
def _prepare_documents_for_update(self, expr: str, metadata: str, action: Action = Action.UPSERT) -> tuple[List[Document], List]:
|
|
209
199
|
try:
|
|
210
200
|
metadata_dict = json.loads(metadata)
|
|
211
201
|
except json.JSONDecodeError:
|
|
212
202
|
raise ValueError("Invalid JSON string for metadata")
|
|
213
|
-
|
|
203
|
+
|
|
214
204
|
# Retrieve documents that match the filter expression.
|
|
215
205
|
fields = self.get_fields()
|
|
216
206
|
documents = self.search_by_metadata(expr, fields=fields, limit=5000)
|
|
217
|
-
|
|
207
|
+
|
|
218
208
|
updated_documents = []
|
|
219
209
|
for doc in documents:
|
|
220
210
|
# Preserve the original primary key and text values.
|
|
@@ -232,7 +222,7 @@ class SchemaMilvus(Milvus):
|
|
|
232
222
|
update_dict = {}
|
|
233
223
|
for key, value in metadata_dict.items():
|
|
234
224
|
if key in existing_metadata:
|
|
235
|
-
if isinstance(value, dict) and isinstance(existing_metadata
|
|
225
|
+
if isinstance(value, dict) and isinstance(existing_metadata.get(key), dict):
|
|
236
226
|
merged = existing_metadata[key].copy()
|
|
237
227
|
for sub_key, sub_value in value.items():
|
|
238
228
|
if sub_key in merged:
|
|
@@ -247,7 +237,7 @@ class SchemaMilvus(Milvus):
|
|
|
247
237
|
if key in ['pk', 'text']:
|
|
248
238
|
continue
|
|
249
239
|
|
|
250
|
-
if isinstance(value, dict) and key in existing_metadata and isinstance(existing_metadata
|
|
240
|
+
if isinstance(value, dict) and key in existing_metadata and isinstance(existing_metadata.get(key), dict):
|
|
251
241
|
existing_metadata[key] = {}
|
|
252
242
|
existing_metadata[key] = value
|
|
253
243
|
else:
|
|
@@ -262,16 +252,59 @@ class SchemaMilvus(Milvus):
|
|
|
262
252
|
|
|
263
253
|
updated_documents.append(doc)
|
|
264
254
|
|
|
255
|
+
if not updated_documents:
|
|
256
|
+
return [], []
|
|
257
|
+
|
|
265
258
|
# Extract the primary keys for the upsert operation.
|
|
266
259
|
updated_ids = [doc.metadata[self.primary_field] for doc in updated_documents]
|
|
267
|
-
|
|
260
|
+
|
|
268
261
|
# Remove primary key and text from metadata before upserting,
|
|
269
262
|
# as they are handled separately by the vector store.
|
|
270
263
|
for doc in updated_documents:
|
|
271
264
|
doc.metadata.pop(self.primary_field, None)
|
|
272
265
|
doc.metadata.pop(self.text_field, None)
|
|
273
|
-
|
|
266
|
+
|
|
267
|
+
return updated_documents, updated_ids
|
|
268
|
+
|
|
269
|
+
def update_documents_metadata(self, expr: str, metadata: str, action: Action = Action.UPSERT) -> List[Document]:
|
|
270
|
+
"""
|
|
271
|
+
Updates the metadata of documents in the Milvus vector store based on the provided expression.
|
|
272
|
+
|
|
273
|
+
Args:
|
|
274
|
+
expr: Expression to filter the target documents.
|
|
275
|
+
metadata: New metadata to update the documents with.
|
|
276
|
+
|
|
277
|
+
Returns:
|
|
278
|
+
List of updated documents.
|
|
279
|
+
"""
|
|
280
|
+
documents_to_upsert, updated_ids = self._prepare_documents_for_update(expr, metadata, action)
|
|
281
|
+
|
|
282
|
+
if not documents_to_upsert:
|
|
283
|
+
return []
|
|
284
|
+
|
|
274
285
|
# Perform the upsert operation to update the documents in the collection.
|
|
275
|
-
self.upsert(ids=updated_ids, documents=
|
|
276
|
-
|
|
277
|
-
return
|
|
286
|
+
self.upsert(ids=updated_ids, documents=documents_to_upsert)
|
|
287
|
+
|
|
288
|
+
return documents_to_upsert
|
|
289
|
+
|
|
290
|
+
async def aupdate_documents_metadata(self, expr: str, metadata: str, action: Action = Action.UPSERT) -> List[Document]:
|
|
291
|
+
"""
|
|
292
|
+
Asynchronously updates the metadata of documents in the Milvus vector store.
|
|
293
|
+
|
|
294
|
+
Args:
|
|
295
|
+
expr: Expression to filter the target documents.
|
|
296
|
+
metadata: New metadata to update the documents with.
|
|
297
|
+
action: The action to perform on the document metadata.
|
|
298
|
+
|
|
299
|
+
Returns:
|
|
300
|
+
List of updated documents.
|
|
301
|
+
"""
|
|
302
|
+
documents_to_upsert, updated_ids = self._prepare_documents_for_update(expr, metadata, action)
|
|
303
|
+
|
|
304
|
+
if not documents_to_upsert:
|
|
305
|
+
return []
|
|
306
|
+
|
|
307
|
+
# Perform the asynchronous upsert operation.
|
|
308
|
+
await self.aupsert(ids=updated_ids, documents=documents_to_upsert)
|
|
309
|
+
|
|
310
|
+
return documents_to_upsert
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|