crewplus 0.2.53__tar.gz → 0.2.54__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 (24) hide show
  1. {crewplus-0.2.53 → crewplus-0.2.54}/PKG-INFO +1 -1
  2. {crewplus-0.2.53 → crewplus-0.2.54}/crewplus/vectorstores/milvus/vdb_service.py +43 -12
  3. {crewplus-0.2.53 → crewplus-0.2.54}/pyproject.toml +1 -1
  4. {crewplus-0.2.53 → crewplus-0.2.54}/LICENSE +0 -0
  5. {crewplus-0.2.53 → crewplus-0.2.54}/README.md +0 -0
  6. {crewplus-0.2.53 → crewplus-0.2.54}/crewplus/__init__.py +0 -0
  7. {crewplus-0.2.53 → crewplus-0.2.54}/crewplus/callbacks/__init__.py +0 -0
  8. {crewplus-0.2.53 → crewplus-0.2.54}/crewplus/callbacks/async_langfuse_handler.py +0 -0
  9. {crewplus-0.2.53 → crewplus-0.2.54}/crewplus/services/__init__.py +0 -0
  10. {crewplus-0.2.53 → crewplus-0.2.54}/crewplus/services/azure_chat_model.py +0 -0
  11. {crewplus-0.2.53 → crewplus-0.2.54}/crewplus/services/gemini_chat_model.py +0 -0
  12. {crewplus-0.2.53 → crewplus-0.2.54}/crewplus/services/init_services.py +0 -0
  13. {crewplus-0.2.53 → crewplus-0.2.54}/crewplus/services/model_load_balancer.py +0 -0
  14. {crewplus-0.2.53 → crewplus-0.2.54}/crewplus/services/tracing_manager.py +0 -0
  15. {crewplus-0.2.53 → crewplus-0.2.54}/crewplus/utils/__init__.py +0 -0
  16. {crewplus-0.2.53 → crewplus-0.2.54}/crewplus/utils/schema_action.py +0 -0
  17. {crewplus-0.2.53 → crewplus-0.2.54}/crewplus/utils/schema_document_updater.py +0 -0
  18. {crewplus-0.2.53 → crewplus-0.2.54}/crewplus/vectorstores/milvus/__init__.py +0 -0
  19. {crewplus-0.2.53 → crewplus-0.2.54}/crewplus/vectorstores/milvus/milvus_schema_manager.py +0 -0
  20. {crewplus-0.2.53 → crewplus-0.2.54}/crewplus/vectorstores/milvus/schema_milvus.py +0 -0
  21. {crewplus-0.2.53 → crewplus-0.2.54}/docs/GeminiChatModel.md +0 -0
  22. {crewplus-0.2.53 → crewplus-0.2.54}/docs/ModelLoadBalancer.md +0 -0
  23. {crewplus-0.2.53 → crewplus-0.2.54}/docs/VDBService.md +0 -0
  24. {crewplus-0.2.53 → crewplus-0.2.54}/docs/index.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: crewplus
3
- Version: 0.2.53
3
+ Version: 0.2.54
4
4
  Summary: Base services for CrewPlus AI applications
5
5
  Author-Email: Tim Liu <tim@opsmateai.com>
6
6
  License: MIT
@@ -95,6 +95,7 @@ class VDBService(object):
95
95
  _client: MilvusClient
96
96
  _async_client: AsyncMilvusClient
97
97
  _instances: Dict[str, Milvus] = {}
98
+ _async_instances: Dict[str, Milvus] = {}
98
99
 
99
100
  schema: str
100
101
  embedding_function: Embeddings
@@ -255,6 +256,30 @@ class VDBService(object):
255
256
  """
256
257
  return self._async_client
257
258
 
259
+ def get_vector_field(self, collection_name: str) -> str:
260
+ """
261
+ Retrieves the vector field name for a given collection from a cached instance.
262
+
263
+ Args:
264
+ collection_name (str): The name of the collection.
265
+
266
+ Returns:
267
+ str: The name of the vector field.
268
+
269
+ Raises:
270
+ ValueError: If no cached instance is found for the collection.
271
+ """
272
+ if collection_name in self._instances:
273
+ return self._instances[collection_name]._vector_field
274
+ if collection_name in self._async_instances:
275
+ return self._async_instances[collection_name]._vector_field
276
+
277
+ self.logger.warning(f"No cached instance found for collection '{collection_name}' to get vector field. Creating a temporary sync instance.")
278
+ # As a fallback, create a temporary sync instance to fetch the schema info.
279
+ # This is less efficient but ensures the method is robust.
280
+ temp_instance = self.get_vector_store(collection_name)
281
+ return temp_instance._vector_field
282
+
258
283
  def get_embeddings(self, from_model_balancer: bool = False, provider: Optional[str] = "azure-openai", model_type: Optional[str] = "embedding-large") -> Embeddings:
259
284
  """
