crewplus 0.2.1__py3-none-any.whl → 0.2.3__py3-none-any.whl

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.

@@ -22,17 +22,22 @@ class VDBService(object):
22
22
  and provides helper methods to get embedding functions and vector store instances.
23
23
 
24
24
  Args:
25
- settings (dict): A dictionary containing configuration for the vector store
25
+ settings (dict, optional): A dictionary containing configuration for the vector store
26
26
  and embedding models.
27
+ endpoint (str, optional): The URI for the Zilliz cluster. Can be used for simple
28
+ initialization instead of `settings`.
29
+ token (str, optional): The token for authenticating with Zilliz. Must be provided
30
+ with `endpoint`.
27
31
  schema (str, optional): The schema definition for a collection. Defaults to None.
28
32
  logger (logging.Logger, optional): An optional logger instance. Defaults to None.
29
33
 
30
34
  Raises:
31
- ValueError: If required configurations are missing from the settings dictionary.
35
+ ValueError: If required configurations are missing.
32
36
  NotImplementedError: If an unsupported provider is specified.
33
37
  RuntimeError: If the MilvusClient fails to initialize after a retry.
34
38
 
35
39
  Example:
40
+ >>> # Initialize with a full settings dictionary
36
41
  >>> settings = {
37
42
  ... "embedder": {
38
43
  ... "provider": "azure-openai",
@@ -61,6 +66,10 @@ class VDBService(object):
61
66
  ... }
62
67
  ... }
63
68
  >>> vdb_service = VDBService(settings=settings)
69
+ >>>
70
+ >>> # Alternatively, initialize with an endpoint and token for Zilliz
71
+ >>> # vdb_service_zilliz = VDBService(endpoint="YOUR_ZILLIZ_ENDPOINT", token="YOUR_ZILLIZ_TOKEN")
72
+ >>>
64
73
  >>> # Get the raw Milvus client
65
74
  >>> client = vdb_service.get_vector_client()
66
75
  >>> print(client.list_collections())
@@ -82,17 +91,41 @@ class VDBService(object):
82
91
  connection_args: dict
83
92
  settings: dict
84
93
 
85
- def __init__(self, settings: dict, schema: str = None, logger: logging.Logger = None):
94
+ def __init__(self, settings: dict = None, endpoint: str = None, token: str = None, schema: str = None, logger: logging.Logger = None):
86
95
  """
87
96
  Initializes the VDBService.
97
+
98
+ Can be initialized in two ways:
99
+ 1. By providing a full `settings` dictionary for complex configurations.
100
+ 2. By providing `endpoint` and `token` for a direct Zilliz connection.
101
+ Note: When using this method, an `embedder` configuration is not created.
102
+ You must either use the `ModelLoadBalancer` or pass an `Embeddings` object
103
+ directly to methods like `get_vector_store`.
88
104
 
89
105
  Args:
90
- settings (dict): Configuration dictionary for the service.
106
+ settings (dict, optional): Configuration dictionary for the service. Defaults to None.
107
+ endpoint (str, optional): The URI for the Zilliz cluster. Used if `settings` is not provided.
108
+ token (str, optional): The token for authenticating with the Zilliz cluster.
91
109
  schema (str, optional): Default schema for new collections. Defaults to None.
92
110
  logger (logging.Logger, optional): Logger instance. Defaults to None.
93
111
  """
94
112
  self.logger = logger or logging.getLogger(__name__)
95
- self.settings = settings
113
+
114
+ if settings:
115
+ self.settings = settings
116
+ elif endpoint and token:
117
+ self.logger.info("Initializing VDBService with endpoint and token for a Zilliz connection.")
118
+ self.settings = {
119
+ "vector_store": {
120
+ "provider": "zilliz",
121
+ "config": {
122
+ "uri": endpoint,
123
+ "token": token
124
+ }
125
+ }
126
+ }
127
+ else:
128
+ raise ValueError("VDBService must be initialized with either a 'settings' dictionary or both 'endpoint' and 'token'.")
96
129
 
97
130
  vector_store_settings = self.settings.get("vector_store")
98
131
  if not vector_store_settings:
@@ -257,43 +290,48 @@ class VDBService(object):
257
290
 
258
291
  return vdb
259
292
 
260
- def delete_old_indexes(self, url: str = None, vdb: Zilliz = None) -> None:
293
+ def delete_old_indexes(self, url: str = None, vdb: Zilliz = None) -> (bool | None):
261
294
  """ Delete old indexes of the same source_url
262
295
 
263
296
  Args:
264
297
  url (str): source url
298
+ vdb (Zilliz): Zilliz instance
265
299
  """
300
+ self.logger.info(f"Delete old indexes of the same source_url:{url}")
301
+
266
302
  if url is None or vdb is None:
267
- return
303
+ return None
268
304
 
269
305
  # Delete indexes of the same source_url
270
- expr = "source in [\"" + url + "\"]"
306
+ expr = f'source_url == "{url}" or source == "{url}"'
271
307
  pks = vdb.get_pks(expr)
272
308
 
273
309
  # Delete entities by pks
274
310
  if pks is not None and len(pks) > 0 :
275
- old_items = vdb.delete(pks)
276
- self.logger.info("ingesting document -- delete old indexes -- " + str(old_items))
311
+ res = vdb.delete(pks)
312
+ self.logger.info("Deleted old indexes result: " + str(res))
313
+ return res
277
314
 
