waldiez 0.1.0__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.

Files changed (94) hide show
  1. waldiez/__init__.py +15 -0
  2. waldiez/__main__.py +6 -0
  3. waldiez/_version.py +3 -0
  4. waldiez/cli.py +162 -0
  5. waldiez/exporter.py +293 -0
  6. waldiez/exporting/__init__.py +14 -0
  7. waldiez/exporting/agents/__init__.py +5 -0
  8. waldiez/exporting/agents/agent.py +229 -0
  9. waldiez/exporting/agents/agent_skills.py +67 -0
  10. waldiez/exporting/agents/code_execution.py +67 -0
  11. waldiez/exporting/agents/group_manager.py +209 -0
  12. waldiez/exporting/agents/llm_config.py +53 -0
  13. waldiez/exporting/agents/rag_user/__init__.py +5 -0
  14. waldiez/exporting/agents/rag_user/chroma_utils.py +134 -0
  15. waldiez/exporting/agents/rag_user/mongo_utils.py +83 -0
  16. waldiez/exporting/agents/rag_user/pgvector_utils.py +93 -0
  17. waldiez/exporting/agents/rag_user/qdrant_utils.py +112 -0
  18. waldiez/exporting/agents/rag_user/rag_user.py +165 -0
  19. waldiez/exporting/agents/rag_user/vector_db.py +119 -0
  20. waldiez/exporting/agents/teachability.py +37 -0
  21. waldiez/exporting/agents/termination_message.py +45 -0
  22. waldiez/exporting/chats/__init__.py +14 -0
  23. waldiez/exporting/chats/chats.py +46 -0
  24. waldiez/exporting/chats/helpers.py +395 -0
  25. waldiez/exporting/chats/nested.py +264 -0
  26. waldiez/exporting/flow/__init__.py +5 -0
  27. waldiez/exporting/flow/def_main.py +37 -0
  28. waldiez/exporting/flow/flow.py +185 -0
  29. waldiez/exporting/models/__init__.py +193 -0
  30. waldiez/exporting/skills/__init__.py +128 -0
  31. waldiez/exporting/utils/__init__.py +34 -0
  32. waldiez/exporting/utils/comments.py +136 -0
  33. waldiez/exporting/utils/importing.py +267 -0
  34. waldiez/exporting/utils/logging_utils.py +203 -0
  35. waldiez/exporting/utils/method_utils.py +35 -0
  36. waldiez/exporting/utils/naming.py +127 -0
  37. waldiez/exporting/utils/object_string.py +81 -0
  38. waldiez/io_stream.py +181 -0
  39. waldiez/models/__init__.py +107 -0
  40. waldiez/models/agents/__init__.py +65 -0
  41. waldiez/models/agents/agent/__init__.py +21 -0
  42. waldiez/models/agents/agent/agent.py +190 -0
  43. waldiez/models/agents/agent/agent_data.py +162 -0
  44. waldiez/models/agents/agent/code_execution.py +71 -0
  45. waldiez/models/agents/agent/linked_skill.py +30 -0
  46. waldiez/models/agents/agent/nested_chat.py +73 -0
  47. waldiez/models/agents/agent/teachability.py +68 -0
  48. waldiez/models/agents/agent/termination_message.py +167 -0
  49. waldiez/models/agents/agents.py +129 -0
  50. waldiez/models/agents/assistant/__init__.py +6 -0
  51. waldiez/models/agents/assistant/assistant.py +41 -0
  52. waldiez/models/agents/assistant/assistant_data.py +29 -0
  53. waldiez/models/agents/group_manager/__init__.py +19 -0
  54. waldiez/models/agents/group_manager/group_manager.py +87 -0
  55. waldiez/models/agents/group_manager/group_manager_data.py +91 -0
  56. waldiez/models/agents/group_manager/speakers.py +211 -0
  57. waldiez/models/agents/rag_user/__init__.py +26 -0
  58. waldiez/models/agents/rag_user/rag_user.py +58 -0
  59. waldiez/models/agents/rag_user/rag_user_data.py +32 -0
  60. waldiez/models/agents/rag_user/retrieve_config.py +592 -0
  61. waldiez/models/agents/rag_user/vector_db_config.py +162 -0
  62. waldiez/models/agents/user_proxy/__init__.py +6 -0
  63. waldiez/models/agents/user_proxy/user_proxy.py +41 -0
  64. waldiez/models/agents/user_proxy/user_proxy_data.py +30 -0
  65. waldiez/models/chat/__init__.py +22 -0
  66. waldiez/models/chat/chat.py +129 -0
  67. waldiez/models/chat/chat_data.py +326 -0
  68. waldiez/models/chat/chat_message.py +304 -0
  69. waldiez/models/chat/chat_nested.py +160 -0
  70. waldiez/models/chat/chat_summary.py +110 -0
  71. waldiez/models/common/__init__.py +38 -0
  72. waldiez/models/common/base.py +63 -0
  73. waldiez/models/common/method_utils.py +165 -0
  74. waldiez/models/flow/__init__.py +9 -0
  75. waldiez/models/flow/flow.py +302 -0
  76. waldiez/models/flow/flow_data.py +87 -0
  77. waldiez/models/model/__init__.py +11 -0
  78. waldiez/models/model/model.py +169 -0
  79. waldiez/models/model/model_data.py +86 -0
  80. waldiez/models/skill/__init__.py +9 -0
  81. waldiez/models/skill/skill.py +129 -0
  82. waldiez/models/skill/skill_data.py +37 -0
  83. waldiez/models/waldiez.py +301 -0
  84. waldiez/py.typed +0 -0
  85. waldiez/runner.py +304 -0
  86. waldiez/stream/__init__.py +7 -0
  87. waldiez/stream/consumer.py +139 -0
  88. waldiez/stream/provider.py +339 -0
  89. waldiez/stream/server.py +412 -0
  90. waldiez-0.1.0.dist-info/METADATA +181 -0
  91. waldiez-0.1.0.dist-info/RECORD +94 -0
  92. waldiez-0.1.0.dist-info/WHEEL +4 -0
  93. waldiez-0.1.0.dist-info/entry_points.txt +2 -0
  94. waldiez-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,91 @@
