waldiez 0.4.7__py3-none-any.whl → 0.4.9__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 waldiez might be problematic. Click here for more details.
- waldiez/__init__.py +5 -5
- waldiez/_version.py +1 -1
- waldiez/cli.py +97 -102
- waldiez/exporter.py +61 -19
- waldiez/exporting/__init__.py +25 -6
- waldiez/exporting/agent/__init__.py +7 -3
- waldiez/exporting/agent/code_execution.py +114 -0
- waldiez/exporting/agent/exporter.py +354 -0
- waldiez/exporting/agent/extras/__init__.py +15 -0
- waldiez/exporting/agent/extras/captain_agent_extras.py +315 -0
- waldiez/exporting/agent/extras/group/target.py +178 -0
- waldiez/exporting/agent/extras/group_manager_agent_extas.py +500 -0
- waldiez/exporting/agent/extras/group_member_extras.py +181 -0
- waldiez/exporting/agent/extras/handoffs/__init__.py +19 -0
- waldiez/exporting/agent/extras/handoffs/after_work.py +78 -0
- waldiez/exporting/agent/extras/handoffs/available.py +74 -0
- waldiez/exporting/agent/extras/handoffs/condition.py +158 -0
- waldiez/exporting/agent/extras/handoffs/handoff.py +171 -0
- waldiez/exporting/agent/extras/handoffs/target.py +189 -0
- waldiez/exporting/agent/extras/rag/__init__.py +10 -0
- waldiez/exporting/agent/{utils/rag_user/chroma_utils.py → extras/rag/chroma_extras.py} +37 -24
- waldiez/exporting/agent/{utils/rag_user/mongo_utils.py → extras/rag/mongo_extras.py} +10 -10
- waldiez/exporting/agent/{utils/rag_user/pgvector_utils.py → extras/rag/pgvector_extras.py} +13 -13
- waldiez/exporting/agent/{utils/rag_user/qdrant_utils.py → extras/rag/qdrant_extras.py} +13 -13
- waldiez/exporting/agent/{utils/rag_user/vector_db.py → extras/rag/vector_db_extras.py} +59 -46
- waldiez/exporting/agent/extras/rag_user_proxy_agent_extras.py +245 -0
- waldiez/exporting/agent/extras/reasoning_agent_extras.py +88 -0
- waldiez/exporting/agent/factory.py +95 -0
- waldiez/exporting/agent/processor.py +150 -0
- waldiez/exporting/agent/system_message.py +36 -0
- waldiez/exporting/agent/termination.py +50 -0
- waldiez/exporting/chats/__init__.py +7 -3
- waldiez/exporting/chats/exporter.py +97 -0
- waldiez/exporting/chats/factory.py +65 -0
- waldiez/exporting/chats/processor.py +226 -0
- waldiez/exporting/chats/utils/__init__.py +6 -5
- waldiez/exporting/chats/utils/common.py +11 -45
- waldiez/exporting/chats/utils/group.py +55 -0
- waldiez/exporting/chats/utils/nested.py +37 -52
- waldiez/exporting/chats/utils/sequential.py +72 -61
- waldiez/exporting/chats/utils/{single_chat.py → single.py} +48 -50
- waldiez/exporting/core/__init__.py +196 -0
- waldiez/exporting/core/constants.py +17 -0
- waldiez/exporting/core/content.py +69 -0
- waldiez/exporting/core/context.py +244 -0
- waldiez/exporting/core/enums.py +89 -0
- waldiez/exporting/core/errors.py +19 -0
- waldiez/exporting/core/exporter.py +390 -0
- waldiez/exporting/core/exporters.py +67 -0
- waldiez/exporting/core/extras/__init__.py +39 -0
- waldiez/exporting/core/extras/agent_extras/__init__.py +27 -0
- waldiez/exporting/core/extras/agent_extras/captain_extras.py +57 -0
- waldiez/exporting/core/extras/agent_extras/group_manager_extras.py +102 -0
- waldiez/exporting/core/extras/agent_extras/rag_user_extras.py +53 -0
- waldiez/exporting/core/extras/agent_extras/reasoning_extras.py +68 -0
- waldiez/exporting/core/extras/agent_extras/standard_extras.py +263 -0
- waldiez/exporting/core/extras/base.py +241 -0
- waldiez/exporting/core/extras/chat_extras.py +118 -0
- waldiez/exporting/core/extras/flow_extras.py +70 -0
- waldiez/exporting/core/extras/model_extras.py +73 -0
- waldiez/exporting/core/extras/path_resolver.py +93 -0
- waldiez/exporting/core/extras/serializer.py +138 -0
- waldiez/exporting/core/extras/tool_extras.py +82 -0
- waldiez/exporting/core/protocols.py +259 -0
- waldiez/exporting/core/result.py +705 -0
- waldiez/exporting/core/types.py +329 -0
- waldiez/exporting/core/utils/__init__.py +11 -0
- waldiez/exporting/core/utils/comment.py +33 -0
- waldiez/exporting/core/utils/llm_config.py +117 -0
- waldiez/exporting/core/validation.py +96 -0
- waldiez/exporting/flow/__init__.py +6 -2
- waldiez/exporting/flow/execution_generator.py +193 -0
- waldiez/exporting/flow/exporter.py +107 -0
- waldiez/exporting/flow/factory.py +94 -0
- waldiez/exporting/flow/file_generator.py +214 -0
- waldiez/exporting/flow/merger.py +387 -0
- waldiez/exporting/flow/orchestrator.py +411 -0
- waldiez/exporting/flow/utils/__init__.py +9 -36
- waldiez/exporting/flow/utils/common.py +206 -0
- waldiez/exporting/flow/utils/importing.py +373 -0
- waldiez/exporting/flow/utils/linting.py +200 -0
- waldiez/exporting/flow/utils/{logging_utils.py → logging.py} +23 -9
- waldiez/exporting/models/__init__.py +3 -1
- waldiez/exporting/models/exporter.py +233 -0
- waldiez/exporting/models/factory.py +66 -0
- waldiez/exporting/models/processor.py +139 -0
- waldiez/exporting/tools/__init__.py +11 -0
- waldiez/exporting/tools/exporter.py +207 -0
- waldiez/exporting/tools/factory.py +57 -0
- waldiez/exporting/tools/processor.py +248 -0
- waldiez/exporting/tools/registration.py +133 -0
- waldiez/io/__init__.py +128 -0
- waldiez/io/_ws.py +199 -0
- waldiez/io/models/__init__.py +60 -0
- waldiez/io/models/base.py +66 -0
- waldiez/io/models/constants.py +78 -0
- waldiez/io/models/content/__init__.py +23 -0
- waldiez/io/models/content/audio.py +43 -0
- waldiez/io/models/content/base.py +45 -0
- waldiez/io/models/content/file.py +43 -0
- waldiez/io/models/content/image.py +96 -0
- waldiez/io/models/content/text.py +37 -0
- waldiez/io/models/content/video.py +43 -0
- waldiez/io/models/user_input.py +269 -0
- waldiez/io/models/user_response.py +215 -0
- waldiez/io/mqtt.py +681 -0
- waldiez/io/redis.py +782 -0
- waldiez/io/structured.py +439 -0
- waldiez/io/utils.py +184 -0
- waldiez/io/ws.py +298 -0
- waldiez/logger.py +481 -0
- waldiez/models/__init__.py +108 -51
- waldiez/models/agents/__init__.py +34 -70
- waldiez/models/agents/agent/__init__.py +10 -4
- waldiez/models/agents/agent/agent.py +466 -65
- waldiez/models/agents/agent/agent_data.py +119 -47
- waldiez/models/agents/agent/agent_type.py +13 -2
- waldiez/models/agents/agent/code_execution.py +12 -12
- waldiez/models/agents/agent/human_input_mode.py +8 -0
- waldiez/models/agents/agent/{linked_skill.py → linked_tool.py} +7 -7
- waldiez/models/agents/agent/nested_chat.py +35 -7
- waldiez/models/agents/agent/termination_message.py +30 -22
- waldiez/models/agents/{swarm_agent → agent}/update_system_message.py +22 -22
- waldiez/models/agents/agents.py +58 -63
- waldiez/models/agents/assistant/assistant.py +4 -4
- waldiez/models/agents/assistant/assistant_data.py +13 -1
- waldiez/models/agents/{captain_agent → captain}/captain_agent.py +5 -5
- waldiez/models/agents/{captain_agent → captain}/captain_agent_data.py +5 -5
- waldiez/models/agents/extra_requirements.py +11 -16
- waldiez/models/agents/group_manager/group_manager.py +103 -13
- waldiez/models/agents/group_manager/group_manager_data.py +36 -14
- waldiez/models/agents/group_manager/speakers.py +77 -24
- waldiez/models/agents/{rag_user → rag_user_proxy}/__init__.py +16 -16
- waldiez/models/agents/rag_user_proxy/rag_user_proxy.py +64 -0
- waldiez/models/agents/{rag_user/rag_user_data.py → rag_user_proxy/rag_user_proxy_data.py} +6 -5
- waldiez/models/agents/{rag_user → rag_user_proxy}/retrieve_config.py +182 -114
- waldiez/models/agents/{rag_user → rag_user_proxy}/vector_db_config.py +13 -13
- waldiez/models/agents/reasoning/reasoning_agent.py +6 -6
- waldiez/models/agents/reasoning/reasoning_agent_data.py +110 -63
- waldiez/models/agents/reasoning/reasoning_agent_reason_config.py +38 -10
- waldiez/models/agents/user_proxy/user_proxy.py +11 -7
- waldiez/models/agents/user_proxy/user_proxy_data.py +2 -2
- waldiez/models/chat/__init__.py +2 -1
- waldiez/models/chat/chat.py +166 -87
- waldiez/models/chat/chat_data.py +99 -136
- waldiez/models/chat/chat_message.py +33 -23
- waldiez/models/chat/chat_nested.py +31 -30
- waldiez/models/chat/chat_summary.py +10 -8
- waldiez/models/common/__init__.py +52 -2
- waldiez/models/common/ag2_version.py +1 -1
- waldiez/models/common/base.py +38 -7
- waldiez/models/common/dict_utils.py +42 -17
- waldiez/models/common/handoff.py +459 -0
- waldiez/models/common/id_generator.py +19 -0
- waldiez/models/common/method_utils.py +130 -68
- waldiez/{exporting/base/utils → models/common}/naming.py +38 -61
- waldiez/models/common/waldiez_version.py +37 -0
- waldiez/models/flow/__init__.py +9 -2
- waldiez/models/flow/connection.py +18 -0
- waldiez/models/flow/flow.py +311 -215
- waldiez/models/flow/flow_data.py +207 -40
- waldiez/models/flow/info.py +85 -0
- waldiez/models/flow/naming.py +131 -0
- waldiez/models/model/__init__.py +7 -1
- waldiez/models/model/extra_requirements.py +3 -12
- waldiez/models/model/model.py +76 -21
- waldiez/models/model/model_data.py +108 -20
- waldiez/models/tool/__init__.py +16 -0
- waldiez/models/tool/extra_requirements.py +36 -0
- waldiez/models/{skill/skill.py → tool/tool.py} +88 -88
- waldiez/models/tool/tool_data.py +51 -0
- waldiez/models/tool/tool_type.py +8 -0
- waldiez/models/waldiez.py +97 -80
- waldiez/runner.py +115 -61
- waldiez/running/__init__.py +13 -7
- waldiez/running/environment.py +49 -68
- waldiez/running/gen_seq_diagram.py +16 -14
- waldiez/running/post_run.py +119 -0
- waldiez/running/pre_run.py +149 -0
- waldiez/running/util.py +134 -0
- waldiez/utils/__init__.py +2 -4
- waldiez/utils/cli_extras/jupyter.py +5 -3
- waldiez/utils/cli_extras/runner.py +6 -4
- waldiez/utils/cli_extras/studio.py +6 -4
- waldiez/utils/conflict_checker.py +15 -9
- waldiez/utils/flaml_warnings.py +5 -5
- waldiez/utils/version.py +47 -0
- {waldiez-0.4.7.dist-info → waldiez-0.4.9.dist-info}/METADATA +235 -91
- waldiez-0.4.9.dist-info/RECORD +203 -0
- waldiez/exporting/agent/agent_exporter.py +0 -297
- waldiez/exporting/agent/utils/__init__.py +0 -23
- waldiez/exporting/agent/utils/captain_agent.py +0 -263
- waldiez/exporting/agent/utils/code_execution.py +0 -65
- waldiez/exporting/agent/utils/group_manager.py +0 -220
- waldiez/exporting/agent/utils/rag_user/__init__.py +0 -7
- waldiez/exporting/agent/utils/rag_user/rag_user.py +0 -209
- waldiez/exporting/agent/utils/reasoning.py +0 -36
- waldiez/exporting/agent/utils/swarm_agent.py +0 -469
- waldiez/exporting/agent/utils/teachability.py +0 -41
- waldiez/exporting/agent/utils/termination_message.py +0 -44
- waldiez/exporting/base/__init__.py +0 -25
- waldiez/exporting/base/agent_position.py +0 -75
- waldiez/exporting/base/base_exporter.py +0 -118
- waldiez/exporting/base/export_position.py +0 -48
- waldiez/exporting/base/import_position.py +0 -23
- waldiez/exporting/base/mixin.py +0 -137
- waldiez/exporting/base/utils/__init__.py +0 -18
- waldiez/exporting/base/utils/comments.py +0 -96
- waldiez/exporting/base/utils/path_check.py +0 -68
- waldiez/exporting/base/utils/to_string.py +0 -84
- waldiez/exporting/chats/chats_exporter.py +0 -240
- waldiez/exporting/chats/utils/swarm.py +0 -210
- waldiez/exporting/flow/flow_exporter.py +0 -528
- waldiez/exporting/flow/utils/agent_utils.py +0 -204
- waldiez/exporting/flow/utils/chat_utils.py +0 -71
- waldiez/exporting/flow/utils/def_main.py +0 -77
- waldiez/exporting/flow/utils/flow_content.py +0 -202
- waldiez/exporting/flow/utils/flow_names.py +0 -116
- waldiez/exporting/flow/utils/importing_utils.py +0 -227
- waldiez/exporting/models/models_exporter.py +0 -199
- waldiez/exporting/models/utils.py +0 -174
- waldiez/exporting/skills/__init__.py +0 -9
- waldiez/exporting/skills/skills_exporter.py +0 -176
- waldiez/exporting/skills/utils.py +0 -369
- waldiez/models/agents/agent/teachability.py +0 -70
- waldiez/models/agents/rag_user/rag_user.py +0 -60
- waldiez/models/agents/swarm_agent/__init__.py +0 -50
- waldiez/models/agents/swarm_agent/after_work.py +0 -179
- waldiez/models/agents/swarm_agent/on_condition.py +0 -105
- waldiez/models/agents/swarm_agent/on_condition_available.py +0 -142
- waldiez/models/agents/swarm_agent/on_condition_target.py +0 -40
- waldiez/models/agents/swarm_agent/swarm_agent.py +0 -107
- waldiez/models/agents/swarm_agent/swarm_agent_data.py +0 -124
- waldiez/models/flow/utils.py +0 -232
- waldiez/models/skill/__init__.py +0 -16
- waldiez/models/skill/extra_requirements.py +0 -36
- waldiez/models/skill/skill_data.py +0 -53
- waldiez/models/skill/skill_type.py +0 -8
- waldiez/running/running.py +0 -369
- waldiez/utils/pysqlite3_checker.py +0 -308
- waldiez/utils/rdps_checker.py +0 -122
- waldiez-0.4.7.dist-info/RECORD +0 -149
- /waldiez/models/agents/{captain_agent → captain}/__init__.py +0 -0
- /waldiez/models/agents/{captain_agent → captain}/captain_agent_lib_entry.py +0 -0
- {waldiez-0.4.7.dist-info → waldiez-0.4.9.dist-info}/WHEEL +0 -0
- {waldiez-0.4.7.dist-info → waldiez-0.4.9.dist-info}/entry_points.txt +0 -0
- {waldiez-0.4.7.dist-info → waldiez-0.4.9.dist-info}/licenses/LICENSE +0 -0
- {waldiez-0.4.7.dist-info → waldiez-0.4.9.dist-info}/licenses/NOTICE.md +0 -0
waldiez/models/model/model.py
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
"""Waldiez model model."""
|
|
4
4
|
|
|
5
5
|
import os
|
|
6
|
-
from typing import Any,
|
|
6
|
+
from typing import Any, Optional
|
|
7
7
|
|
|
8
8
|
from pydantic import Field
|
|
9
9
|
from typing_extensions import Annotated, Literal
|
|
10
10
|
|
|
11
11
|
from ..common import WaldiezBase, now
|
|
12
|
-
from .model_data import WaldiezModelAPIType, WaldiezModelData
|
|
12
|
+
from .model_data import WaldiezModelAPIType, WaldiezModelAWS, WaldiezModelData
|
|
13
13
|
|
|
14
|
-
DEFAULT_BASE_URLS:
|
|
14
|
+
DEFAULT_BASE_URLS: dict[WaldiezModelAPIType, str] = {
|
|
15
15
|
"deepseek": "https://api.deepseek.com/v1",
|
|
16
16
|
"google": "https://generativelanguage.googleapis.com/v1beta",
|
|
17
17
|
"anthropic": "https://api.anthropic.com/v1",
|
|
@@ -24,7 +24,7 @@ DEFAULT_BASE_URLS: Dict[WaldiezModelAPIType, str] = {
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
# we can omit the base_url for these models
|
|
27
|
-
MODEL_NEEDS_BASE_URL:
|
|
27
|
+
MODEL_NEEDS_BASE_URL: dict[WaldiezModelAPIType, bool] = {
|
|
28
28
|
"openai": False,
|
|
29
29
|
"azure": False,
|
|
30
30
|
"google": False,
|
|
@@ -50,9 +50,9 @@ class WaldiezModel(WaldiezBase):
|
|
|
50
50
|
The name of the model.
|
|
51
51
|
description : str
|
|
52
52
|
The description of the model.
|
|
53
|
-
tags :
|
|
53
|
+
tags : list[str]
|
|
54
54
|
The tags of the model.
|
|
55
|
-
requirements :
|
|
55
|
+
requirements : list[str]
|
|
56
56
|
The requirements of the model.
|
|
57
57
|
created_at : str
|
|
58
58
|
The date and time when the model was created.
|
|
@@ -86,7 +86,7 @@ class WaldiezModel(WaldiezBase):
|
|
|
86
86
|
),
|
|
87
87
|
]
|
|
88
88
|
tags: Annotated[
|
|
89
|
-
|
|
89
|
+
list[str],
|
|
90
90
|
Field(
|
|
91
91
|
default_factory=list,
|
|
92
92
|
title="Tags",
|
|
@@ -94,7 +94,7 @@ class WaldiezModel(WaldiezBase):
|
|
|
94
94
|
),
|
|
95
95
|
]
|
|
96
96
|
requirements: Annotated[
|
|
97
|
-
|
|
97
|
+
list[str],
|
|
98
98
|
Field(
|
|
99
99
|
default_factory=list,
|
|
100
100
|
title="Requirements",
|
|
@@ -175,7 +175,7 @@ class WaldiezModel(WaldiezBase):
|
|
|
175
175
|
return api_key or "REPLACE_ME"
|
|
176
176
|
|
|
177
177
|
@property
|
|
178
|
-
def price(self) -> Optional[
|
|
178
|
+
def price(self) -> Optional[list[float]]:
|
|
179
179
|
"""Get the model's price."""
|
|
180
180
|
if self.data.price is None:
|
|
181
181
|
return None
|
|
@@ -188,29 +188,31 @@ class WaldiezModel(WaldiezBase):
|
|
|
188
188
|
]
|
|
189
189
|
return None
|
|
190
190
|
|
|
191
|
-
def get_llm_config(self, skip_price: bool = False) ->
|
|
191
|
+
def get_llm_config(self, skip_price: bool = False) -> dict[str, Any]:
|
|
192
192
|
"""Get the model's llm config.
|
|
193
193
|
|
|
194
194
|
Parameters
|
|
195
195
|
----------
|
|
196
196
|
skip_price : bool, optional
|
|
197
|
-
Whether to skip the price, by default False
|
|
197
|
+
Whether to skip the price, by default, False
|
|
198
198
|
|
|
199
199
|
Returns
|
|
200
200
|
-------
|
|
201
|
-
|
|
201
|
+
dict[str, Any]
|
|
202
202
|
The model's llm config dictionary.
|
|
203
203
|
"""
|
|
204
|
-
|
|
204
|
+
# noinspection PyDictCreation
|
|
205
|
+
_llm_config: dict[str, Any] = {}
|
|
205
206
|
_llm_config["model"] = self.name
|
|
206
|
-
|
|
207
|
+
optionals: list[tuple[str, type]] = [
|
|
207
208
|
("base_url", str),
|
|
208
209
|
("max_tokens", int),
|
|
209
210
|
# ("temperature", float),
|
|
210
211
|
("top_p", float),
|
|
211
212
|
("api_version", str),
|
|
212
213
|
("default_headers", dict),
|
|
213
|
-
]
|
|
214
|
+
]
|
|
215
|
+
for attr, atr_type in optionals:
|
|
214
216
|
value = getattr(self.data, attr)
|
|
215
217
|
if value and isinstance(value, atr_type):
|
|
216
218
|
_llm_config[attr] = value
|
|
@@ -221,33 +223,86 @@ class WaldiezModel(WaldiezBase):
|
|
|
221
223
|
value = getattr(self, attr)
|
|
222
224
|
if value:
|
|
223
225
|
_llm_config[attr] = value
|
|
226
|
+
if self.data.api_type == "bedrock":
|
|
227
|
+
_llm_config.pop("base_url", None)
|
|
228
|
+
return set_bedrock_aws_config(_llm_config, self.data.aws)
|
|
224
229
|
return set_default_base_url(_llm_config, self.data.api_type)
|
|
225
230
|
|
|
226
231
|
|
|
227
232
|
def set_default_base_url(
|
|
228
|
-
llm_config:
|
|
229
|
-
) ->
|
|
233
|
+
llm_config: dict[str, Any], api_type: WaldiezModelAPIType
|
|
234
|
+
) -> dict[str, Any]:
|
|
230
235
|
"""Set the default base url if not provided.
|
|
231
236
|
|
|
232
237
|
Parameters
|
|
233
238
|
----------
|
|
234
|
-
llm_config :
|
|
239
|
+
llm_config : dict[str, Any]
|
|
235
240
|
The llm config dictionary.
|
|
236
241
|
api_type : str
|
|
237
242
|
The api type.
|
|
238
243
|
|
|
239
244
|
Returns
|
|
240
245
|
-------
|
|
241
|
-
|
|
246
|
+
dict[str, Any]
|
|
242
247
|
The llm config dictionary with the default base url set.
|
|
243
248
|
"""
|
|
244
249
|
dict_copy = llm_config.copy()
|
|
245
250
|
if "base_url" not in llm_config or not llm_config["base_url"]:
|
|
246
|
-
if MODEL_NEEDS_BASE_URL.get(api_type, True):
|
|
251
|
+
if MODEL_NEEDS_BASE_URL.get(api_type, True): # pragma: no branch
|
|
247
252
|
dict_copy["base_url"] = DEFAULT_BASE_URLS.get(api_type, "")
|
|
248
253
|
if (
|
|
249
254
|
not llm_config.get("base_url", "")
|
|
250
255
|
and MODEL_NEEDS_BASE_URL.get(api_type, True) is False
|
|
251
|
-
):
|
|
256
|
+
): # pragma: no cover
|
|
252
257
|
dict_copy.pop("base_url", None)
|
|
253
258
|
return dict_copy
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def set_bedrock_aws_config(
|
|
262
|
+
llm_config: dict[str, Any],
|
|
263
|
+
aws_config: Optional[WaldiezModelAWS],
|
|
264
|
+
) -> dict[str, Any]:
|
|
265
|
+
"""Set the AWS config for Bedrock.
|
|
266
|
+
|
|
267
|
+
Parameters
|
|
268
|
+
----------
|
|
269
|
+
llm_config : dict[str, Any]
|
|
270
|
+
The llm config dictionary.
|
|
271
|
+
aws_config : Optional[WaldiezModelAWS]
|
|
272
|
+
The passed aws config if any.
|
|
273
|
+
|
|
274
|
+
Returns
|
|
275
|
+
-------
|
|
276
|
+
dict[str, Any]
|
|
277
|
+
The llm config dictionary with the AWS config set.
|
|
278
|
+
"""
|
|
279
|
+
dict_copy = llm_config.copy()
|
|
280
|
+
aws_params = [
|
|
281
|
+
"access_key",
|
|
282
|
+
"secret_key",
|
|
283
|
+
"session_token",
|
|
284
|
+
"profile_name",
|
|
285
|
+
"region",
|
|
286
|
+
]
|
|
287
|
+
|
|
288
|
+
extra_args: dict[str, Any] = {}
|
|
289
|
+
for param in aws_params:
|
|
290
|
+
config_key = f"aws_{param}"
|
|
291
|
+
env_var = f"AWS_{param.upper()}"
|
|
292
|
+
|
|
293
|
+
# First try to get from aws_config
|
|
294
|
+
value = getattr(aws_config, param, "") if aws_config else ""
|
|
295
|
+
|
|
296
|
+
# If not found, try environment variable
|
|
297
|
+
if not value: # pragma: no cover
|
|
298
|
+
value = os.environ.get(env_var, "")
|
|
299
|
+
|
|
300
|
+
# Add to extra_args if value exists
|
|
301
|
+
if value: # pragma: no branch
|
|
302
|
+
extra_args[config_key] = value
|
|
303
|
+
|
|
304
|
+
# Update llm_config with extra_args
|
|
305
|
+
if extra_args: # pragma: no branch
|
|
306
|
+
dict_copy.update(extra_args)
|
|
307
|
+
|
|
308
|
+
return dict_copy
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# flake8: noqa: E501
|
|
4
4
|
"""Waldiez Model Data."""
|
|
5
5
|
|
|
6
|
-
from typing import
|
|
6
|
+
from typing import Optional
|
|
7
7
|
|
|
8
8
|
from pydantic import Field
|
|
9
9
|
from typing_extensions import Annotated, Literal
|
|
@@ -21,11 +21,76 @@ WaldiezModelAPIType = Literal[
|
|
|
21
21
|
"together",
|
|
22
22
|
"nim",
|
|
23
23
|
"cohere",
|
|
24
|
+
"bedrock",
|
|
24
25
|
"other",
|
|
25
26
|
]
|
|
26
27
|
"""Possible API types for the model."""
|
|
27
28
|
|
|
28
29
|
|
|
30
|
+
class WaldiezModelAWS(WaldiezBase):
|
|
31
|
+
"""AWS related parameters.
|
|
32
|
+
|
|
33
|
+
Attributes
|
|
34
|
+
----------
|
|
35
|
+
region : Optional[str]
|
|
36
|
+
The AWS region, by default None.
|
|
37
|
+
access_key : Optional[str]
|
|
38
|
+
The AWS access key, by default None.
|
|
39
|
+
secret_key : Optional[str]
|
|
40
|
+
The AWS secret access key, by default None.
|
|
41
|
+
session_token : Optional[str]
|
|
42
|
+
The AWS session token, by default None.
|
|
43
|
+
profile_name : Optional[str]
|
|
44
|
+
The AWS profile name, by default Nonde.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
region: Annotated[
|
|
48
|
+
Optional[str],
|
|
49
|
+
Field(
|
|
50
|
+
None,
|
|
51
|
+
alias="region",
|
|
52
|
+
title="Region",
|
|
53
|
+
description="The AWS region",
|
|
54
|
+
),
|
|
55
|
+
] = None
|
|
56
|
+
access_key: Annotated[
|
|
57
|
+
Optional[str],
|
|
58
|
+
Field(
|
|
59
|
+
None,
|
|
60
|
+
alias="accessKey",
|
|
61
|
+
title="Access Ke",
|
|
62
|
+
description="The AWS access key",
|
|
63
|
+
),
|
|
64
|
+
] = None
|
|
65
|
+
secret_key: Annotated[
|
|
66
|
+
Optional[str],
|
|
67
|
+
Field(
|
|
68
|
+
None,
|
|
69
|
+
alias="secretKey",
|
|
70
|
+
title="Secret Key",
|
|
71
|
+
description="The AWS secret key",
|
|
72
|
+
),
|
|
73
|
+
] = None
|
|
74
|
+
session_token: Annotated[
|
|
75
|
+
Optional[str],
|
|
76
|
+
Field(
|
|
77
|
+
None,
|
|
78
|
+
alias="sessionToken",
|
|
79
|
+
title="Session Token",
|
|
80
|
+
description="The AWS session token",
|
|
81
|
+
),
|
|
82
|
+
] = None
|
|
83
|
+
profile_name: Annotated[
|
|
84
|
+
Optional[str],
|
|
85
|
+
Field(
|
|
86
|
+
None,
|
|
87
|
+
alias="profileName",
|
|
88
|
+
title="Profile Name",
|
|
89
|
+
description="The AWS Profile name to use",
|
|
90
|
+
),
|
|
91
|
+
] = None
|
|
92
|
+
|
|
93
|
+
|
|
29
94
|
class WaldiezModelPrice(WaldiezBase):
|
|
30
95
|
"""Model Price.
|
|
31
96
|
|
|
@@ -65,7 +130,10 @@ class WaldiezModelData(WaldiezBase):
|
|
|
65
130
|
The top p of the model, by default None.
|
|
66
131
|
max_tokens : Optional[int]
|
|
67
132
|
The max tokens of the model, by default None.
|
|
68
|
-
|
|
133
|
+
aws : Optional[WaldiezModelAWS]
|
|
134
|
+
extras: dict[str, str]
|
|
135
|
+
Any extra attributes to include in the LLM Config.
|
|
136
|
+
default_headers : dict[str, str]
|
|
69
137
|
The default headers of the model.
|
|
70
138
|
price : Optional[WaldiezModelPrice]
|
|
71
139
|
The price of the model, by default None.
|
|
@@ -74,76 +142,96 @@ class WaldiezModelData(WaldiezBase):
|
|
|
74
142
|
base_url: Annotated[
|
|
75
143
|
Optional[str],
|
|
76
144
|
Field(
|
|
77
|
-
None,
|
|
145
|
+
default=None,
|
|
78
146
|
title="Base URL",
|
|
79
147
|
description="The base url of the model",
|
|
80
148
|
alias="baseUrl",
|
|
81
149
|
),
|
|
82
|
-
]
|
|
150
|
+
] = None
|
|
83
151
|
api_key: Annotated[
|
|
84
152
|
Optional[str],
|
|
85
153
|
Field(
|
|
86
|
-
None,
|
|
154
|
+
default=None,
|
|
87
155
|
alias="apiKey",
|
|
88
156
|
title="API Key",
|
|
89
157
|
description="The api key to use with the model",
|
|
90
158
|
),
|
|
91
|
-
]
|
|
159
|
+
] = None
|
|
92
160
|
api_type: Annotated[
|
|
93
161
|
WaldiezModelAPIType,
|
|
94
162
|
Field(
|
|
95
|
-
"other",
|
|
163
|
+
default="other",
|
|
96
164
|
alias="apiType",
|
|
97
165
|
title="API Type",
|
|
98
166
|
description="The api type of the model",
|
|
99
167
|
),
|
|
100
|
-
]
|
|
168
|
+
] = "other"
|
|
101
169
|
api_version: Annotated[
|
|
102
170
|
Optional[str],
|
|
103
171
|
Field(
|
|
104
|
-
None,
|
|
172
|
+
default=None,
|
|
105
173
|
alias="apiVersion",
|
|
106
174
|
title="API Version",
|
|
107
175
|
description="The api version of the model",
|
|
108
176
|
),
|
|
109
|
-
]
|
|
177
|
+
] = None
|
|
110
178
|
temperature: Annotated[
|
|
111
179
|
Optional[float],
|
|
112
180
|
Field(
|
|
113
|
-
None,
|
|
181
|
+
default=None,
|
|
114
182
|
alias="temperature",
|
|
115
183
|
title="Temperature",
|
|
116
184
|
description="The temperature of the model",
|
|
117
185
|
),
|
|
118
|
-
]
|
|
186
|
+
] = None
|
|
119
187
|
top_p: Annotated[
|
|
120
188
|
Optional[float],
|
|
121
189
|
Field(
|
|
122
|
-
None,
|
|
190
|
+
default=None,
|
|
123
191
|
alias="topP",
|
|
124
192
|
title="Top P",
|
|
125
193
|
description="The top p of the model",
|
|
126
194
|
),
|
|
127
|
-
]
|
|
195
|
+
] = None
|
|
128
196
|
max_tokens: Annotated[
|
|
129
197
|
Optional[int],
|
|
130
198
|
Field(
|
|
131
|
-
None,
|
|
199
|
+
default=None,
|
|
132
200
|
alias="maxTokens",
|
|
133
201
|
title="Max Tokens",
|
|
134
202
|
description="The max tokens of the model",
|
|
135
203
|
),
|
|
136
|
-
]
|
|
204
|
+
] = None
|
|
205
|
+
aws: Annotated[
|
|
206
|
+
Optional[WaldiezModelAWS],
|
|
207
|
+
Field(
|
|
208
|
+
default=None,
|
|
209
|
+
alias="aws",
|
|
210
|
+
title="AWS",
|
|
211
|
+
description="The AWS related parameters",
|
|
212
|
+
),
|
|
213
|
+
] = None
|
|
214
|
+
extras: Annotated[
|
|
215
|
+
dict[str, str],
|
|
216
|
+
Field(
|
|
217
|
+
alias="extras",
|
|
218
|
+
default_factory=dict,
|
|
219
|
+
title="Extras",
|
|
220
|
+
description="Any extra attributes to include in the LLM Config",
|
|
221
|
+
),
|
|
222
|
+
] = {}
|
|
137
223
|
default_headers: Annotated[
|
|
138
|
-
|
|
224
|
+
dict[str, str],
|
|
139
225
|
Field(
|
|
140
226
|
alias="defaultHeaders",
|
|
141
227
|
default_factory=dict,
|
|
142
228
|
title="Default Headers",
|
|
143
229
|
description="The default headers of the model",
|
|
144
230
|
),
|
|
145
|
-
]
|
|
231
|
+
] = {}
|
|
146
232
|
price: Annotated[
|
|
147
233
|
Optional[WaldiezModelPrice],
|
|
148
|
-
Field(
|
|
149
|
-
|
|
234
|
+
Field(
|
|
235
|
+
default=None, title="Price", description="The price of the model"
|
|
236
|
+
),
|
|
237
|
+
] = None
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
+
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
+
"""Waldiez Tool related models."""
|
|
4
|
+
|
|
5
|
+
from .extra_requirements import get_tools_extra_requirements
|
|
6
|
+
from .tool import SHARED_TOOL_NAME, WaldiezTool
|
|
7
|
+
from .tool_data import WaldiezToolData
|
|
8
|
+
from .tool_type import WaldiezToolType
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"SHARED_TOOL_NAME",
|
|
12
|
+
"WaldiezTool",
|
|
13
|
+
"WaldiezToolData",
|
|
14
|
+
"WaldiezToolType",
|
|
15
|
+
"get_tools_extra_requirements",
|
|
16
|
+
]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
+
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
+
"""Waldiez tool extra requirements."""
|
|
4
|
+
|
|
5
|
+
from typing import Iterator, Set
|
|
6
|
+
|
|
7
|
+
from .tool import WaldiezTool
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_tools_extra_requirements(
|
|
11
|
+
tools: Iterator[WaldiezTool],
|
|
12
|
+
autogen_version: str,
|
|
13
|
+
) -> Set[str]:
|
|
14
|
+
"""Get the tools extra requirements.
|
|
15
|
+
|
|
16
|
+
Parameters
|
|
17
|
+
----------
|
|
18
|
+
tools : list[WaldiezTool]
|
|
19
|
+
The tools.
|
|
20
|
+
autogen_version : str
|
|
21
|
+
The ag2 version.
|
|
22
|
+
|
|
23
|
+
Returns
|
|
24
|
+
-------
|
|
25
|
+
list[str]
|
|
26
|
+
The tools extra requirements.
|
|
27
|
+
"""
|
|
28
|
+
tool_requirements: Set[str] = set()
|
|
29
|
+
for tool in tools:
|
|
30
|
+
if tool.tool_type == "langchain":
|
|
31
|
+
tool_requirements.add(f"ag2[interop-langchain]=={autogen_version}")
|
|
32
|
+
if tool.tool_type == "crewai":
|
|
33
|
+
tool_requirements.add(f"ag2[interop-crewai]=={autogen_version}")
|
|
34
|
+
for requirement in tool.requirements:
|
|
35
|
+
tool_requirements.add(requirement)
|
|
36
|
+
return tool_requirements
|