crewplus 0.2.2__tar.gz → 0.2.3__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: crewplus
3
- Version: 0.2.2
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
@@ -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:
@@ -262,6 +295,7 @@ class VDBService(object):
262
295
 
263
296
  Args:
264
297
  url (str): source url
298
+ vdb (Zilliz): Zilliz instance
265
299
  """
266
300
  self.logger.info(f"Delete old indexes of the same source_url:{url}")
267
301
 
@@ -269,7 +303,7 @@ class VDBService(object):
269
303
  return None
270
304
 
271
305
  # Delete indexes of the same source_url
272
- expr = "source in [\"" + url + "\"]"
306
+ expr = f'source_url == "{url}" or source == "{url}"'
273
307
  pks = vdb.get_pks(expr)
274
308
 
275
309
  # Delete entities by pks
@@ -278,19 +312,19 @@ class VDBService(object):
278
312
  self.logger.info("Deleted old indexes result: " + str(res))
279
313
  return res
280
314
 
281
- def delete_old_indexes_by_id(self, id: str = None, vdb: Zilliz = None) -> (bool | None):
315
+ def delete_old_indexes_by_id(self, source_id: str = None, vdb: Zilliz = None) -> (bool | None):
282
316
  """ Delete old indexes of the same source_id
283
317
 
284
318
  Args:
285
- id (str): source id
319
+ source_id (str): source id
286
320
  """
287
- 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}")
288
322
 
289
- if id is None or vdb is None:
323
+ if source_id is None or vdb is None:
290
324
  return None
291
325
 
292
326
  # Delete indexes of the same source_id
293
- expr = "source_id in [\"" + id + "\"]"
327
+ expr = f'source_id == "{source_id}"'
294
328
  pks = vdb.get_pks(expr)
295
329
 
296
330
  # Delete entities by pks
@@ -6,7 +6,7 @@ build-backend = "pdm.backend"
6
6
 
7
7
  [project]
8
8
  name = "crewplus"
9
- version = "0.2.2"
9
+ version = "0.2.3"
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