278
- def delete_old_indexes_by_id(self, id: str = None, vdb: Zilliz = None) -> None:
315
+ def delete_old_indexes_by_id(self, source_id: str = None, vdb: Zilliz = None) -> (bool | None):
279
316
  """ Delete old indexes of the same source_id
280
317
 
281
318
  Args:
282
- id (str): source id
319
+ source_id (str): source id
283
320
  """
284
- self.logger.info(f"Delete old indexes of the same source_id:{id}")
321
+ self.logger.info(f"Delete old indexes of the same source_id:{source_id}")
285
322
 
286
- if id is None or vdb is None:
287
- return
323
+ if source_id is None or vdb is None:
324
+ return None
288
325
 
289
326
  # Delete indexes of the same source_id
290
- expr = "source_id in [\"" + id + "\"]"
327
+ expr = f'source_id == "{source_id}"'
291
328
  pks = vdb.get_pks(expr)
292
329
 
293
330
  # Delete entities by pks
294
331
  if pks is not None and len(pks) > 0 :
295
- old_items = vdb.delete(pks)
296
- self.logger.info("ingesting document -- delete old indexes -- " + str(old_items))
332
+ res = vdb.delete(pks)
333
+ self.logger.info("Deleted old indexes result: " + str(res))
334
+ return res
297
335
 
298
336
  def drop_collection(self, collection_name: str) -> None:
299
337
  """
@@ -326,12 +364,13 @@ class VDBService(object):
326
364
  self.logger.info(f"Removed '{collection_name}' from instance cache.")
327
365
 
328
366
  def delete_data_by_filter(self, collection_name: str = None, filter: str = None) -> None:
329
- """ Delete a collection
367
+ """ Delete data by filter
330
368
 
331
369
  Args:
332
- collection_name (str): scollection_name
370
+ collection_name (str): collection_name
371
+ filter (str): filter
333
372
  """
334
- self.logger.info(f"drop a collection by name:{collection_name}")
373
+ self.logger.info(f"Delete data by filter:{filter}")
335
374
 
336
375
  try:
337
376
  client=self.get_vector_client()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: crewplus
3
- Version: 0.2.1
3
+ Version: 0.2.3
4
4
  Summary: Base services for CrewPlus AI applications
5
5
  Author-Email: Tim Liu <tim@opsmateai.com>
6
6
  License: MIT
@@ -45,7 +45,7 @@ CrewPlus is designed as a modular and extensible ecosystem of packages. This all
45
45
 
46
46
  - **Chat Services:** A unified interface for interacting with various chat models (e.g., `GeminiChatModel`).
47
47
  - **Model Load Balancer:** Intelligently distribute requests across multiple LLM endpoints.
48
- - **Vector DB Services:** Abstractions for working with popular vector stores for retrieval-augmented generation (RAG).
48
+ - **Vector DB Services:** working with popular vector stores (e.g. Milvus, Zilliz Cloud) for retrieval-augmented generation (RAG) and agent memory.
49
49
 
50
50
 
51
51
  ## Documentation
@@ -1,7 +1,7 @@
1
- crewplus-0.2.1.dist-info/METADATA,sha256=IKVh7qW2mV9NfYXs66enxgcBOk_GTP9xeU3kwI6lysc,4881
2
- crewplus-0.2.1.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
- crewplus-0.2.1.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
- crewplus-0.2.1.dist-info/licenses/LICENSE,sha256=2_NHSHRTKB_cTcT_GXgcenOCtIZku8j343mOgAguTfc,1087
1
+ crewplus-0.2.3.dist-info/METADATA,sha256=3kbzrxbpcbp1zW-lV4j4rYmxnOV5iFiF1oDi5bQ1K-I,4909
2
+ crewplus-0.2.3.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
+ crewplus-0.2.3.dist-info/entry_points.txt,sha256=6OYgBcLyFCUgeqLgnvMyOJxPCWzgy7se4rLPKtNonMs,34
4
+ crewplus-0.2.3.dist-info/licenses/LICENSE,sha256=2_NHSHRTKB_cTcT_GXgcenOCtIZku8j343mOgAguTfc,1087
5
5
  crewplus/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  crewplus/services/__init__.py,sha256=MmH2v3N0ZMsuqFNAupkXENjUqvgf5ehQ99H6EzPqLZU,48
7
7
  crewplus/services/gemini_chat_model.py,sha256=i9p5KvSJYaHSUBLPKM_bpyGVLWCDQoNeah_WjQVJRXs,26227
@@ -12,5 +12,5 @@ crewplus/utils/schema_document_updater.py,sha256=frvffxn2vbi71fHFPoGb9hq7gH2azmm
12
12
  crewplus/vectorstores/milvus/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  crewplus/vectorstores/milvus/milvus_schema_manager.py,sha256=qHMVIM0NS3rLfACb8d3-tQS9hJo6_7_YP8AxVx4t1Cc,9019
14
14
  crewplus/vectorstores/milvus/schema_milvus.py,sha256=GhHTtCH5HsIJc3RHa25RXl3aZdkS3Rba5KeuUk_Hi0k,11425
15
- crewplus/vectorstores/milvus/vdb_service.py,sha256=KiGuHWU9oz2QCCaxGECtN-F69m8ZOwjzPO0umk6ZjzA,14592
16
- crewplus-0.2.1.dist-info/RECORD,,
15
+ crewplus/vectorstores/milvus/vdb_service.py,sha256=J7B6TOZmJl9_K2euJFKJFvSYqvruKbXuYkFiugWnXXs,16657
16
+ crewplus-0.2.3.dist-info/RECORD,,