crewplus 0.2.29__tar.gz → 0.2.31__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.29 → crewplus-0.2.31}/PKG-INFO +4 -4
- {crewplus-0.2.29 → crewplus-0.2.31}/crewplus/services/__init__.py +0 -1
- {crewplus-0.2.29 → crewplus-0.2.31}/crewplus/services/model_load_balancer.py +23 -6
- {crewplus-0.2.29 → crewplus-0.2.31}/crewplus/vectorstores/milvus/__init__.py +1 -1
- {crewplus-0.2.29 → crewplus-0.2.31}/pyproject.toml +4 -4
- {crewplus-0.2.29 → crewplus-0.2.31}/LICENSE +0 -0
- {crewplus-0.2.29 → crewplus-0.2.31}/README.md +0 -0
- {crewplus-0.2.29 → crewplus-0.2.31}/crewplus/__init__.py +0 -0
- {crewplus-0.2.29 → crewplus-0.2.31}/crewplus/services/azure_chat_model.py +0 -0
- {crewplus-0.2.29 → crewplus-0.2.31}/crewplus/services/gemini_chat_model.py +0 -0
- {crewplus-0.2.29 → crewplus-0.2.31}/crewplus/services/init_services.py +0 -0
- {crewplus-0.2.29 → crewplus-0.2.31}/crewplus/services/tracing_manager.py +0 -0
- {crewplus-0.2.29 → crewplus-0.2.31}/crewplus/utils/__init__.py +0 -0
- {crewplus-0.2.29 → crewplus-0.2.31}/crewplus/utils/schema_action.py +0 -0
- {crewplus-0.2.29 → crewplus-0.2.31}/crewplus/utils/schema_document_updater.py +0 -0
- {crewplus-0.2.29 → crewplus-0.2.31}/crewplus/vectorstores/milvus/milvus_schema_manager.py +0 -0
- {crewplus-0.2.29 → crewplus-0.2.31}/crewplus/vectorstores/milvus/schema_milvus.py +0 -0
- {crewplus-0.2.29 → crewplus-0.2.31}/crewplus/vectorstores/milvus/vdb_service.py +0 -0
- {crewplus-0.2.29 → crewplus-0.2.31}/docs/GeminiChatModel.md +0 -0
- {crewplus-0.2.29 → crewplus-0.2.31}/docs/ModelLoadBalancer.md +0 -0
- {crewplus-0.2.29 → crewplus-0.2.31}/docs/VDBService.md +0 -0
- {crewplus-0.2.29 → crewplus-0.2.31}/docs/index.md +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: crewplus
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.31
|
|
4
4
|
Summary: Base services for CrewPlus AI applications
|
|
5
5
|
Author-Email: Tim Liu <tim@opsmateai.com>
|
|
6
6
|
License: MIT
|
|
@@ -9,9 +9,9 @@ Project-URL: Documentation, https://crewplus.readthedocs.io
|
|
|
9
9
|
Project-URL: Repository, https://github.com/your-org/crewplus-base
|
|
10
10
|
Project-URL: Issues, https://github.com/your-org/crewplus-base/issues
|
|
11
11
|
Requires-Python: <4.0,>=3.11
|
|
12
|
-
Requires-Dist: langchain
|
|
13
|
-
Requires-Dist: langchain-openai
|
|
14
|
-
Requires-Dist: google-genai
|
|
12
|
+
Requires-Dist: langchain>=0.3.25
|
|
13
|
+
Requires-Dist: langchain-openai>=0.3.24
|
|
14
|
+
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
|
|
@@ -76,21 +76,23 @@ class ModelLoadBalancer:
|
|
|
76
76
|
self.logger.error(f"Failed to load model configuration: {e}", exc_info=True)
|
|
77
77
|
raise RuntimeError(f"Failed to load model configuration: {e}")
|
|
78
78
|
|
|
79
|
-
def get_model(self, provider: str = None, model_type: str = None, deployment_name: str = None, with_metadata: bool = False):
|
|
79
|
+
def get_model(self, provider: str = None, model_type: str = None, deployment_name: str = None, with_metadata: bool = False, selection_strategy: str = 'random'):
|
|
80
80
|
"""
|
|
81
81
|
Get a model instance.
|
|
82
82
|
|
|
83
83
|
Can fetch a model in two ways:
|
|
84
84
|
1. By its specific `deployment_name`.
|
|
85
|
-
2. By `provider` and `model_type`, which will select a model using
|
|
85
|
+
2. By `provider` and `model_type`, which will select a model using a specified strategy.
|
|
86
86
|
|
|
87
87
|
Args:
|
|
88
88
|
provider: The model provider (e.g., 'azure-openai', 'google-genai').
|
|
89
89
|
model_type: The type of model (e.g., 'inference', 'embedding', 'embedding-large').
|
|
90
90
|
deployment_name: The unique name for the model deployment.
|
|
91
|
+
with_metadata: If True, returns a tuple of (model, deployment_name).
|
|
92
|
+
selection_strategy: The selection strategy ('random', 'round_robin', or 'least_used'). Defaults to 'random'.
|
|
91
93
|
|
|
92
94
|
Returns:
|
|
93
|
-
An instantiated language model object.
|
|
95
|
+
An instantiated language model object, or a tuple if with_metadata is True.
|
|
94
96
|
|
|
95
97
|
Raises:
|
|
96
98
|
RuntimeError: If the model configuration has not been loaded.
|
|
@@ -118,7 +120,16 @@ class ModelLoadBalancer:
|
|
|
118
120
|
self.logger.error(f"No models found for provider '{provider}' and type '{model_type}'")
|
|
119
121
|
raise ValueError(f"No models found for provider '{provider}' and type '{model_type}'")
|
|
120
122
|
|
|
121
|
-
|
|
123
|
+
if selection_strategy == 'random':
|
|
124
|
+
selected_model_config = self._random_selection(candidates)
|
|
125
|
+
elif selection_strategy == 'round_robin':
|
|
126
|
+
selected_model_config = self._round_robin_selection(candidates)
|
|
127
|
+
elif selection_strategy == 'least_used':
|
|
128
|
+
selected_model_config = self._least_used_selection(candidates)
|
|
129
|
+
else:
|
|
130
|
+
self.logger.warning(f"Unsupported selection strategy: '{selection_strategy}'. Defaulting to 'random'.")
|
|
131
|
+
selected_model_config = self._random_selection(candidates)
|
|
132
|
+
|
|
122
133
|
model_id = selected_model_config['id']
|
|
123
134
|
model = self.models[model_id]
|
|
124
135
|
if with_metadata:
|
|
@@ -186,6 +197,12 @@ class ModelLoadBalancer:
|
|
|
186
197
|
self.usage_counter = defaultdict(int)
|
|
187
198
|
self.current_indices = {}
|
|
188
199
|
|
|
200
|
+
def _random_selection(self, candidates: list) -> Dict:
|
|
201
|
+
"""Selects a model randomly from a list of candidates."""
|
|
202
|
+
model = random.choice(candidates)
|
|
203
|
+
self.usage_counter[model['id']] += 1
|
|
204
|
+
return model
|
|
205
|
+
|
|
189
206
|
def _round_robin_selection(self, candidates: list) -> Dict:
|
|
190
207
|
if id(candidates) not in self.current_indices:
|
|
191
208
|
self.current_indices[id(candidates)] = 0
|
|
@@ -197,8 +214,8 @@ class ModelLoadBalancer:
|
|
|
197
214
|
return model
|
|
198
215
|
|
|
199
216
|
def _least_used_selection(self, candidates: list) -> Dict:
|
|
200
|
-
min_usage = min(self.usage_counter[m['
|
|
201
|
-
least_used = [m for m in candidates if self.usage_counter[m['
|
|
217
|
+
min_usage = min(self.usage_counter[m['id']] for m in candidates)
|
|
218
|
+
least_used = [m for m in candidates if self.usage_counter[m['id']] == min_usage]
|
|
202
219
|
model = random.choice(least_used)
|
|
203
220
|
self.usage_counter[model['id']] += 1
|
|
204
221
|
return model
|
|
@@ -2,4 +2,4 @@ from .milvus_schema_manager import MilvusSchemaManager, ZillizSchemaManager
|
|
|
2
2
|
from .schema_milvus import SchemaMilvus
|
|
3
3
|
from .vdb_service import VDBService
|
|
4
4
|
|
|
5
|
-
__all__ = ["MilvusSchemaManager", "ZillizSchemaManager", "VDBService"]
|
|
5
|
+
__all__ = ["MilvusSchemaManager", "ZillizSchemaManager", "VDBService", "SchemaMilvus"]
|
|
@@ -6,7 +6,7 @@ build-backend = "pdm.backend"
|
|
|
6
6
|
|
|
7
7
|
[project]
|
|
8
8
|
name = "crewplus"
|
|
9
|
-
version = "0.2.
|
|
9
|
+
version = "0.2.31"
|
|
10
10
|
description = "Base services for CrewPlus AI applications"
|
|
11
11
|
authors = [
|
|
12
12
|
{ name = "Tim Liu", email = "tim@opsmateai.com" },
|
|
@@ -14,9 +14,9 @@ authors = [
|
|
|
14
14
|
readme = "README.md"
|
|
15
15
|
requires-python = ">=3.11,<4.0"
|
|
16
16
|
dependencies = [
|
|
17
|
-
"langchain
|
|
18
|
-
"langchain-openai
|
|
19
|
-
"google-genai
|
|
17
|
+
"langchain>=0.3.25",
|
|
18
|
+
"langchain-openai>=0.3.24",
|
|
19
|
+
"google-genai>=1.21.1",
|
|
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",
|
|
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
|