1
+ """Group chat manager data."""
2
+
3
+ from typing import Optional
4
+
5
+ from pydantic import Field
6
+ from typing_extensions import Annotated, Literal
7
+
8
+ from ..agent import WaldiezAgentData
9
+ from .speakers import WaldiezGroupManagerSpeakers
10
+
11
+
12
+ class WaldiezGroupManagerData(WaldiezAgentData):
13
+ """Group chat manager data class.
14
+
15
+ The data for an agent with `human_input_mode` set to "NEVER" as default.
16
+ and the chat group's related extra properties.
17
+ See the parent's docs (`WaldiezAgentData`) for the rest of the properties.
18
+
19
+ Attributes
20
+ ----------
21
+ human_input_mode : Literal["ALWAYS", "NEVER", "TERMINATE"]
22
+ The human input mode, Defaults to `NEVER`
23
+ max_round : Optional[int]
24
+ The maximum number of rounds to have in the group.
25
+ admin_name : Optional[str]
26
+ The name of the group's admin.
27
+ Make sure you use a name of an agent in the group.
28
+ speakers : WaldiezGroupManagerSpeakers
29
+ The rules for the speaker selection and repetition
30
+ enable_clear_history : Optional[bool]
31
+ Enable clearing the history in the chat group.
32
+ send_introductions : bool
33
+ Send the group members' introductions.
34
+ """
35
+
36
+ human_input_mode: Annotated[
37
+ Literal["ALWAYS", "NEVER", "TERMINATE"],
38
+ Field(
39
+ "NEVER",
40
+ title="Human input mode",
41
+ description="The human input mode, Defaults to `NEVER`",
42
+ alias="humanInputMode",
43
+ ),
44
+ ]
45
+ max_round: Annotated[
46
+ Optional[int],
47
+ Field(
48
+ None,
49
+ title="Max round",
50
+ description="The maximum number of rounds to have in the group.",
51
+ alias="maxRound",
52
+ ),
53
+ ]
54
+ admin_name: Annotated[
55
+ Optional[str],
56
+ Field(
57
+ None,
58
+ title="Group Admin name",
59
+ description=(
60
+ "The name of the group's admin. "
61
+ "Make sure you use a name of an agent in the group."
62
+ ),
63
+ alias="adminName",
64
+ ),
65
+ ]
66
+ speakers: Annotated[
67
+ WaldiezGroupManagerSpeakers,
68
+ Field(
69
+ title="Speakers",
70
+ description="The rules for the speaker selection and repetition",
71
+ default_factory=WaldiezGroupManagerSpeakers,
72
+ ),
73
+ ]
74
+ enable_clear_history: Annotated[
75
+ Optional[bool],
76
+ Field(
77
+ None,
78
+ title="Enable clear history",
79
+ description="Enable clearing hte history in the chat group.",
80
+ alias="enableClearHistory",
81
+ ),
82
+ ]
83
+ send_introductions: Annotated[
84
+ bool,
85
+ Field(
86
+ False,
87
+ title="Send Introductions",
88
+ description="Send the group members' introductions.",
89
+ alias="sendIntroductions",
90
+ ),
91
+ ]
@@ -0,0 +1,211 @@
1
+ """Group chat speakers."""
2
+
3
+ from typing import Dict, List, Optional, Union
4
+
5
+ from pydantic import ConfigDict, Field, model_validator
6
+ from pydantic.alias_generators import to_camel
7
+ from typing_extensions import Annotated, Literal, Self
8
+
9
+ from ...common import WaldiezBase, WaldiezMethodName, check_function
10
+
11
+ WaldiezGroupManagerSpeakersSelectionMethod = Literal[
12
+ "auto",
13
+ "manual",
14
+ "random",
15
+ "round_robin",
16
+ "custom",
17
+ ]
18
+ WaldiezGroupManagerSpeakersSelectionMode = Literal["repeat", "transition"]
19
+ WaldiezGroupManagerSpeakersTransitionsType = Literal["allowed", "disallowed"]
20
+
21
+
22
+ class WaldiezGroupManagerSpeakers(WaldiezBase):
23
+ """Group chat speakers.
24
+
25
+ If the method for the speaker selection is `custom`
26
+ the `selection_custom_method` contents (source code) will be used.
27
+ The method must be called `custom_speaker_selection`,
28
+ have two arguments:
29
+
30
+ - last_speaker: `autogen.ConversableAgent`
31
+ - groupchat: `autogen.GroupChat`
32
+
33
+ and return a `Union[Agent, str, None]`
34
+
35
+ Example
36
+ -------
37
+ ```python
38
+ {
39
+ "selectionMethod": "custom",
40
+ "selectionCustomMethod": (
41
+ "def custom_speaker_selection(last_speaker, groupchat):\\n"
42
+ " return last_speaker"
43
+ ),
44
+ ...
45
+ }
46
+ ```
47
+
48
+ Attributes
49
+ ----------
50
+ selection_method : WaldiezGroupManagerSpeakersSelectionMethod
51
+ The next speaker selection method.
52
+ selection_custom_method : Optional[str]
53
+ Method for custom selection.
54
+ max_retries_for_selecting : Optional[int]
55
+ Max retries for selecting a speaker.
56
+ selection_mode : WaldiezGroupManagerSpeakersSelectionMode
57
+ Selection mode.
58
+ allow_repeat : Union[bool, List[str]]
59
+ Allow repeat.
60
+ allowed_or_disallowed_transitions : Dict[str, List[str]]
61
+ Allowed or disallowed transitions.
62
+ transitions_type : WaldiezGroupManagerSpeakersTransitionsType
63
+ The type of transition rules to use if
64
+ if a mapping (agent => List[agents]) is used:
65
+ `allowed` (default) or `disallowed`
66
+ custom_method_string : Optional[str]
67
+ The custom method string.
68
+
69
+ Functions
70
+ ---------
71
+ validate_group_speakers_config()
72
+ Validate the speakers config.
73
+ """
74
+
75
+ model_config = ConfigDict(
76
+ extra="forbid",
77
+ alias_generator=to_camel,
78
+ populate_by_name=True,
79
+ frozen=False,
80
+ )
81
+
82
+ selection_method: Annotated[
83
+ WaldiezGroupManagerSpeakersSelectionMethod,
84
+ Field(
85
+ "auto",
86
+ title="Selection Method",
87
+ description="The next speaker selection method",
88
+ alias="selectionMethod",
89
+ ),
90
+ ]
91
+ selection_custom_method: Annotated[
92
+ Optional[str],
93
+ Field(
94
+ None,
95
+ title="Method for custom selection.",
96
+ description=(
97
+ "If the method for the speaker selection if `custom`"
98
+ "These contents (source code) will be used. "
99
+ "The method must be called `custom_speaker_selection`, "
100
+ "have two arguments: "
101
+ " - last_speaker: `autogen.ConversableAgent`"
102
+ " - groupchat: `autogen.GroupChat`"
103
+ "and return a `Union[Agent, str, None]`"
104
+ ),
105
+ alias="selectionCustomMethod",
106
+ ),
107
+ ]
108
+ max_retries_for_selecting: Annotated[
109
+ Optional[int],
110
+ Field(
111
+ None,
112
+ title="Max retries for a selecting",
113
+ description=(
114
+ "The maximum number of retries for the group manager "
115
+ "for selecting the next speaker. Default: None (no limit)"
116
+ ),
117
+ alias="maxRetriesForSelecting",
118
+ ),
119
+ ]
120
+ selection_mode: Annotated[
121
+ WaldiezGroupManagerSpeakersSelectionMode,
122
+ Field(
123
+ "repeat",
124
+ title="Selection Mode",
125
+ description=(
126
+ "The method to use for selecting a next speaker: "
127
+ "Either using the speaker repetition or "
128
+ "the speaker transition rules"
129
+ ),
130
+ alias="selectionMode",
131
+ ),
132
+ ]
133
+ allow_repeat: Annotated[
134
+ Union[bool, List[str]],
135
+ Field(
136
+ True,
137
+ title="Allow repeat",
138
+ description=(
139
+ "The speakers' repetition mode: "
140
+ "Either a bool, or a list with agents to be allowed."
141
+ ),
142
+ alias="allowRepeat",
143
+ ),
144
+ ]
145
+ allowed_or_disallowed_transitions: Annotated[
146
+ Dict[str, List[str]],
147
+ Field(
148
+ default_factory=dict,
149
+ title="Allowed or disallowed transitions",
150
+ description=(
151
+ "A mapping (agent.id => List[agent.ids])",
152
+ "with the allowed or disallowed transitions.",
153
+ ),
154
+ alias="allowedOrDisallowedTransitions",
155
+ ),
156
+ ]
157
+ transitions_type: Annotated[
158
+ WaldiezGroupManagerSpeakersTransitionsType,
159
+ Field(
160
+ "allowed",
161
+ title="Transitions type",
162
+ description=(
163
+ "The type of transition rules to use if "
164
+ "if a mapping (agent => List[agents]) is used: "
165
+ "`allowed` (default) or `disallowed`"
166
+ ),
167
+ alias="transitionsType",
168
+ ),
169
+ ]
170
+
171
+ _custom_method_string: Optional[str] = None
172
+
173
+ @property
174
+ def custom_method_string(self) -> Optional[str]:
175
+ """Get the custom method string.
176
+
177
+ Returns
178
+ -------
179
+ str
180
+ The custom method string.
181
+ """
182
+ return self._custom_method_string
183
+
184
+ @model_validator(mode="after")
185
+ def validate_group_speakers_config(self) -> Self:
186
+ """Validate the speakers config.
187
+
188
+ Returns
189
+ -------
190
+ GroupManagerSpeakers
191
+ The group manager speakers config.
192
+
193
+ Raises
194
+ ------
195
+ ValueError
196
+ If the custom method is invalid.
197
+ """
198
+ if self.selection_method == "custom":
199
+ if not self.selection_custom_method:
200
+ raise ValueError("No custom method provided.")
201
+ function_name: WaldiezMethodName = "custom_speaker_selection"
202
+ is_valid, error_or_body = check_function(
203
+ self.selection_custom_method, function_name=function_name
204
+ )
205
+ if not is_valid or not error_or_body:
206
+ # pylint: disable=inconsistent-quotes
207
+ raise ValueError(
208
+ f"Invalid custom method: {error_or_body or 'no content'}"
209
+ )
210
+ self._custom_method_string = error_or_body
211
+ return self
@@ -0,0 +1,26 @@
1
+ """RAG user agent.
2
+ # pylint: disable=line-too-long
3
+ It extends a user agent and has RAG related parameters.
4
+ """
5
+
6
+ from .rag_user import WaldiezRagUser
7
+ from .rag_user_data import WaldiezRagUserData
8
+ from .retrieve_config import (
9
+ WaldiezRagUserChunkMode,
10
+ WaldiezRagUserModels,
11
+ WaldiezRagUserRetrieveConfig,
12
+ WaldiezRagUserTask,
13
+ WaldiezRagUserVectorDb,
14
+ )
15
+ from .vector_db_config import WaldiezRagUserVectorDbConfig
16
+
17
+ __all__ = [
18
+ "WaldiezRagUser",
19
+ "WaldiezRagUserData",
20
+ "WaldiezRagUserModels",
21
+ "WaldiezRagUserVectorDb",
22
+ "WaldiezRagUserChunkMode",
23
+ "WaldiezRagUserRetrieveConfig",
24
+ "WaldiezRagUserTask",
25
+ "WaldiezRagUserVectorDbConfig",
26
+ ]
@@ -0,0 +1,58 @@
1
+ # pylint: disable=line-too-long
2
+ """RAG user agent.
3
+ It extends a user agent and has RAG related parameters (`retrieve_config`).
4
+ """
5
+
6
+ from pydantic import Field
7
+ from typing_extensions import Annotated, Literal
8
+
9
+ from ..agent import WaldiezAgent
10
+ from .rag_user_data import WaldiezRagUserData
11
+ from .retrieve_config import WaldiezRagUserRetrieveConfig
12
+
13
+
14
+ class WaldiezRagUser(WaldiezAgent):
15
+ """RAG user agent.
16
+
17
+ It extends a user agent and has RAG related parameters.
18
+
19
+ Attributes
20
+ ----------
21
+ agent_type : Literal["rag_user"]
22
+ The agent type: 'rag_user' for a RAG user agent.
23
+ data : WaldiezRagUserData
24
+ The RAG user agent's data.
25
+ See `WaldiezRagUserData` for more info.
26
+ retrieve_config : WaldiezRagUserRetrieveConfig
27
+ The RAG user agent's retrieve config.
28
+ """
29
+
30
+ agent_type: Annotated[
31
+ Literal["rag_user"],
32
+ Field(
33
+ "rag_user",
34
+ title="Agent type",
35
+ description="The agent type: 'rag_user' for a RAG user agent",
36
+ alias="agentType",
37
+ ),
38
+ ]
39
+
40
+ data: Annotated[
41
+ WaldiezRagUserData,
42
+ Field(
43
+ title="Data",
44
+ description="The RAG user agent's data",
45
+ default_factory=WaldiezRagUserData,
46
+ ),
47
+ ]
48
+
49
+ @property
50
+ def retrieve_config(self) -> WaldiezRagUserRetrieveConfig:
51
+ """Get the retrieve config.
52
+
53
+ Returns
54
+ -------
55
+ WaldiezRagUserRetrieveConfig
56
+ The RAG user agent's retrieve config.
57
+ """
58
+ return self.data.retrieve_config
@@ -0,0 +1,32 @@
1
+ """Waldiez RAG user agent data."""
2
+
3
+ from pydantic import Field
4
+ from typing_extensions import Annotated
5
+
6
+ from ..user_proxy import WaldiezUserProxyData
7
+ from .retrieve_config import WaldiezRagUserRetrieveConfig
8
+
9
+
10
+ class WaldiezRagUserData(WaldiezUserProxyData):
11
+ """RAG user agent data.
12
+
13
+ The data for a RAG user agent.
14
+
15
+ Attributes
16
+ ----------
17
+ use_message_generator: bool
18
+ Whether to use the message generator in user's chats. Defaults to False.
19
+ retrieve_config : WaldiezRagUserRetrieveConfig
20
+ The RAG user agent's retrieve config.
21
+
22
+ """
23
+
24
+ retrieve_config: Annotated[
25
+ WaldiezRagUserRetrieveConfig,
26
+ Field(
27
+ title="Retrieve Config",
28
+ description="The RAG user agent's retrieve config",
29
+ default_factory=WaldiezRagUserRetrieveConfig,
30
+ alias="retrieveConfig",
31
+ ),
32
+ ]