crewplus 0.2.37__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.

Files changed (22) hide show
  1. {crewplus-0.2.37 → crewplus-0.2.39}/PKG-INFO +2 -1
  2. {crewplus-0.2.37 → crewplus-0.2.39}/crewplus/services/gemini_chat_model.py +7 -4
  3. {crewplus-0.2.37 → crewplus-0.2.39}/crewplus/vectorstores/milvus/schema_milvus.py +53 -20
  4. {crewplus-0.2.37 → crewplus-0.2.39}/pyproject.toml +2 -1
  5. {crewplus-0.2.37 → crewplus-0.2.39}/LICENSE +0 -0
  6. {crewplus-0.2.37 → crewplus-0.2.39}/README.md +0 -0
  7. {crewplus-0.2.37 → crewplus-0.2.39}/crewplus/__init__.py +0 -0
  8. {crewplus-0.2.37 → crewplus-0.2.39}/crewplus/services/__init__.py +0 -0
  9. {crewplus-0.2.37 → crewplus-0.2.39}/crewplus/services/azure_chat_model.py +0 -0
  10. {crewplus-0.2.37 → crewplus-0.2.39}/crewplus/services/init_services.py +0 -0
  11. {crewplus-0.2.37 → crewplus-0.2.39}/crewplus/services/model_load_balancer.py +0 -0
  12. {crewplus-0.2.37 → crewplus-0.2.39}/crewplus/services/tracing_manager.py +0 -0
  13. {crewplus-0.2.37 → crewplus-0.2.39}/crewplus/utils/__init__.py +0 -0
  14. {crewplus-0.2.37 → crewplus-0.2.39}/crewplus/utils/schema_action.py +0 -0
  15. {crewplus-0.2.37 → crewplus-0.2.39}/crewplus/utils/schema_document_updater.py +0 -0
  16. {crewplus-0.2.37 → crewplus-0.2.39}/crewplus/vectorstores/milvus/__init__.py +0 -0
  17. {crewplus-0.2.37 → crewplus-0.2.39}/crewplus/vectorstores/milvus/milvus_schema_manager.py +0 -0
  18. {crewplus-0.2.37 → crewplus-0.2.39}/crewplus/vectorstores/milvus/vdb_service.py +0 -0
  19. {crewplus-0.2.37 → crewplus-0.2.39}/docs/GeminiChatModel.md +0 -0
  20. {crewplus-0.2.37 → crewplus-0.2.39}/docs/ModelLoadBalancer.md +0 -0
  21. {crewplus-0.2.37 → crewplus-0.2.39}/docs/VDBService.md +0 -0
  22. {crewplus-0.2.37 → crewplus-0.2.39}/docs/index.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: crewplus
3
- Version: 0.2.37
3
+ Version: 0.2.39
4
4
  Summary: Base services for CrewPlus AI applications
5
5
  Author-Email: Tim Liu <tim@opsmateai.com>
6
6
  License: MIT
@@ -15,6 +15,7 @@ Requires-Dist: google-genai>=1.21.1
15
15
  Requires-Dist: langchain-milvus<0.3.0,>=0.2.1
16
16
  Requires-Dist: langfuse<4.0.0,>=3.1.3
17
17
  Requires-Dist: langchain-mcp-adapters>=0.1.4
18
+ Requires-Dist: protobuf<6.0,>=5.27
18
19
  Description-Content-Type: text/markdown
19
20
 
20
21
  # CrewPlus
@@ -678,10 +678,13 @@ class GeminiChatModel(BaseChatModel):
678
678
  "thoughts_tokens": thoughts_tokens,
679
679
  "total_tokens": total_tokens,
680
680
  }
681
- if input_details:
682
- final_metadata["input_token_details"] = input_details
683
- if output_details:
684
- final_metadata["output_token_details"] = output_details
681
+
682
+ ## COMMENTED BEGIN: This is not working as expected.
683
+ # if input_details:
684
+ # final_metadata["input_token_details"] = input_details
685
+ # if output_details:
686
+ # final_metadata["output_token_details"] = output_details
687
+ ## COMMENTED END
685
688
 
686
689
  return final_metadata
687
690
 
@@ -195,26 +195,16 @@ class SchemaMilvus(Milvus):
195
195
  doc.metadata = existing_metadata
196
196
  return doc
197
197
 
198
- def update_documents_metadata(self, expr: str, metadata: str,action:Action=Action.UPSERT) -> List[Document]:
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[key], dict):
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[key], dict):
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=updated_documents)
276
-
277
- return updated_documents
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
@@ -6,7 +6,7 @@ build-backend = "pdm.backend"
6
6
 
7
7
  [project]
8
8
  name = "crewplus"
9
- version = "0.2.37"
9
+ version = "0.2.39"
10
10
  description = "Base services for CrewPlus AI applications"
11
11
  authors = [
12
12
  { name = "Tim Liu", email = "tim@opsmateai.com" },
@@ -20,6 +20,7 @@ dependencies = [
20
20
  "langchain-milvus (>=0.2.1,<0.3.0)",
21
21
  "langfuse (>=3.1.3,<4.0.0)",
22
22
  "langchain-mcp-adapters>=0.1.4",
23
+ "protobuf (>=5.27,<6.0)",
23
24
  ]
24
25
 
25
26
  [project.license]
File without changes
File without changes
File without changes
File without changes