crewplus 0.2.51__tar.gz → 0.2.53__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.51 → crewplus-0.2.53}/PKG-INFO +1 -1
- {crewplus-0.2.51 → crewplus-0.2.53}/crewplus/vectorstores/milvus/vdb_service.py +23 -2
- {crewplus-0.2.51 → crewplus-0.2.53}/pyproject.toml +1 -1
- {crewplus-0.2.51 → crewplus-0.2.53}/LICENSE +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/README.md +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/crewplus/__init__.py +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/crewplus/callbacks/__init__.py +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/crewplus/callbacks/async_langfuse_handler.py +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/crewplus/services/__init__.py +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/crewplus/services/azure_chat_model.py +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/crewplus/services/gemini_chat_model.py +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/crewplus/services/init_services.py +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/crewplus/services/model_load_balancer.py +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/crewplus/services/tracing_manager.py +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/crewplus/utils/__init__.py +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/crewplus/utils/schema_action.py +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/crewplus/utils/schema_document_updater.py +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/crewplus/vectorstores/milvus/__init__.py +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/crewplus/vectorstores/milvus/milvus_schema_manager.py +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/crewplus/vectorstores/milvus/schema_milvus.py +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/docs/GeminiChatModel.md +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/docs/ModelLoadBalancer.md +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/docs/VDBService.md +0 -0
- {crewplus-0.2.51 → crewplus-0.2.53}/docs/index.md +0 -0
|
@@ -12,6 +12,7 @@ from langchain_openai import AzureOpenAIEmbeddings
|
|
|
12
12
|
from pymilvus import MilvusClient, AsyncMilvusClient
|
|
13
13
|
import time
|
|
14
14
|
import asyncio
|
|
15
|
+
import uuid
|
|
15
16
|
|
|
16
17
|
from ...services.init_services import get_model_balancer
|
|
17
18
|
from .schema_milvus import SchemaMilvus, DEFAULT_SCHEMA
|
|
@@ -24,6 +25,12 @@ class VDBService(object):
|
|
|
24
25
|
This service centralizes the configuration and instantiation of the Milvus client
|
|
25
26
|
and provides helper methods to get embedding functions and vector store instances.
|
|
26
27
|
|
|
28
|
+
This service generates a unique connection `alias` upon initialization. This `alias`
|
|
29
|
+
is propagated to all Milvus clients created by this service, including those
|
|
30
|
+
within `langchain_milvus` instances. This mechanism ensures that a single,
|
|
31
|
+
shared connection is used for all operations, preventing the creation of
|
|
32
|
+
multiple redundant connections and improving resource efficiency.
|
|
33
|
+
|
|
27
34
|
Args:
|
|
28
35
|
settings (dict, optional): A dictionary containing configuration for the vector store
|
|
29
36
|
and embedding models.
|
|
@@ -146,6 +153,14 @@ class VDBService(object):
|
|
|
146
153
|
self.logger.error(msg)
|
|
147
154
|
raise ValueError(msg)
|
|
148
155
|
|
|
156
|
+
# Create separate aliases for sync and async clients to avoid connection handler race conditions.
|
|
157
|
+
self.sync_alias = f"crewplus-vdb-sync-{uuid.uuid4()}"
|
|
158
|
+
self.async_alias = f"crewplus-vdb-async-{uuid.uuid4()}"
|
|
159
|
+
|
|
160
|
+
# The default alias in connection_args should be the sync one, as langchain_milvus
|
|
161
|
+
# primarily uses a synchronous client and will pick up this alias.
|
|
162
|
+
self.connection_args['alias'] = self.sync_alias
|
|
163
|
+
|
|
149
164
|
self._client = self._initialize_milvus_client(provider)
|
|
150
165
|
self._async_client = self._initialize_async_milvus_client(provider)
|
|
151
166
|
|
|
@@ -172,12 +187,15 @@ class VDBService(object):
|
|
|
172
187
|
"uri": uri,
|
|
173
188
|
"user": self.connection_args.get("user"),
|
|
174
189
|
"password": self.connection_args.get("password"),
|
|
175
|
-
"db_name": self.connection_args.get("db_name")
|
|
190
|
+
"db_name": self.connection_args.get("db_name"),
|
|
176
191
|
}
|
|
177
192
|
return {k: v for k, v in client_args.items() if v is not None}
|
|
178
193
|
|
|
179
194
|
elif provider == "zilliz":
|
|
180
|
-
|
|
195
|
+
# Return a copy without the default alias, as it will be added specifically for sync/async clients.
|
|
196
|
+
zilliz_args = self.connection_args.copy()
|
|
197
|
+
zilliz_args.pop('alias', None)
|
|
198
|
+
return zilliz_args
|
|
181
199
|
else:
|
|
182
200
|
self.logger.error(f"Unsupported vector store provider: {provider}")
|
|
183
201
|
raise NotImplementedError(f"Vector store provider '{provider}' is not supported.")
|
|
@@ -187,6 +205,7 @@ class VDBService(object):
|
|
|
187
205
|
Initializes and returns a MilvusClient with a retry mechanism.
|
|
188
206
|
"""
|
|
189
207
|
client_args = self._get_milvus_client_args(provider)
|
|
208
|
+
client_args["alias"] = self.sync_alias
|
|
190
209
|
|
|
191
210
|
try:
|
|
192
211
|
# First attempt to connect
|
|
@@ -205,6 +224,8 @@ class VDBService(object):
|
|
|
205
224
|
Initializes and returns an AsyncMilvusClient with a retry mechanism.
|
|
206
225
|
"""
|
|
207
226
|
client_args = self._get_milvus_client_args(provider)
|
|
227
|
+
client_args["alias"] = self.async_alias
|
|
228
|
+
|
|
208
229
|
try:
|
|
209
230
|
return AsyncMilvusClient(**client_args)
|
|
210
231
|
except Exception as e:
|
|
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
|
|
File without changes
|
|
File without changes
|