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,162 @@
1
+ """The vector db config for the RAG user agent."""
2
+
3
+ from pathlib import Path
4
+ from typing import Any, Dict, Optional
5
+
6
+ from pydantic import ConfigDict, Field, model_validator
7
+ from pydantic.alias_generators import to_camel
8
+ from typing_extensions import Annotated, Self
9
+
10
+ from ...common import WaldiezBase
11
+
12
+
13
+ # pylint: disable=line-too-long
14
+ class WaldiezRagUserVectorDbConfig(WaldiezBase):
15
+ """The config for the vector db.
16
+
17
+ Attributes
18
+ ----------
19
+ model : str
20
+ The model to use for the vector db embeddings.
21
+ use_memory : bool
22
+ Whether to use memory for the vector db (if `qdrant` is used).
23
+ use_local_storage : bool
24
+ Whether to use local storage for the db (if `qdrant` or `chroma` is used).
25
+ local_storage_path : Optional[str]
26
+ The path to the local storage for the vector db (if `qdrant` or `chroma` is used).
27
+ connection_url : Optional[str]
28
+ The connection url for the vector db.
29
+ wait_until_index_ready : Optional[float]
30
+ Blocking call to wait until the database indexes are ready (if `mongodb` is used).
31
+ None, the default, means no wait.
32
+ wait_until_document_ready : Optional[float]
33
+ Blocking call to wait until the database documents are ready (if `mongodb` is used).
34
+ None, the default, means no wait.
35
+ metadata : Optional[Dict[str, Any]]
36
+ The metadata to use for the vector db.
37
+ Example: {"hnsw:space": "ip", "hnsw:construction_ef": 30, "hnsw:M": 32}
38
+
39
+ Functions
40
+ ---------
41
+ validate_vector_db_config()
42
+ Validate the vector db config.
43
+ """
44
+
45
+ model_config = ConfigDict(
46
+ extra="forbid",
47
+ alias_generator=to_camel,
48
+ populate_by_name=True,
49
+ frozen=False,
50
+ protected_namespaces=(), # we use "model" as a field
51
+ )
52
+
53
+ model: Annotated[
54
+ Optional[str],
55
+ Field(
56
+ None,
57
+ title="Model",
58
+ description="The model to use for the vector db embeddings.",
59
+ ),
60
+ ]
61
+ use_memory: Annotated[
62
+ bool,
63
+ Field(
64
+ True,
65
+ title="Use Memory",
66
+ description=(
67
+ "Whether to use memory for the vector db (if qdrant is used)."
68
+ ),
69
+ ),
70
+ ]
71
+ use_local_storage: Annotated[
72
+ bool,
73
+ Field(
74
+ False,
75
+ title="Use Local Storage",
76
+ description=(
77
+ "Whether to use local storage for the vector db "
78
+ "(if qdrant or chroma is used)."
79
+ ),
80
+ ),
81
+ ]
82
+ local_storage_path: Annotated[
83
+ Optional[str],
84
+ Field(
85
+ None,
86
+ title="Local Storage Path",
87
+ description=(
88
+ "The path to the local storage for the vector db "
89
+ "(if qdrant is used)."
90
+ ),
91
+ ),
92
+ ]
93
+ connection_url: Annotated[
94
+ Optional[str],
95
+ Field(
96
+ None,
97
+ title="Connection URL",
98
+ description="The connection url for the vector db.",
99
+ ),
100
+ ]
101
+ wait_until_index_ready: Annotated[
102
+ Optional[float],
103
+ Field(
104
+ None,
105
+ title="Wait Until Index Ready",
106
+ description=(
107
+ "The time to wait/block until the database indexes are ready. "
108
+ "None, the default, means no wait."
109
+ ),
110
+ ),
111
+ ]
112
+ wait_until_document_ready: Annotated[
113
+ Optional[float],
114
+ Field(
115
+ None,
116
+ title="Wait Until Document Ready",
117
+ description=(
118
+ "The time to wait/block until the database documents "
119
+ "are ready. None, the default, means no wait."
120
+ ),
121
+ ),
122
+ ]
123
+ metadata: Annotated[
124
+ Optional[Dict[str, Any]],
125
+ Field(
126
+ None,
127
+ title="Metadata",
128
+ description=(
129
+ "The metadata to use for the vector db. Example: "
130
+ '"{"hnsw:space": "ip", '
131
+ '"hnsw:construction_ef": 30, '
132
+ '"hnsw:M": 32}'
133
+ ),
134
+ ),
135
+ ]
136
+
137
+ @model_validator(mode="after")
138
+ def validate_vector_db_config(self) -> Self:
139
+ """Validate the vector db config.
140
+
141
+ if local storage is used, make sure the path is provided,
142
+ and make it absolute if not already.
143
+
144
+ Returns
145
+ -------
146
+ WaldiezRagUserVectorDbConfig
147
+ The vector db config.
148
+
149
+ Raises
150
+ ------
151
+ ValueError
152
+ If the validation fails.
153
+ """
154
+ if self.use_local_storage:
155
+ if self.local_storage_path is None:
156
+ raise ValueError(
157
+ "The local storage path must be provided if local storage is used."
158
+ )
159
+ as_path = Path(self.local_storage_path)
160
+ if not as_path.is_absolute():
161
+ self.local_storage_path = str(as_path.resolve())
162
+ return self
@@ -0,0 +1,6 @@
1
+ """User proxy agent model."""
2
+
3
+ from .user_proxy import WaldiezUserProxy
4
+ from .user_proxy_data import WaldiezUserProxyData
5
+
6
+ __all__ = ["WaldiezUserProxy", "WaldiezUserProxyData"]
@@ -0,0 +1,41 @@
1
+ """User proxy agent model."""
2
+
3
+ from pydantic import Field
4
+ from typing_extensions import Annotated, Literal
5
+
6
+ from ..agent import WaldiezAgent
7
+ from .user_proxy_data import WaldiezUserProxyData
8
+
9
+
10
+ class WaldiezUserProxy(WaldiezAgent):
11
+ """User proxy agent model.
12
+
13
+ A `WaldiezAgent` with agent_type `user` and
14
+ default `human_input_mode`: `"ALWAYS"`
15
+ See `WaldiezAgent`,`WaldiezUserProxyData`,`WaldiezAgentData` for more info.
16
+
17
+ Attributes
18
+ ----------
19
+ agent_type : Literal["user"]
20
+ The agent type: 'user' for a user proxy agent
21
+ data : WaldiezUserProxyData
22
+ The user proxy agent's data
23
+ """
24
+
25
+ agent_type: Annotated[
26
+ Literal["user"],
27
+ Field(
28
+ "user",
29
+ title="Agent type",
30
+ description="The agent type in a graph: 'user'",
31
+ alias="agentType",
32
+ ),
33
+ ]
34
+ data: Annotated[
35
+ WaldiezUserProxyData,
36
+ Field(
37
+ title="Data",
38
+ description="The user proxy agent's data",
39
+ default_factory=WaldiezUserProxyData,
40
+ ),
41
+ ]
@@ -0,0 +1,30 @@
1
+ """User proxy agent data module."""
2
+
3
+ from pydantic import Field
4
+ from typing_extensions import Annotated, Literal
5
+
6
+ from ..agent import WaldiezAgentData
7
+
8
+
9
+ class WaldiezUserProxyData(WaldiezAgentData):
10
+ """User proxy agent data class.
11
+
12
+ The data for an agent with `human_input_mode`
13
+ set to `"ALWAYS"` as default.
14
+ See the parent's docs (`WaldiezAgentData`) for the rest of the properties.
15
+
16
+ Attributes
17
+ ----------
18
+ human_input_mode : Literal["ALWAYS", "NEVER", "TERMINATE"]
19
+ The human input mode, Defaults to `ALWAYS`
20
+ """
21
+
22
+ human_input_mode: Annotated[
23
+ Literal["ALWAYS", "NEVER", "TERMINATE"],
24
+ Field(
25
+ "ALWAYS",
26
+ title="Human input mode",
27
+ description="The human input mode, Defaults to `ALWAYS`",
28
+ alias="humanInputMode",
29
+ ),
30
+ ]
@@ -0,0 +1,22 @@
1
+ """Waldiez chat related models."""
2
+
3
+ from .chat import WaldiezChat
4
+ from .chat_data import WaldiezChatData
5
+ from .chat_message import (
6
+ WaldiezChatMessage,
7
+ WaldiezChatMessageType,
8
+ validate_message_dict,
9
+ )
10
+ from .chat_nested import WaldiezChatNested
11
+ from .chat_summary import WaldiezChatSummary, WaldiezChatSummaryMethod
12
+
13
+ __all__ = [
14
+ "WaldiezChat",
15
+ "WaldiezChatData",
16
+ "WaldiezChatMessage",
17
+ "WaldiezChatMessageType",
18
+ "WaldiezChatNested",
19
+ "WaldiezChatSummary",
20
+ "WaldiezChatSummaryMethod",
21
+ "validate_message_dict",
22
+ ]
@@ -0,0 +1,129 @@
1
+ """Waldiez chat model."""
2
+
3
+ from typing import Any, Dict, Optional
4
+
5
+ from pydantic import Field
6
+ from typing_extensions import Annotated
7
+
8
+ from ..agents import WaldiezAgent, WaldiezRagUser
9
+ from ..common import WaldiezBase
10
+ from .chat_data import WaldiezChatData
11
+ from .chat_message import WaldiezChatMessage
12
+ from .chat_nested import WaldiezChatNested
13
+
14
+
15
+ class WaldiezChat(WaldiezBase):
16
+ """Chat class.
17
+
18
+ Attributes
19
+ ----------
20
+ id : str
21
+ The chat ID.
22
+ data : WaldiezChatData
23
+ The chat data.
24
+ See `waldiez.models.chat.WaldiezChatData` for more information.
25
+ name : str
26
+ The chat name.
27
+ source : str
28
+ The chat source.
29
+ target : str
30
+ The chat target.
31
+ nested_chat : WaldiezChatNested
32
+ The nested chat message/reply if any.
33
+ message : WaldiezChatMessage
34
+ The chat message.
35
+ message_content : Optional[str]
36
+ The chat message content if any. If method, the method's body.
37
+
38
+ Functions
39
+ ---------
40
+ get_chat_args()
41
+ Get the chat arguments to use in autogen.
42
+ """
43
+
44
+ id: Annotated[
45
+ str,
46
+ Field(
47
+ ...,
48
+ title="ID",
49
+ description="The chat ID.",
50
+ ),
51
+ ]
52
+ data: Annotated[
53
+ WaldiezChatData,
54
+ Field(
55
+ ...,
56
+ title="Data",
57
+ description="The chat data.",
58
+ ),
59
+ ]
60
+
61
+ @property
62
+ def name(self) -> str:
63
+ """Get the name."""
64
+ return self.data.name
65
+
66
+ @property
67
+ def source(self) -> str:
68
+ """Get the source."""
69
+ if self.data.real_source:
70
+ return self.data.real_source
71
+ return self.data.source
72
+
73
+ @property
74
+ def target(self) -> str:
75
+ """Get the target."""
76
+ if self.data.real_target:
77
+ return self.data.real_target
78
+ return self.data.target
79
+
80
+ @property
81
+ def nested_chat(self) -> WaldiezChatNested:
82
+ """Get the nested chat."""
83
+ return self.data.nested_chat
84
+
85
+ @property
86
+ def message(self) -> WaldiezChatMessage:
87
+ """Get the message."""
88
+ if isinstance(
89
+ self.data.message, str
90
+ ): # pragma: no cover (just for the lint)
91
+ return WaldiezChatMessage(
92
+ type="string",
93
+ use_carryover=False,
94
+ content=self.data.message,
95
+ context={},
96
+ )
97
+ return self.data.message
98
+
99
+ @property
100
+ def message_content(self) -> Optional[str]:
101
+ """Get the message content."""
102
+ return self.data.message_content
103
+
104
+ def get_chat_args(
105
+ self,
106
+ sender: Optional[WaldiezAgent] = None,
107
+ ) -> Dict[str, Any]:
108
+ """Get the chat arguments to use in autogen.
109
+
110
+ Parameters
111
+ ----------
112
+ sender : WaldiezAgent
113
+ The sender agent, to check if it's a RAG user.
114
+ Returns
115
+ -------
116
+ dict
117
+ The chat arguments.
118
+ """
119
+ args_dict = self.data.get_chat_args()
120
+ if (
121
+ isinstance(sender, WaldiezRagUser)
122
+ and sender.agent_type == "rag_user"
123
+ and self.message.type == "rag_message_generator"
124
+ ):
125
+ # check for n_results in agent data, to add in context
126
+ n_results = sender.data.retrieve_config.n_results
127
+ if isinstance(n_results, int) and n_results > 0:
128
+ args_dict["n_results"] = n_results
129
+ return args_dict