waldiez 0.4.7__py3-none-any.whl → 0.4.8__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 +112 -73
- 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} +16 -15
- 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 +419 -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 +114 -49
- waldiez/running/__init__.py +1 -1
- waldiez/running/environment.py +49 -68
- waldiez/running/gen_seq_diagram.py +16 -14
- waldiez/running/running.py +53 -34
- waldiez/utils/__init__.py +0 -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-0.4.7.dist-info → waldiez-0.4.8.dist-info}/METADATA +235 -91
- waldiez-0.4.8.dist-info/RECORD +200 -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/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.8.dist-info}/WHEEL +0 -0
- {waldiez-0.4.7.dist-info → waldiez-0.4.8.dist-info}/entry_points.txt +0 -0
- {waldiez-0.4.7.dist-info → waldiez-0.4.8.dist-info}/licenses/LICENSE +0 -0
- {waldiez-0.4.7.dist-info → waldiez-0.4.8.dist-info}/licenses/NOTICE.md +0 -0
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
-
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
-
"""Extras for exporting a captain agent."""
|
|
4
|
-
|
|
5
|
-
import json
|
|
6
|
-
import os
|
|
7
|
-
from datetime import datetime, timezone
|
|
8
|
-
from pathlib import Path
|
|
9
|
-
from typing import Any, Callable, Dict, List, Optional, Union
|
|
10
|
-
|
|
11
|
-
from waldiez.models import (
|
|
12
|
-
WaldiezAgent,
|
|
13
|
-
WaldiezCaptainAgent,
|
|
14
|
-
WaldiezModel,
|
|
15
|
-
WaldiezModelData,
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def get_captain_agent_extras(
|
|
20
|
-
agent: WaldiezAgent,
|
|
21
|
-
agent_names: Dict[str, str],
|
|
22
|
-
all_models: List[WaldiezModel],
|
|
23
|
-
serializer: Callable[..., str],
|
|
24
|
-
output_dir: Optional[Union[str, Path]],
|
|
25
|
-
) -> str:
|
|
26
|
-
"""Get the extra args for the captain agent.
|
|
27
|
-
|
|
28
|
-
Parameters
|
|
29
|
-
----------
|
|
30
|
-
agent : WaldiezAgent
|
|
31
|
-
The agent.
|
|
32
|
-
agent_names : Dict[str, str]
|
|
33
|
-
A mapping of agent ids to agent names.
|
|
34
|
-
all_models : List[WaldiezModel]
|
|
35
|
-
All the models in the flow.
|
|
36
|
-
serializer : Callable[..., str]
|
|
37
|
-
The serializer to use.
|
|
38
|
-
output_dir : Optional[Union[str, Path]]
|
|
39
|
-
The output directory to save the agent lib and nested config.
|
|
40
|
-
|
|
41
|
-
Returns
|
|
42
|
-
-------
|
|
43
|
-
str
|
|
44
|
-
The extra args to use in the captain agent.
|
|
45
|
-
"""
|
|
46
|
-
# extra args: nested_config, agent_lib, tool_lib
|
|
47
|
-
if not isinstance(agent, WaldiezCaptainAgent):
|
|
48
|
-
return ""
|
|
49
|
-
agent_name = agent_names[agent.id]
|
|
50
|
-
save_path = str(output_dir) if output_dir else "."
|
|
51
|
-
extra_args_content = "\n" + " agent_config_save_path=os.getcwd(),"
|
|
52
|
-
if agent.data.agent_lib:
|
|
53
|
-
lib_dict = [
|
|
54
|
-
lib.model_dump(by_alias=False) for lib in agent.data.agent_lib
|
|
55
|
-
]
|
|
56
|
-
lib_json_name = f"{agent_name}_agent_lib.json"
|
|
57
|
-
agent_lib_path = os.path.join(save_path, lib_json_name)
|
|
58
|
-
with open(agent_lib_path, "w", encoding="utf-8", newline="\n") as f:
|
|
59
|
-
json.dump(lib_dict, f, ensure_ascii=False, indent=4)
|
|
60
|
-
extra_args_content += "\n" + f' agent_lib="{lib_json_name}",'
|
|
61
|
-
if agent.data.tool_lib:
|
|
62
|
-
extra_args_content += "\n" + f' tool_lib="{agent.data.tool_lib}",'
|
|
63
|
-
nested_config = generate_nested_config(
|
|
64
|
-
agent,
|
|
65
|
-
agent_name,
|
|
66
|
-
all_models,
|
|
67
|
-
save_path,
|
|
68
|
-
)
|
|
69
|
-
serialized_nested_config = serializer(nested_config)
|
|
70
|
-
extra_args_content += (
|
|
71
|
-
"\n" + f" nested_config={serialized_nested_config},"
|
|
72
|
-
)
|
|
73
|
-
return extra_args_content
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
def generate_nested_config(
|
|
77
|
-
agent: WaldiezCaptainAgent,
|
|
78
|
-
agent_name: str,
|
|
79
|
-
all_models: List[WaldiezModel],
|
|
80
|
-
save_path: str,
|
|
81
|
-
) -> Dict[str, Any]:
|
|
82
|
-
"""Generate the nested config for the captain agent.
|
|
83
|
-
|
|
84
|
-
Parameters
|
|
85
|
-
----------
|
|
86
|
-
agent : WaldiezCaptainAgent
|
|
87
|
-
The captain agent.
|
|
88
|
-
agent_name : str
|
|
89
|
-
The agent name.
|
|
90
|
-
all_models : List[WaldiezModel]
|
|
91
|
-
All the models in the flow.
|
|
92
|
-
save_path : str
|
|
93
|
-
The path to save the nested config.
|
|
94
|
-
|
|
95
|
-
Returns
|
|
96
|
-
-------
|
|
97
|
-
Dict[str, Any]
|
|
98
|
-
The nested config.
|
|
99
|
-
"""
|
|
100
|
-
config_file_or_env_name = f"{agent_name}_llm_config.json"
|
|
101
|
-
llm_config = get_llm_config(agent, all_models)
|
|
102
|
-
os.makedirs(save_path, exist_ok=True)
|
|
103
|
-
config_file_or_env_path = os.path.join(save_path, config_file_or_env_name)
|
|
104
|
-
with open(
|
|
105
|
-
config_file_or_env_path, "w", encoding="utf-8", newline="\n"
|
|
106
|
-
) as f:
|
|
107
|
-
json.dump(llm_config, f, ensure_ascii=False, indent=4)
|
|
108
|
-
nested_config = {
|
|
109
|
-
"autobuild_init_config": {
|
|
110
|
-
"config_file_or_env": config_file_or_env_name,
|
|
111
|
-
"builder_model": llm_config["config_list"][0]["model"],
|
|
112
|
-
"agent_model": llm_config["config_list"][0]["model"],
|
|
113
|
-
},
|
|
114
|
-
"autobuild_build_config": get_auto_build_build_config(
|
|
115
|
-
agent, llm_config
|
|
116
|
-
),
|
|
117
|
-
"group_chat_config": {"max_round": agent.data.max_round},
|
|
118
|
-
"group_chat_llm_config": None,
|
|
119
|
-
"max_turns": agent.data.max_turns,
|
|
120
|
-
}
|
|
121
|
-
return nested_config
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
def get_llm_config(
|
|
125
|
-
agent: WaldiezAgent,
|
|
126
|
-
all_models: List[WaldiezModel],
|
|
127
|
-
) -> Dict[str, Any]:
|
|
128
|
-
"""Get the config list environment variable name and its dict value.
|
|
129
|
-
|
|
130
|
-
Parameters
|
|
131
|
-
----------
|
|
132
|
-
agent : WaldiezAgent
|
|
133
|
-
The agent.
|
|
134
|
-
all_models : List[WaldiezModel]
|
|
135
|
-
All the models in the flow.
|
|
136
|
-
|
|
137
|
-
Returns
|
|
138
|
-
-------
|
|
139
|
-
Dict[str, str]
|
|
140
|
-
The llm config dict.
|
|
141
|
-
"""
|
|
142
|
-
model_name = "gpt-4o"
|
|
143
|
-
temperature: Optional[float] = 1
|
|
144
|
-
top_p: Optional[float] = 0.95
|
|
145
|
-
max_tokens: Optional[int] = 2048
|
|
146
|
-
config_dict: Dict[str, Any] = {}
|
|
147
|
-
if agent.data.model_ids:
|
|
148
|
-
waldiez_model = get_waldiez_model(agent.data.model_ids[0], all_models)
|
|
149
|
-
llm_config = waldiez_model.get_llm_config(skip_price=True)
|
|
150
|
-
for key in ["temperature", "top_p", "max_tokens"]:
|
|
151
|
-
if key not in llm_config:
|
|
152
|
-
llm_config[key] = None
|
|
153
|
-
temp = llm_config.pop("temperature", None)
|
|
154
|
-
config_dict = {
|
|
155
|
-
"config_list": [llm_config],
|
|
156
|
-
}
|
|
157
|
-
if temp is not None:
|
|
158
|
-
config_dict["temperature"] = temp
|
|
159
|
-
return config_dict
|
|
160
|
-
config_dict = {
|
|
161
|
-
"model": model_name,
|
|
162
|
-
"top_p": top_p,
|
|
163
|
-
"max_tokens": max_tokens,
|
|
164
|
-
}
|
|
165
|
-
return {
|
|
166
|
-
"config_list": [config_dict],
|
|
167
|
-
"temperature": temperature,
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
def get_auto_build_build_config(
|
|
172
|
-
agent: WaldiezAgent,
|
|
173
|
-
llm_config: Dict[str, Any],
|
|
174
|
-
) -> Dict[str, Any]:
|
|
175
|
-
"""Get the auto build build config.
|
|
176
|
-
|
|
177
|
-
Parameters
|
|
178
|
-
----------
|
|
179
|
-
agent : WaldiezAgent
|
|
180
|
-
The agent.
|
|
181
|
-
llm_config : Dict[str, Any]
|
|
182
|
-
The llm config.
|
|
183
|
-
|
|
184
|
-
Returns
|
|
185
|
-
-------
|
|
186
|
-
Dict[str, Any]
|
|
187
|
-
The auto build build config.
|
|
188
|
-
"""
|
|
189
|
-
coding = False
|
|
190
|
-
code_execution_config = {
|
|
191
|
-
"timeout": 300,
|
|
192
|
-
"work_dir": "groupchat",
|
|
193
|
-
"last_n_messages": 1,
|
|
194
|
-
"use_docker": False,
|
|
195
|
-
}
|
|
196
|
-
if agent.data.code_execution_config is not False:
|
|
197
|
-
coding = True
|
|
198
|
-
code_execution_config["work_dir"] = (
|
|
199
|
-
agent.data.code_execution_config.work_dir or "groupchat"
|
|
200
|
-
)
|
|
201
|
-
code_execution_config["last_n_messages"] = (
|
|
202
|
-
agent.data.code_execution_config.last_n_messages or 1
|
|
203
|
-
)
|
|
204
|
-
code_execution_config["timeout"] = (
|
|
205
|
-
agent.data.code_execution_config.timeout or 300
|
|
206
|
-
)
|
|
207
|
-
return {
|
|
208
|
-
"default_llm_config": {
|
|
209
|
-
"temperature": llm_config["temperature"],
|
|
210
|
-
"top_p": llm_config["config_list"][0]["top_p"],
|
|
211
|
-
"max_tokens": llm_config["config_list"][0]["max_tokens"],
|
|
212
|
-
},
|
|
213
|
-
"code_execution_config": code_execution_config,
|
|
214
|
-
"coding": coding,
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
def get_waldiez_model(
|
|
219
|
-
model_id: str, all_models: List[WaldiezModel]
|
|
220
|
-
) -> WaldiezModel:
|
|
221
|
-
"""Get the model name from the model id.
|
|
222
|
-
|
|
223
|
-
Parameters
|
|
224
|
-
----------
|
|
225
|
-
model_id : str
|
|
226
|
-
The model id.
|
|
227
|
-
all_models : List[WaldiezModel]
|
|
228
|
-
All the models in the flow.
|
|
229
|
-
|
|
230
|
-
Returns
|
|
231
|
-
-------
|
|
232
|
-
str
|
|
233
|
-
The model name.
|
|
234
|
-
"""
|
|
235
|
-
for model in all_models:
|
|
236
|
-
if model.id == model_id:
|
|
237
|
-
return model
|
|
238
|
-
now = (
|
|
239
|
-
datetime.now(tz=timezone.utc)
|
|
240
|
-
.isoformat(timespec="milliseconds")
|
|
241
|
-
.replace("+00:00", "Z")
|
|
242
|
-
)
|
|
243
|
-
return WaldiezModel(
|
|
244
|
-
id=model_id,
|
|
245
|
-
type="model",
|
|
246
|
-
name="gpt-4o",
|
|
247
|
-
description="The GPT-4o model.",
|
|
248
|
-
tags=["gpt-4o"],
|
|
249
|
-
requirements=[],
|
|
250
|
-
created_at=now,
|
|
251
|
-
updated_at=now,
|
|
252
|
-
data=WaldiezModelData(
|
|
253
|
-
api_type="openai",
|
|
254
|
-
temperature=1,
|
|
255
|
-
top_p=0.95,
|
|
256
|
-
max_tokens=2048,
|
|
257
|
-
base_url=None,
|
|
258
|
-
api_key=os.environ.get("OPENAI_API_KEY", "REPLACE_ME"),
|
|
259
|
-
api_version=None,
|
|
260
|
-
default_headers={},
|
|
261
|
-
price=None,
|
|
262
|
-
),
|
|
263
|
-
)
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
-
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
-
"""Code execution related functions for exporting agents."""
|
|
4
|
-
|
|
5
|
-
from typing import Dict, Tuple
|
|
6
|
-
|
|
7
|
-
from waldiez.models import WaldiezAgent
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def get_agent_code_execution_config(
|
|
11
|
-
agent: WaldiezAgent, agent_name: str, skill_names: Dict[str, str]
|
|
12
|
-
) -> Tuple[str, str, str]:
|
|
13
|
-
"""Get the code execution config for the agent.
|
|
14
|
-
|
|
15
|
-
Parameters
|
|
16
|
-
----------
|
|
17
|
-
agent : WaldiezAgent
|
|
18
|
-
The agent.
|
|
19
|
-
agent_name : str
|
|
20
|
-
The agent name.
|
|
21
|
-
skill_names : Dict[str, str]
|
|
22
|
-
A mapping of skill id to skill name.
|
|
23
|
-
|
|
24
|
-
Returns
|
|
25
|
-
-------
|
|
26
|
-
Tuple[str, str, str, Set[str]]
|
|
27
|
-
- The executor content.
|
|
28
|
-
- The executor argument.
|
|
29
|
-
- The extra autogen.coding import if needed.
|
|
30
|
-
"""
|
|
31
|
-
if agent.data.code_execution_config is False:
|
|
32
|
-
return "", "False", ""
|
|
33
|
-
use_docker = agent.data.code_execution_config.use_docker
|
|
34
|
-
if use_docker is None:
|
|
35
|
-
use_docker = False
|
|
36
|
-
executor_class_name = (
|
|
37
|
-
"DockerCommandLineCodeExecutor"
|
|
38
|
-
if use_docker
|
|
39
|
-
else "LocalCommandLineCodeExecutor"
|
|
40
|
-
)
|
|
41
|
-
executor_content = f"{agent_name}_executor = {executor_class_name}(" + "\n"
|
|
42
|
-
if agent.data.code_execution_config.work_dir:
|
|
43
|
-
wok_dir = agent.data.code_execution_config.work_dir.replace(
|
|
44
|
-
'"', '\\"'
|
|
45
|
-
).replace("\n", "\\n")
|
|
46
|
-
executor_content += f' work_dir="{wok_dir}",' + "\n"
|
|
47
|
-
if agent.data.code_execution_config.timeout:
|
|
48
|
-
executor_content += (
|
|
49
|
-
f" timeout={agent.data.code_execution_config.timeout}," + "\n"
|
|
50
|
-
)
|
|
51
|
-
if use_docker is False and agent.data.code_execution_config.functions:
|
|
52
|
-
function_names = []
|
|
53
|
-
for skill_id in agent.data.code_execution_config.functions:
|
|
54
|
-
skill_name = skill_names[skill_id]
|
|
55
|
-
function_names.append(skill_name)
|
|
56
|
-
if function_names:
|
|
57
|
-
# pylint: disable=inconsistent-quotes
|
|
58
|
-
function_names_string = ", ".join(function_names)
|
|
59
|
-
executor_content += (
|
|
60
|
-
f" functions=[{function_names_string}]," + "\n"
|
|
61
|
-
)
|
|
62
|
-
executor_content += ")\n\n"
|
|
63
|
-
executor_arg = f'{{"executor": {agent_name}_executor}}'
|
|
64
|
-
the_import = f"from autogen.coding import {executor_class_name}"
|
|
65
|
-
return executor_content, executor_arg, the_import
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
-
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
-
"""Export group manager and group chat to string."""
|
|
4
|
-
|
|
5
|
-
from typing import Callable, Dict, List, Optional, Tuple
|
|
6
|
-
|
|
7
|
-
from waldiez.models import WaldiezAgent, WaldiezGroupManager
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def get_group_manager_extras(
|
|
11
|
-
agent: WaldiezAgent,
|
|
12
|
-
group_chat_members: List[WaldiezAgent],
|
|
13
|
-
agent_names: Dict[str, str],
|
|
14
|
-
serializer: Callable[..., str],
|
|
15
|
-
) -> Tuple[str, str]:
|
|
16
|
-
"""Get the group manager extra string and custom selection method if any.
|
|
17
|
-
|
|
18
|
-
Parameters
|
|
19
|
-
----------
|
|
20
|
-
agent : WaldiezAgent
|
|
21
|
-
The agent.
|
|
22
|
-
group_chat_members : List[WaldiezAgent]
|
|
23
|
-
The group members.
|
|
24
|
-
agent_names : Dict[str, str]
|
|
25
|
-
The agent names.
|
|
26
|
-
serializer : Callable[..., str]
|
|
27
|
-
The serializer function.
|
|
28
|
-
|
|
29
|
-
Returns
|
|
30
|
-
-------
|
|
31
|
-
Tuple[str, str]
|
|
32
|
-
The content before the agent string and the group chat argument.
|
|
33
|
-
"""
|
|
34
|
-
group_chat_arg = ""
|
|
35
|
-
before_agent_string = ""
|
|
36
|
-
custom_speaker_selection: Optional[str] = None
|
|
37
|
-
if agent.agent_type == "manager" and isinstance(agent, WaldiezGroupManager):
|
|
38
|
-
group_chat_string, group_chat_name, custom_speaker_selection = (
|
|
39
|
-
_get_group_manager_extras(
|
|
40
|
-
agent=agent,
|
|
41
|
-
group_members=group_chat_members,
|
|
42
|
-
agent_names=agent_names,
|
|
43
|
-
serializer=serializer,
|
|
44
|
-
)
|
|
45
|
-
)
|
|
46
|
-
if group_chat_name:
|
|
47
|
-
group_chat_arg = "\n" + f" groupchat={group_chat_name},"
|
|
48
|
-
if custom_speaker_selection:
|
|
49
|
-
before_agent_string += f"{custom_speaker_selection}" + "\n"
|
|
50
|
-
if group_chat_string:
|
|
51
|
-
before_agent_string += group_chat_string
|
|
52
|
-
return before_agent_string, group_chat_arg
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def _get_group_manager_extras(
|
|
56
|
-
agent: WaldiezGroupManager,
|
|
57
|
-
group_members: List[WaldiezAgent],
|
|
58
|
-
agent_names: Dict[str, str],
|
|
59
|
-
serializer: Callable[..., str],
|
|
60
|
-
) -> Tuple[str, str, Optional[str]]:
|
|
61
|
-
"""Get the group manager extra string and custom selection method if any.
|
|
62
|
-
|
|
63
|
-
Parameters
|
|
64
|
-
----------
|
|
65
|
-
agent : WaldiezGroupManager
|
|
66
|
-
The agent.
|
|
67
|
-
group_members : List[WaldiezAgent]
|
|
68
|
-
The group members.
|
|
69
|
-
agent_names : Dict[str, str]
|
|
70
|
-
The agent names.
|
|
71
|
-
serializer : Callable[..., str]
|
|
72
|
-
The serializer function.
|
|
73
|
-
|
|
74
|
-
Returns
|
|
75
|
-
-------
|
|
76
|
-
str
|
|
77
|
-
The group chat definition string.
|
|
78
|
-
str
|
|
79
|
-
The group chat name.
|
|
80
|
-
Optional[str]
|
|
81
|
-
The custom selection method name and content if any.
|
|
82
|
-
"""
|
|
83
|
-
agent_name = agent_names[agent.id]
|
|
84
|
-
group_chat_name = f"{agent_name}_group_chat"
|
|
85
|
-
group_members_str = ", ".join(
|
|
86
|
-
agent_names[member.id] for member in group_members
|
|
87
|
-
)
|
|
88
|
-
group_chat_string = "\n" + f"{group_chat_name} = GroupChat(" + "\n"
|
|
89
|
-
group_chat_string += f" agents=[{group_members_str}]," + "\n"
|
|
90
|
-
group_chat_string += (
|
|
91
|
-
f" enable_clear_history={agent.data.enable_clear_history}," + "\n"
|
|
92
|
-
)
|
|
93
|
-
group_chat_string += (
|
|
94
|
-
f" send_introductions={agent.data.send_introductions}," + "\n"
|
|
95
|
-
)
|
|
96
|
-
group_chat_string += " messages=[]," + "\n"
|
|
97
|
-
if agent.data.max_round is not None:
|
|
98
|
-
group_chat_string += f" max_round={agent.data.max_round}," + "\n"
|
|
99
|
-
if agent.data.admin_name:
|
|
100
|
-
group_chat_string += f' admin_name="{agent.data.admin_name}",' + "\n"
|
|
101
|
-
extra_group_chat_string, custom_selection_method = (
|
|
102
|
-
_get_group_chat_speakers_string(agent, agent_names, serializer)
|
|
103
|
-
)
|
|
104
|
-
group_chat_string += extra_group_chat_string
|
|
105
|
-
group_chat_string += ")\n\n"
|
|
106
|
-
return group_chat_string, group_chat_name, custom_selection_method
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def _get_group_chat_speakers_string(
|
|
110
|
-
agent: WaldiezGroupManager,
|
|
111
|
-
agent_names: Dict[str, str],
|
|
112
|
-
serializer: Callable[..., str],
|
|
113
|
-
) -> Tuple[str, Optional[str]]:
|
|
114
|
-
"""Get the group chat speakers string.
|
|
115
|
-
|
|
116
|
-
Parameters
|
|
117
|
-
----------
|
|
118
|
-
agent : WaldiezGroupManager
|
|
119
|
-
The agent.
|
|
120
|
-
agent_names : Dict[str, str]
|
|
121
|
-
The agent names.
|
|
122
|
-
serializer : Callable[..., str]
|
|
123
|
-
The serializer function.
|
|
124
|
-
|
|
125
|
-
Returns
|
|
126
|
-
-------
|
|
127
|
-
str
|
|
128
|
-
The group chat speakers string.
|
|
129
|
-
Optional[str]
|
|
130
|
-
The custom custom for speaker selection if any.
|
|
131
|
-
"""
|
|
132
|
-
speakers_string = ""
|
|
133
|
-
function_content: Optional[str] = None
|
|
134
|
-
if agent.data.speakers.max_retries_for_selecting is not None:
|
|
135
|
-
speakers_string += (
|
|
136
|
-
" max_retries_for_selecting_speaker="
|
|
137
|
-
f"{agent.data.speakers.max_retries_for_selecting},"
|
|
138
|
-
"\n"
|
|
139
|
-
)
|
|
140
|
-
if agent.data.speakers.selection_method != "custom":
|
|
141
|
-
speakers_string += (
|
|
142
|
-
" speaker_selection_method="
|
|
143
|
-
f'"{agent.data.speakers.selection_method}",'
|
|
144
|
-
"\n"
|
|
145
|
-
)
|
|
146
|
-
else:
|
|
147
|
-
agent_name = agent_names[agent.id]
|
|
148
|
-
function_content, function_name = (
|
|
149
|
-
agent.data.speakers.get_custom_method_function(
|
|
150
|
-
name_suffix=agent_name
|
|
151
|
-
)
|
|
152
|
-
)
|
|
153
|
-
speakers_string += (
|
|
154
|
-
f" speaker_selection_method={function_name}," + "\n"
|
|
155
|
-
)
|
|
156
|
-
# selection_mode == "repeat":
|
|
157
|
-
if agent.data.speakers.selection_mode == "repeat":
|
|
158
|
-
speakers_string += _get_speakers_selection_repeat_string(
|
|
159
|
-
agent, agent_names
|
|
160
|
-
)
|
|
161
|
-
# selection_mode == "transition":
|
|
162
|
-
if (
|
|
163
|
-
agent.data.speakers.selection_mode == "transition"
|
|
164
|
-
and agent.data.speakers.allowed_or_disallowed_transitions
|
|
165
|
-
):
|
|
166
|
-
speakers_string += _get_speakers_selection_transition_string(
|
|
167
|
-
agent=agent,
|
|
168
|
-
agent_names=agent_names,
|
|
169
|
-
serializer=serializer,
|
|
170
|
-
)
|
|
171
|
-
speakers_string = speakers_string.replace('"None"', "None")
|
|
172
|
-
return speakers_string, function_content
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
def _get_speakers_selection_repeat_string(
|
|
176
|
-
agent: WaldiezGroupManager, agent_names: Dict[str, str]
|
|
177
|
-
) -> str:
|
|
178
|
-
speakers_string = ""
|
|
179
|
-
if isinstance(agent.data.speakers.allow_repeat, bool):
|
|
180
|
-
speakers_string += (
|
|
181
|
-
f" allow_repeat_speaker={agent.data.speakers.allow_repeat},"
|
|
182
|
-
+ "\n"
|
|
183
|
-
)
|
|
184
|
-
elif isinstance(agent.data.speakers.allow_repeat, list):
|
|
185
|
-
# get the names of the agents
|
|
186
|
-
allow_repeat = ", ".join(
|
|
187
|
-
agent_names[agent_id]
|
|
188
|
-
for agent_id in agent.data.speakers.allow_repeat
|
|
189
|
-
)
|
|
190
|
-
speakers_string += f" allow_repeat=[{allow_repeat}]," + "\n"
|
|
191
|
-
return speakers_string
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
def _get_speakers_selection_transition_string(
|
|
195
|
-
agent: WaldiezGroupManager,
|
|
196
|
-
agent_names: Dict[str, str],
|
|
197
|
-
serializer: Callable[..., str],
|
|
198
|
-
) -> str:
|
|
199
|
-
speakers_string = ""
|
|
200
|
-
allowed_or_disallowed_speaker_transitions = {}
|
|
201
|
-
for (
|
|
202
|
-
agent_id,
|
|
203
|
-
transitions,
|
|
204
|
-
) in agent.data.speakers.allowed_or_disallowed_transitions.items():
|
|
205
|
-
allowed_or_disallowed_speaker_transitions[agent_names[agent_id]] = [
|
|
206
|
-
agent_names[transition] for transition in transitions
|
|
207
|
-
]
|
|
208
|
-
transitions_string = serializer(
|
|
209
|
-
allowed_or_disallowed_speaker_transitions, 1
|
|
210
|
-
)
|
|
211
|
-
transitions_string = transitions_string.replace('"', "").replace("'", "")
|
|
212
|
-
speakers_string += (
|
|
213
|
-
" allowed_or_disallowed_speaker_transitions="
|
|
214
|
-
f"{transitions_string}," + "\n"
|
|
215
|
-
)
|
|
216
|
-
speakers_string += (
|
|
217
|
-
" speaker_transitions_type="
|
|
218
|
-
f'"{agent.data.speakers.transitions_type}",' + "\n"
|
|
219
|
-
)
|
|
220
|
-
return speakers_string
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
-
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
-
"""RAG User Agent related string generation."""
|
|
4
|
-
|
|
5
|
-
from .rag_user import get_rag_user_extras, get_rag_user_retrieve_config_str
|
|
6
|
-
|
|
7
|
-
__all__ = ["get_rag_user_retrieve_config_str", "get_rag_user_extras"]
|