260
285
  Gets an embedding function, either from the model balancer or directly from settings.
@@ -482,21 +507,21 @@ class VDBService(object):
482
507
  raise ValueError("collection_name must be provided.")
483
508
 
484
509
  check_existence = True
485
- if collection_name in self._instances:
486
- instance = self._instances[collection_name]
510
+ if collection_name in self._async_instances:
511
+ instance = self._async_instances[collection_name]
487
512
  is_connected, collection_exists = await self._ais_good_connection(instance, collection_name)
488
513
 
489
514
  if is_connected and collection_exists:
490
- self.logger.info(f"Returning existing vector store instance for collection: {collection_name}")
515
+ self.logger.info(f"Returning existing async vector store instance for collection: {collection_name}")
491
516
  return instance
492
517
 
493
- self.logger.warning(f"Cached instance for '{collection_name}' is invalid. Removing it from cache.")
494
- del self._instances[collection_name]
518
+ self.logger.warning(f"Cached async instance for '{collection_name}' is invalid. Removing it from cache.")
519
+ del self._async_instances[collection_name]
495
520
 
496
521
  if is_connected and not collection_exists:
497
522
  check_existence = False
498
523
 
499
- self.logger.info(f"Creating new vector store instance for collection: {collection_name}")
524
+ self.logger.info(f"Creating new async vector store instance for collection: {collection_name}")
500
525
  if embeddings is None:
501
526
  embeddings = self.get_embeddings()
502
527
 
@@ -519,28 +544,34 @@ class VDBService(object):
519
544
  "params": {}
520
545
  }
521
546
 
547
+ # Prepare connection args with the specific async alias
548
+ async_connection_args = self.connection_args.copy()
549
+ async_connection_args["alias"] = self.async_alias
550
+
522
551
  vdb = await asyncio.to_thread(
523
552
  self._create_milvus_instance_with_retry,
524
553
  collection_name=collection_name,
525
554
  embeddings=embeddings,
526
- index_params=index_params
555
+ index_params=index_params,
556
+ connection_args=async_connection_args
527
557
  )
528
558
 
529
- self._instances[collection_name] = vdb
559
+ self._async_instances[collection_name] = vdb
530
560
 
531
561
  return vdb
532
562
 
533
- def _create_milvus_instance_with_retry(self, collection_name: str, embeddings: Embeddings, index_params: dict) -> Milvus:
563
+ def _create_milvus_instance_with_retry(self, collection_name: str, embeddings: Embeddings, index_params: dict, connection_args: Optional[dict] = None) -> Milvus:
534
564
  """
535
565
  Creates a Milvus instance with a retry mechanism for connection failures.
536
566
  """
537
567
  retries = 2
568
+ conn_args = connection_args if connection_args is not None else self.connection_args
538
569
  for attempt in range(retries + 1):
539
570
  try:
540
571
  vdb = Milvus(
541
572
  embedding_function=embeddings,
542
573
  collection_name=collection_name,
543
- connection_args=self.connection_args,
574
+ connection_args=conn_args,
544
575
  index_params=index_params
545
576
  )
546
577
  self.logger.info(f"Successfully connected to Milvus for collection '{collection_name}' on attempt {attempt + 1}.")
@@ -612,8 +643,8 @@ class VDBService(object):
612
643
  raise RuntimeError(f"An error occurred while dropping collection '{collection_name}' asynchronously.") from e
613
644
  finally:
614
645
  # Whether successful or not, remove the stale instance from the cache.
615
- if collection_name in self._instances:
616
- del self._instances[collection_name]
646
+ if collection_name in self._async_instances:
647
+ del self._async_instances[collection_name]
617
648
  self.logger.info(f"Removed '{collection_name}' from instance cache.")
618
649
 
619
650
  def delete_data_by_filter(self, collection_name: str = None, filter: str = None) -> None:
@@ -6,7 +6,7 @@ build-backend = "pdm.backend"
6
6
 
7
7
  [project]
8
8
  name = "crewplus"
9
- version = "0.2.53"
9
+ version = "0.2.54"
10
10
  description = "Base services for CrewPlus AI applications"
11
11
  authors = [
12
12
  { name = "Tim Liu", email = "tim@opsmateai.com" },
File without changes
File without changes
File without changes
File without changes