waldiez 0.3.10__py3-none-any.whl → 0.3.12__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/_version.py +1 -1
- waldiez/exporter.py +6 -69
- waldiez/exporting/agent/agent_exporter.py +22 -15
- waldiez/exporting/agent/utils/__init__.py +2 -4
- waldiez/exporting/agent/utils/captain_agent.py +254 -0
- waldiez/exporting/chats/chats_exporter.py +3 -3
- waldiez/exporting/chats/utils/sequential.py +1 -0
- waldiez/exporting/chats/utils/single_chat.py +3 -0
- waldiez/exporting/flow/flow_exporter.py +11 -3
- waldiez/exporting/flow/utils/def_main.py +15 -6
- waldiez/exporting/flow/utils/flow_content.py +11 -10
- waldiez/exporting/flow/utils/importing_utils.py +1 -0
- waldiez/exporting/models/models_exporter.py +7 -0
- waldiez/exporting/models/utils.py +4 -0
- waldiez/models/__init__.py +6 -0
- waldiez/models/agents/__init__.py +14 -0
- waldiez/models/agents/agent/agent.py +71 -8
- waldiez/models/agents/agents.py +13 -3
- waldiez/models/agents/captain_agent/__init__.py +15 -0
- waldiez/models/agents/captain_agent/captain_agent.py +45 -0
- waldiez/models/agents/captain_agent/captain_agent_data.py +62 -0
- waldiez/models/agents/captain_agent/captain_agent_lib_entry.py +38 -0
- waldiez/models/agents/extra_requirements.py +88 -0
- waldiez/models/common/__init__.py +2 -0
- waldiez/models/common/ag2_version.py +30 -0
- waldiez/models/common/base.py +4 -0
- waldiez/models/common/date_utils.py +2 -0
- waldiez/models/common/dict_utils.py +2 -0
- waldiez/models/flow/__init__.py +2 -0
- waldiez/models/flow/flow.py +88 -10
- waldiez/models/flow/flow_data.py +15 -1
- waldiez/models/flow/utils.py +61 -1
- waldiez/models/model/__init__.py +2 -0
- waldiez/models/model/extra_requirements.py +55 -0
- waldiez/models/model/model.py +8 -2
- waldiez/models/model/model_data.py +2 -1
- waldiez/models/waldiez.py +26 -75
- {waldiez-0.3.10.dist-info → waldiez-0.3.12.dist-info}/METADATA +38 -29
- {waldiez-0.3.10.dist-info → waldiez-0.3.12.dist-info}/RECORD +43 -37
- waldiez/exporting/agent/utils/agent_class_name.py +0 -36
- waldiez/exporting/agent/utils/agent_imports.py +0 -55
- {waldiez-0.3.10.dist-info → waldiez-0.3.12.dist-info}/WHEEL +0 -0
- {waldiez-0.3.10.dist-info → waldiez-0.3.12.dist-info}/entry_points.txt +0 -0
- {waldiez-0.3.10.dist-info → waldiez-0.3.12.dist-info}/licenses/LICENSE +0 -0
- {waldiez-0.3.10.dist-info → waldiez-0.3.12.dist-info}/licenses/NOTICE.md +0 -0
|
@@ -32,6 +32,7 @@ class ModelsExporter(BaseExporter, ExporterMixin):
|
|
|
32
32
|
models: List[WaldiezModel],
|
|
33
33
|
model_names: Dict[str, str],
|
|
34
34
|
for_notebook: bool,
|
|
35
|
+
cache_seed: Optional[int],
|
|
35
36
|
output_dir: Optional[Union[str, Path]] = None,
|
|
36
37
|
) -> None:
|
|
37
38
|
"""Initialize the models exporter.
|
|
@@ -46,6 +47,10 @@ class ModelsExporter(BaseExporter, ExporterMixin):
|
|
|
46
47
|
The models.
|
|
47
48
|
model_names : Dict[str, str]
|
|
48
49
|
The model names.
|
|
50
|
+
for_notebook : bool
|
|
51
|
+
Whether the export is for a notebook or not.
|
|
52
|
+
cache_seed : Optional[int]
|
|
53
|
+
The cache seed if any, by default None
|
|
49
54
|
output_dir : Optional[Union[str, Path]], optional
|
|
50
55
|
The output directory if any, by default None
|
|
51
56
|
"""
|
|
@@ -57,6 +62,7 @@ class ModelsExporter(BaseExporter, ExporterMixin):
|
|
|
57
62
|
self.model_names = model_names
|
|
58
63
|
if output_dir is not None and not isinstance(output_dir, Path):
|
|
59
64
|
output_dir = Path(output_dir)
|
|
65
|
+
self.cache_seed = cache_seed
|
|
60
66
|
self.output_dir = output_dir
|
|
61
67
|
self._exported_string = None
|
|
62
68
|
|
|
@@ -127,6 +133,7 @@ class ModelsExporter(BaseExporter, ExporterMixin):
|
|
|
127
133
|
agent,
|
|
128
134
|
all_models=self.models,
|
|
129
135
|
model_names=self.model_names,
|
|
136
|
+
cache_seed=self.cache_seed,
|
|
130
137
|
),
|
|
131
138
|
AgentPosition(
|
|
132
139
|
agent=agent, position=AgentPositions.AS_ARGUMENT
|
|
@@ -63,6 +63,7 @@ def get_agent_llm_config_arg(
|
|
|
63
63
|
agent: WaldiezAgent,
|
|
64
64
|
all_models: List[WaldiezModel],
|
|
65
65
|
model_names: Dict[str, str],
|
|
66
|
+
cache_seed: Optional[int],
|
|
66
67
|
tabs: int = 1,
|
|
67
68
|
) -> str:
|
|
68
69
|
"""Get the string representation of the agent's llm config argument.
|
|
@@ -75,6 +76,8 @@ def get_agent_llm_config_arg(
|
|
|
75
76
|
All the models in the flow.
|
|
76
77
|
model_names : Dict[str, str]
|
|
77
78
|
A mapping of model ids to model names.
|
|
79
|
+
cache_seed : Optional[int]
|
|
80
|
+
The cache seed.
|
|
78
81
|
tabs : int, optional
|
|
79
82
|
The number of tabs for indentation, by default 1.
|
|
80
83
|
|
|
@@ -98,6 +101,7 @@ def get_agent_llm_config_arg(
|
|
|
98
101
|
if not got_at_least_one_model: # pragma: no cover
|
|
99
102
|
return f"{tab}llm_config=False," + "\n"
|
|
100
103
|
content += "\n" + f"{tab} ]," + "\n"
|
|
104
|
+
content += f'{tab} "cache_seed": {cache_seed},' + "\n"
|
|
101
105
|
content += tab + "},\n"
|
|
102
106
|
return content
|
|
103
107
|
|
waldiez/models/__init__.py
CHANGED
|
@@ -23,6 +23,9 @@ from .agents import (
|
|
|
23
23
|
WaldiezAgentType,
|
|
24
24
|
WaldiezAssistant,
|
|
25
25
|
WaldiezAssistantData,
|
|
26
|
+
WaldiezCaptainAgent,
|
|
27
|
+
WaldiezCaptainAgentData,
|
|
28
|
+
WaldiezCaptainAgentLibEntry,
|
|
26
29
|
WaldiezGroupManager,
|
|
27
30
|
WaldiezGroupManagerData,
|
|
28
31
|
WaldiezGroupManagerSpeakers,
|
|
@@ -87,6 +90,9 @@ __all__ = [
|
|
|
87
90
|
"WaldiezAgentType",
|
|
88
91
|
"WaldiezAssistant",
|
|
89
92
|
"WaldiezAssistantData",
|
|
93
|
+
"WaldiezCaptainAgent",
|
|
94
|
+
"WaldiezCaptainAgentData",
|
|
95
|
+
"WaldiezCaptainAgentLibEntry",
|
|
90
96
|
"WaldiezChat",
|
|
91
97
|
"WaldiezChatData",
|
|
92
98
|
"WaldiezChatSummary",
|
|
@@ -18,6 +18,15 @@ from .agent import (
|
|
|
18
18
|
)
|
|
19
19
|
from .agents import WaldiezAgents
|
|
20
20
|
from .assistant import WaldiezAssistant, WaldiezAssistantData
|
|
21
|
+
from .captain_agent import (
|
|
22
|
+
WaldiezCaptainAgent,
|
|
23
|
+
WaldiezCaptainAgentData,
|
|
24
|
+
WaldiezCaptainAgentLibEntry,
|
|
25
|
+
)
|
|
26
|
+
from .extra_requirements import (
|
|
27
|
+
get_captain_agent_extra_requirements,
|
|
28
|
+
get_retrievechat_extra_requirements,
|
|
29
|
+
)
|
|
21
30
|
from .group_manager import (
|
|
22
31
|
CUSTOM_SPEAKER_SELECTION,
|
|
23
32
|
CUSTOM_SPEAKER_SELECTION_ARGS,
|
|
@@ -77,6 +86,8 @@ from .swarm_agent import (
|
|
|
77
86
|
from .user_proxy import WaldiezUserProxy, WaldiezUserProxyData
|
|
78
87
|
|
|
79
88
|
__all__ = [
|
|
89
|
+
"get_retrievechat_extra_requirements",
|
|
90
|
+
"get_captain_agent_extra_requirements",
|
|
80
91
|
"IS_TERMINATION_MESSAGE",
|
|
81
92
|
"IS_TERMINATION_MESSAGE_ARGS",
|
|
82
93
|
"IS_TERMINATION_MESSAGE_TYPES",
|
|
@@ -113,6 +124,9 @@ __all__ = [
|
|
|
113
124
|
"WaldiezAgentNestedChatMessage",
|
|
114
125
|
"WaldiezAgentTeachability",
|
|
115
126
|
"WaldiezAgentTerminationMessage",
|
|
127
|
+
"WaldiezCaptainAgent",
|
|
128
|
+
"WaldiezCaptainAgentData",
|
|
129
|
+
"WaldiezCaptainAgentLibEntry",
|
|
116
130
|
"WaldiezGroupManager",
|
|
117
131
|
"WaldiezGroupManagerData",
|
|
118
132
|
"WaldiezGroupManagerSpeakers",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
3
|
"""Base agent class to be inherited by all agents."""
|
|
4
4
|
|
|
5
|
-
from typing import List
|
|
5
|
+
from typing import List, Set
|
|
6
6
|
|
|
7
7
|
from pydantic import Field
|
|
8
8
|
from typing_extensions import Annotated, Literal
|
|
@@ -12,7 +12,7 @@ from .agent_data import WaldiezAgentData
|
|
|
12
12
|
from .code_execution import WaldiezAgentCodeExecutionConfig
|
|
13
13
|
|
|
14
14
|
WaldiezAgentType = Literal[
|
|
15
|
-
"user", "assistant", "manager", "rag_user", "swarm", "reasoning"
|
|
15
|
+
"user", "assistant", "manager", "rag_user", "swarm", "reasoning", "captain"
|
|
16
16
|
]
|
|
17
17
|
|
|
18
18
|
|
|
@@ -25,9 +25,7 @@ class WaldiezAgent(WaldiezBase):
|
|
|
25
25
|
The ID of the agent.
|
|
26
26
|
type : Literal["agent"]
|
|
27
27
|
The type of the "node" in a graph: "agent"
|
|
28
|
-
agent_type :
|
|
29
|
-
"user", "assistant", "manager", "rag_user", "swarm", "reasoning"
|
|
30
|
-
]
|
|
28
|
+
agent_type : WaldiezAgentType
|
|
31
29
|
The type of the agent
|
|
32
30
|
name: str
|
|
33
31
|
The name of the agent.
|
|
@@ -65,9 +63,7 @@ class WaldiezAgent(WaldiezBase):
|
|
|
65
63
|
),
|
|
66
64
|
]
|
|
67
65
|
agent_type: Annotated[
|
|
68
|
-
|
|
69
|
-
"user", "assistant", "manager", "rag_user", "swarm", "reasoning"
|
|
70
|
-
],
|
|
66
|
+
WaldiezAgentType,
|
|
71
67
|
Field(
|
|
72
68
|
...,
|
|
73
69
|
title="Agent type",
|
|
@@ -129,6 +125,73 @@ class WaldiezAgent(WaldiezBase):
|
|
|
129
125
|
),
|
|
130
126
|
]
|
|
131
127
|
|
|
128
|
+
@property
|
|
129
|
+
def ag2_class(self) -> str:
|
|
130
|
+
"""Return the AG2 class of the agent."""
|
|
131
|
+
class_name = "ConversableAgent"
|
|
132
|
+
if self.data.is_multimodal:
|
|
133
|
+
return "MultimodalConversableAgent"
|
|
134
|
+
if self.agent_type == "assistant":
|
|
135
|
+
class_name = "AssistantAgent"
|
|
136
|
+
if self.agent_type == "user":
|
|
137
|
+
class_name = "UserProxyAgent"
|
|
138
|
+
if self.agent_type == "manager":
|
|
139
|
+
class_name = "GroupChatManager"
|
|
140
|
+
if self.agent_type == "rag_user":
|
|
141
|
+
class_name = "RetrieveUserProxyAgent"
|
|
142
|
+
if self.agent_type == "swarm":
|
|
143
|
+
class_name = "SwarmAgent"
|
|
144
|
+
if self.agent_type == "reasoning":
|
|
145
|
+
class_name = "ReasoningAgent"
|
|
146
|
+
if self.agent_type == "captain":
|
|
147
|
+
class_name = "CaptainAgent"
|
|
148
|
+
return class_name
|
|
149
|
+
|
|
150
|
+
@property
|
|
151
|
+
def ag2_imports(self) -> Set[str]:
|
|
152
|
+
"""Return the AG2 imports of the agent."""
|
|
153
|
+
agent_class = self.ag2_class
|
|
154
|
+
imports = set(["import autogen"])
|
|
155
|
+
if agent_class == "AssistantAgent":
|
|
156
|
+
imports.add("from autogen import AssistantAgent")
|
|
157
|
+
elif agent_class == "UserProxyAgent":
|
|
158
|
+
imports.add("from autogen import UserProxyAgent")
|
|
159
|
+
elif agent_class == "GroupChatManager":
|
|
160
|
+
imports.add("from autogen import GroupChatManager")
|
|
161
|
+
elif agent_class == "RetrieveUserProxyAgent":
|
|
162
|
+
imports.add(
|
|
163
|
+
"from autogen.agentchat.contrib.retrieve_user_proxy_agent "
|
|
164
|
+
"import RetrieveUserProxyAgent"
|
|
165
|
+
)
|
|
166
|
+
elif agent_class == "MultimodalConversableAgent":
|
|
167
|
+
imports.add(
|
|
168
|
+
"from autogen.agentchat.contrib.multimodal_conversable_agent "
|
|
169
|
+
"import MultimodalConversableAgent"
|
|
170
|
+
)
|
|
171
|
+
elif agent_class == "SwarmAgent":
|
|
172
|
+
imports.add(
|
|
173
|
+
"from autogen import "
|
|
174
|
+
"AFTER_WORK, "
|
|
175
|
+
"ON_CONDITION, "
|
|
176
|
+
"UPDATE_SYSTEM_MESSAGE, "
|
|
177
|
+
"AfterWorkOption, "
|
|
178
|
+
"SwarmAgent, "
|
|
179
|
+
"SwarmResult"
|
|
180
|
+
)
|
|
181
|
+
elif agent_class == "ReasoningAgent":
|
|
182
|
+
imports.add(
|
|
183
|
+
"from autogen.agentchat.contrib.reasoning_agent "
|
|
184
|
+
"import ReasoningAgent, visualize_tree"
|
|
185
|
+
)
|
|
186
|
+
elif agent_class == "CaptainAgent":
|
|
187
|
+
imports.add(
|
|
188
|
+
"from autogen.agentchat.contrib.captainagent "
|
|
189
|
+
"import CaptainAgent"
|
|
190
|
+
)
|
|
191
|
+
else: # pragma: no cover
|
|
192
|
+
imports.add("import ConversableAgent")
|
|
193
|
+
return imports
|
|
194
|
+
|
|
132
195
|
def validate_linked_skills(
|
|
133
196
|
self, skill_ids: List[str], agent_ids: List[str]
|
|
134
197
|
) -> None:
|
waldiez/models/agents/agents.py
CHANGED
|
@@ -10,7 +10,8 @@ from typing_extensions import Annotated, Self
|
|
|
10
10
|
from ..common import WaldiezBase
|
|
11
11
|
from .agent import WaldiezAgent
|
|
12
12
|
from .assistant import WaldiezAssistant
|
|
13
|
-
from .
|
|
13
|
+
from .captain_agent import WaldiezCaptainAgent
|
|
14
|
+
from .group_manager import WaldiezGroupManager
|
|
14
15
|
from .rag_user import WaldiezRagUser
|
|
15
16
|
from .reasoning import WaldiezReasoningAgent
|
|
16
17
|
from .swarm_agent import WaldiezSwarmAgent
|
|
@@ -80,6 +81,14 @@ class WaldiezAgents(WaldiezBase):
|
|
|
80
81
|
default_factory=list,
|
|
81
82
|
),
|
|
82
83
|
]
|
|
84
|
+
captain_agents: Annotated[
|
|
85
|
+
List[WaldiezCaptainAgent],
|
|
86
|
+
Field(
|
|
87
|
+
title="Captain Agents.",
|
|
88
|
+
description="Captain agents",
|
|
89
|
+
default_factory=list,
|
|
90
|
+
),
|
|
91
|
+
]
|
|
83
92
|
|
|
84
93
|
@property
|
|
85
94
|
def members(self) -> Iterator[WaldiezAgent]:
|
|
@@ -96,6 +105,7 @@ class WaldiezAgents(WaldiezBase):
|
|
|
96
105
|
yield from self.reasoning_agents
|
|
97
106
|
yield from self.swarm_agents
|
|
98
107
|
yield from self.managers
|
|
108
|
+
yield from self.captain_agents
|
|
99
109
|
|
|
100
110
|
@model_validator(mode="after")
|
|
101
111
|
def validate_agents(self) -> Self:
|
|
@@ -115,8 +125,8 @@ class WaldiezAgents(WaldiezBase):
|
|
|
115
125
|
If the agents are invalid.
|
|
116
126
|
"""
|
|
117
127
|
all_agent_ids = [agent.id for agent in self.members]
|
|
118
|
-
if len(all_agent_ids) <
|
|
119
|
-
raise ValueError("At least
|
|
128
|
+
if len(all_agent_ids) < 1:
|
|
129
|
+
raise ValueError("At least one agent is required.")
|
|
120
130
|
if len(all_agent_ids) != len(set(all_agent_ids)):
|
|
121
131
|
raise ValueError("Agent IDs must be unique.")
|
|
122
132
|
return self
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
+
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
+
"""Captain agent model."""
|
|
4
|
+
|
|
5
|
+
from .captain_agent import WaldiezCaptainAgent
|
|
6
|
+
from .captain_agent_data import (
|
|
7
|
+
WaldiezCaptainAgentData,
|
|
8
|
+
)
|
|
9
|
+
from .captain_agent_lib_entry import WaldiezCaptainAgentLibEntry
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"WaldiezCaptainAgentData",
|
|
13
|
+
"WaldiezCaptainAgent",
|
|
14
|
+
"WaldiezCaptainAgentLibEntry",
|
|
15
|
+
]
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
+
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
+
"""Waldiez captain agent model."""
|
|
4
|
+
|
|
5
|
+
from typing import Literal
|
|
6
|
+
|
|
7
|
+
from pydantic import Field
|
|
8
|
+
from typing_extensions import Annotated
|
|
9
|
+
|
|
10
|
+
from ..agent import WaldiezAgent
|
|
11
|
+
from .captain_agent_data import WaldiezCaptainAgentData
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class WaldiezCaptainAgent(WaldiezAgent):
|
|
15
|
+
"""Captain agent.
|
|
16
|
+
|
|
17
|
+
A `WaldiezAgent` with agent_type `captain` and
|
|
18
|
+
captain agent's related config for the agent.
|
|
19
|
+
Also see `WaldiezAgent`, `WaldiezCaptainData`, `WaldiezAgentData`
|
|
20
|
+
|
|
21
|
+
Attributes
|
|
22
|
+
----------
|
|
23
|
+
agent_type : Literal["captain"]
|
|
24
|
+
The agent type: 'captain' for a captain agent
|
|
25
|
+
data : WaldiezCaptainData
|
|
26
|
+
The captain agent's data.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
agent_type: Annotated[
|
|
30
|
+
Literal["captain"],
|
|
31
|
+
Field(
|
|
32
|
+
"captain",
|
|
33
|
+
title="Agent type",
|
|
34
|
+
description="The agent type: 'captain' for a captain agent",
|
|
35
|
+
alias="agentType",
|
|
36
|
+
),
|
|
37
|
+
]
|
|
38
|
+
data: Annotated[
|
|
39
|
+
WaldiezCaptainAgentData,
|
|
40
|
+
Field(
|
|
41
|
+
title="Data",
|
|
42
|
+
description="The captain agent's data",
|
|
43
|
+
default_factory=WaldiezCaptainAgentData,
|
|
44
|
+
),
|
|
45
|
+
]
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
+
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
+
"""Waldiez captain agent data."""
|
|
4
|
+
|
|
5
|
+
from typing import List, Optional
|
|
6
|
+
|
|
7
|
+
from pydantic import Field
|
|
8
|
+
from typing_extensions import Annotated, Literal
|
|
9
|
+
|
|
10
|
+
from ..agent import WaldiezAgentData
|
|
11
|
+
from .captain_agent_lib_entry import WaldiezCaptainAgentLibEntry
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class WaldiezCaptainAgentData(WaldiezAgentData):
|
|
15
|
+
"""Captain agent data class.
|
|
16
|
+
|
|
17
|
+
The data for a captain agent.
|
|
18
|
+
Extends `WaldiezAgentData`.
|
|
19
|
+
Extra attributes:
|
|
20
|
+
- `agent_lib`: Optional list of agent lib entries
|
|
21
|
+
- `tool_lib`:
|
|
22
|
+
- `max_round`: The maximum number of rounds in a group chat
|
|
23
|
+
- `max_turns`: The maximum number of turns for a chat
|
|
24
|
+
See the parent's docs (`WaldiezAgentData`) for the rest of the properties.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
agent_lib: Annotated[
|
|
28
|
+
List[WaldiezCaptainAgentLibEntry],
|
|
29
|
+
Field(
|
|
30
|
+
default_factory=list,
|
|
31
|
+
title="Agent lib",
|
|
32
|
+
description="The agent lib",
|
|
33
|
+
alias="agentLib",
|
|
34
|
+
),
|
|
35
|
+
] = []
|
|
36
|
+
tool_lib: Annotated[
|
|
37
|
+
Optional[Literal["default"]],
|
|
38
|
+
Field(
|
|
39
|
+
None,
|
|
40
|
+
title="Tool lib",
|
|
41
|
+
description="Whether to use the default tool lib",
|
|
42
|
+
alias="toolLib",
|
|
43
|
+
),
|
|
44
|
+
] = None
|
|
45
|
+
max_round: Annotated[
|
|
46
|
+
int,
|
|
47
|
+
Field(
|
|
48
|
+
10,
|
|
49
|
+
title="Max round",
|
|
50
|
+
description="The maximum number of rounds in a group chat",
|
|
51
|
+
alias="maxRound",
|
|
52
|
+
),
|
|
53
|
+
] = 10
|
|
54
|
+
max_turns: Annotated[
|
|
55
|
+
int,
|
|
56
|
+
Field(
|
|
57
|
+
5,
|
|
58
|
+
title="Max turns",
|
|
59
|
+
description="The maximum number of turns for a chat",
|
|
60
|
+
alias="maxTurns",
|
|
61
|
+
),
|
|
62
|
+
] = 5
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
+
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
+
"""Waldiez captain agent lib entry."""
|
|
4
|
+
|
|
5
|
+
from pydantic import Field
|
|
6
|
+
from typing_extensions import Annotated
|
|
7
|
+
|
|
8
|
+
from ...common import WaldiezBase
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class WaldiezCaptainAgentLibEntry(WaldiezBase):
|
|
12
|
+
"""Captain agent lib entry."""
|
|
13
|
+
|
|
14
|
+
name: Annotated[
|
|
15
|
+
str,
|
|
16
|
+
Field(
|
|
17
|
+
...,
|
|
18
|
+
title="Name",
|
|
19
|
+
description="The name of the agent",
|
|
20
|
+
),
|
|
21
|
+
]
|
|
22
|
+
description: Annotated[
|
|
23
|
+
str,
|
|
24
|
+
Field(
|
|
25
|
+
...,
|
|
26
|
+
title="Description",
|
|
27
|
+
description="The description of the agent",
|
|
28
|
+
),
|
|
29
|
+
]
|
|
30
|
+
system_message: Annotated[
|
|
31
|
+
str,
|
|
32
|
+
Field(
|
|
33
|
+
...,
|
|
34
|
+
title="System message",
|
|
35
|
+
description="The system message",
|
|
36
|
+
alias="systemMessage",
|
|
37
|
+
),
|
|
38
|
+
]
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
+
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
+
"""Extra requirements for agents."""
|
|
4
|
+
|
|
5
|
+
# pylint: disable=line-too-long
|
|
6
|
+
import platform
|
|
7
|
+
from typing import Iterator, List, Set
|
|
8
|
+
|
|
9
|
+
from .agent import WaldiezAgent
|
|
10
|
+
from .rag_user import WaldiezRagUser
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def get_retrievechat_extra_requirements(
|
|
14
|
+
agents: Iterator[WaldiezAgent],
|
|
15
|
+
) -> Set[str]:
|
|
16
|
+
"""Get the retrievechat extra requirements.
|
|
17
|
+
|
|
18
|
+
Parameters
|
|
19
|
+
----------
|
|
20
|
+
agents : List[WaldiezAgent]
|
|
21
|
+
The flow agents.
|
|
22
|
+
|
|
23
|
+
Returns
|
|
24
|
+
-------
|
|
25
|
+
Set[str]
|
|
26
|
+
The retrievechat extra requirements.
|
|
27
|
+
"""
|
|
28
|
+
# https://github.com/ag2ai/ag2/blob/main/pyproject.toml
|
|
29
|
+
# with chromadb relaxed
|
|
30
|
+
# to avoid conflicts with other extras and (later) allow py3.13
|
|
31
|
+
rag_requirements: Set[str] = {
|
|
32
|
+
"protobuf==4.25.3",
|
|
33
|
+
"chromadb>=0.5.23",
|
|
34
|
+
"sentence_transformers",
|
|
35
|
+
"pypdf",
|
|
36
|
+
"ipython",
|
|
37
|
+
"beautifulsoup4",
|
|
38
|
+
"markdownify",
|
|
39
|
+
}
|
|
40
|
+
for agent in agents:
|
|
41
|
+
if agent.agent_type == "rag_user" and isinstance(agent, WaldiezRagUser):
|
|
42
|
+
# if not chroma, get the relevant db requirements
|
|
43
|
+
db_type = agent.data.retrieve_config.vector_db
|
|
44
|
+
if db_type == "pgvector":
|
|
45
|
+
rag_requirements.update(
|
|
46
|
+
[
|
|
47
|
+
"pgvector>=0.2.5",
|
|
48
|
+
"psycopg[binary]>=3.2.4",
|
|
49
|
+
]
|
|
50
|
+
)
|
|
51
|
+
elif db_type == "mongodb":
|
|
52
|
+
rag_requirements.add("pymongo>=4.11")
|
|
53
|
+
elif db_type == "qdrant":
|
|
54
|
+
rag_requirements.update(["qdrant_client[fastembed]"])
|
|
55
|
+
return rag_requirements
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def get_captain_agent_extra_requirements() -> List[str]:
|
|
59
|
+
"""Get the captain agent extra requirements.
|
|
60
|
+
|
|
61
|
+
Returns
|
|
62
|
+
-------
|
|
63
|
+
List[str]
|
|
64
|
+
The captain agent extra requirements.
|
|
65
|
+
"""
|
|
66
|
+
# https://github.com/ag2ai/ag2/blob/main/autogen/agentchat/contrib/captainagent/tools/requirements.txt # noqa: E501
|
|
67
|
+
tool_requirements = [
|
|
68
|
+
"markdownify",
|
|
69
|
+
"arxiv",
|
|
70
|
+
"pymupdf",
|
|
71
|
+
"wikipedia-api",
|
|
72
|
+
"easyocr",
|
|
73
|
+
"python-pptx",
|
|
74
|
+
"openai-whisper",
|
|
75
|
+
"pandas",
|
|
76
|
+
"scipy",
|
|
77
|
+
# "sentence-transformers", also in agent_requirements
|
|
78
|
+
]
|
|
79
|
+
agent_requirements = [
|
|
80
|
+
"chromadb",
|
|
81
|
+
"sentence-transformers",
|
|
82
|
+
"huggingface-hub",
|
|
83
|
+
]
|
|
84
|
+
if platform.system() == "Linux":
|
|
85
|
+
agent_requirements.append("pysqlite3-binary")
|
|
86
|
+
# on windows and OSX, installing pysqlite3-binary seem to fail in some cases
|
|
87
|
+
# we can handle/install if needed in waldiez.utils.pysqlite3_checker
|
|
88
|
+
return tool_requirements + agent_requirements
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
3
|
"""Common utils for all models."""
|
|
4
4
|
|
|
5
|
+
from .ag2_version import get_autogen_version
|
|
5
6
|
from .base import WaldiezBase
|
|
6
7
|
from .date_utils import now
|
|
7
8
|
from .dict_utils import update_dict
|
|
@@ -16,6 +17,7 @@ __all__ = [
|
|
|
16
17
|
"WaldiezBase",
|
|
17
18
|
"now",
|
|
18
19
|
"check_function",
|
|
20
|
+
"get_autogen_version",
|
|
19
21
|
"get_function",
|
|
20
22
|
"generate_function",
|
|
21
23
|
"parse_code_string",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0.
|
|
2
|
+
# Copyright (c) 2024 - 2025 Waldiez and contributors.
|
|
3
|
+
"""Get the autogen version."""
|
|
4
|
+
|
|
5
|
+
import warnings
|
|
6
|
+
from functools import cache
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@cache
|
|
10
|
+
def get_autogen_version() -> str:
|
|
11
|
+
"""Get the autogen version.
|
|
12
|
+
|
|
13
|
+
Returns
|
|
14
|
+
-------
|
|
15
|
+
str
|
|
16
|
+
The autogen version.
|
|
17
|
+
|
|
18
|
+
Raises
|
|
19
|
+
------
|
|
20
|
+
ValueError
|
|
21
|
+
If pyautogen is not installed.
|
|
22
|
+
"""
|
|
23
|
+
# pylint: disable=import-outside-toplevel
|
|
24
|
+
with warnings.catch_warnings():
|
|
25
|
+
warnings.simplefilter("ignore")
|
|
26
|
+
try:
|
|
27
|
+
from autogen.version import __version__ as ag2 # type: ignore
|
|
28
|
+
except ImportError as error: # pragma: no cover
|
|
29
|
+
raise ValueError("pyautogen is not installed.") from error
|
|
30
|
+
return ag2
|
waldiez/models/common/base.py
CHANGED