waldiez 0.5.3__py3-none-any.whl → 0.5.5__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 (76) hide show
  1. waldiez/_version.py +1 -1
  2. waldiez/cli.py +3 -27
  3. waldiez/exporter.py +0 -13
  4. waldiez/exporting/agent/exporter.py +38 -0
  5. waldiez/exporting/agent/extras/__init__.py +2 -0
  6. waldiez/exporting/agent/extras/doc_agent_extras.py +366 -0
  7. waldiez/exporting/agent/extras/group_member_extras.py +3 -2
  8. waldiez/exporting/agent/processor.py +113 -15
  9. waldiez/exporting/chats/processor.py +2 -21
  10. waldiez/exporting/chats/utils/common.py +66 -1
  11. waldiez/exporting/chats/utils/group.py +6 -3
  12. waldiez/exporting/chats/utils/nested.py +1 -1
  13. waldiez/exporting/chats/utils/sequential.py +25 -9
  14. waldiez/exporting/chats/utils/single.py +8 -6
  15. waldiez/exporting/core/context.py +0 -12
  16. waldiez/exporting/core/extras/agent_extras/standard_extras.py +3 -1
  17. waldiez/exporting/core/extras/base.py +20 -17
  18. waldiez/exporting/core/extras/path_resolver.py +39 -41
  19. waldiez/exporting/core/extras/serializer.py +16 -1
  20. waldiez/exporting/core/protocols.py +17 -0
  21. waldiez/exporting/core/types.py +6 -9
  22. waldiez/exporting/flow/execution_generator.py +56 -21
  23. waldiez/exporting/flow/exporter.py +1 -4
  24. waldiez/exporting/flow/factory.py +0 -9
  25. waldiez/exporting/flow/file_generator.py +6 -0
  26. waldiez/exporting/flow/orchestrator.py +27 -21
  27. waldiez/exporting/flow/utils/__init__.py +0 -2
  28. waldiez/exporting/flow/utils/common.py +15 -96
  29. waldiez/exporting/flow/utils/importing.py +4 -0
  30. waldiez/io/mqtt.py +33 -14
  31. waldiez/io/redis.py +18 -13
  32. waldiez/io/structured.py +9 -4
  33. waldiez/io/utils.py +32 -0
  34. waldiez/io/ws.py +8 -2
  35. waldiez/models/__init__.py +6 -0
  36. waldiez/models/agents/__init__.py +8 -0
  37. waldiez/models/agents/agent/agent.py +136 -38
  38. waldiez/models/agents/agent/agent_type.py +3 -2
  39. waldiez/models/agents/agents.py +10 -0
  40. waldiez/models/agents/doc_agent/__init__.py +13 -0
  41. waldiez/models/agents/doc_agent/doc_agent.py +126 -0
  42. waldiez/models/agents/doc_agent/doc_agent_data.py +149 -0
  43. waldiez/models/agents/doc_agent/rag_query_engine.py +127 -0
  44. waldiez/models/flow/flow.py +13 -2
  45. waldiez/models/model/__init__.py +2 -2
  46. waldiez/models/model/_aws.py +75 -0
  47. waldiez/models/model/_llm.py +516 -0
  48. waldiez/models/model/_price.py +30 -0
  49. waldiez/models/model/model.py +45 -2
  50. waldiez/models/model/model_data.py +2 -83
  51. waldiez/models/tool/predefined/_duckduckgo.py +123 -0
  52. waldiez/models/tool/predefined/_google.py +31 -9
  53. waldiez/models/tool/predefined/_perplexity.py +161 -0
  54. waldiez/models/tool/predefined/_searxng.py +152 -0
  55. waldiez/models/tool/predefined/_tavily.py +46 -9
  56. waldiez/models/tool/predefined/_wikipedia.py +26 -6
  57. waldiez/models/tool/predefined/_youtube.py +36 -8
  58. waldiez/models/tool/predefined/registry.py +6 -0
  59. waldiez/models/waldiez.py +12 -0
  60. waldiez/runner.py +177 -408
  61. waldiez/running/__init__.py +2 -4
  62. waldiez/running/base_runner.py +100 -112
  63. waldiez/running/environment.py +29 -4
  64. waldiez/running/post_run.py +0 -1
  65. waldiez/running/protocol.py +36 -48
  66. waldiez/running/run_results.py +5 -5
  67. waldiez/running/standard_runner.py +429 -0
  68. waldiez/running/timeline_processor.py +0 -82
  69. {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/METADATA +59 -62
  70. {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/RECORD +74 -64
  71. waldiez/running/import_runner.py +0 -437
  72. waldiez/running/subprocess_runner.py +0 -104
  73. {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/WHEEL +0 -0
  74. {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/entry_points.txt +0 -0
  75. {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/licenses/LICENSE +0 -0
  76. {waldiez-0.5.3.dist-info → waldiez-0.5.5.dist-info}/licenses/NOTICE.md +0 -0
@@ -62,7 +62,7 @@ class TavilySearchToolImpl(PredefinedTool):
62
62
  list[str]
63
63
  List of missing required secrets.
64
64
  """
65
- missing = []
65
+ missing: list[str] = []
66
66
  if not secrets.get("TAVILY_API_KEY"):
67
67
  missing.append("TAVILY_API_KEY")
68
68
  return missing
@@ -101,14 +101,51 @@ class TavilySearchToolImpl(PredefinedTool):
101
101
  os.environ["TAVILY_API_KEY"] = secrets.get(
102
102
  "TAVILY_API_KEY", os.environ.get("TAVILY_API_KEY", "")
103
103
  )
104
- content = f"""
105
- tavily_api_key = os.environ.get("TAVILY_API_KEY", "")
106
- if not tavily_api_key:
107
- raise ValueError("TAVILY_API_KEY is required for Tavily search tool.")
108
- {self.name} = TavilySearchTool(
109
- tavily_api_key=tavily_api_key,
110
- )
111
- """
104
+ content = f'''
105
+ def {self.name}(
106
+ query: str,
107
+ tavily_api_key: str = os.environ.get("TAVILY_API_KEY", ""),
108
+ search_depth: str = "basic",
109
+ topic: str = "general",
110
+ include_answer: str = "basic",
111
+ include_raw_content: bool = False,
112
+ include_domains: list[str] = [],
113
+ num_results: int = 5,
114
+ ) -> list[dict[str, Any]]:
115
+ """Performs a search using the Tavily API and returns formatted results.
116
+
117
+ Args:
118
+ query: The search query string.
119
+ tavily_api_key: The API key for Tavily (injected dependency).
120
+ search_depth: The depth of the search ('basic' or 'advanced'). Defaults to "basic".
121
+ include_answer: Whether to include an AI-generated answer ('basic' or 'advanced'). Defaults to "basic".
122
+ include_raw_content: Whether to include raw content in the results. Defaults to False.
123
+ include_domains: A list of domains to include in the search. Defaults to [].
124
+ num_results: The maximum number of results to return. Defaults to 5.
125
+
126
+ Returns:
127
+ A list of dictionaries, each containing 'title', 'link', and 'snippet' of a search result.
128
+
129
+ Raises:
130
+ ValueError: If the Tavily API key is not available.
131
+ """
132
+ tavily_api_key = os.environ.get("TAVILY_API_KEY", "")
133
+ if not tavily_api_key:
134
+ raise ValueError("TAVILY_API_KEY is required for Tavily search tool.")
135
+ {self.name}_tool = TavilySearchTool(
136
+ tavily_api_key=tavily_api_key,
137
+ )
138
+ return {self.name}_tool(
139
+ query=query,
140
+ tavily_api_key=tavily_api_key,
141
+ search_depth=search_depth,
142
+ topic=topic,
143
+ include_answer=include_answer,
144
+ include_raw_content=include_raw_content,
145
+ include_domains=include_domains,
146
+ num_results=num_results,
147
+ )
148
+ '''
112
149
  return content
113
150
 
114
151
 
@@ -1,5 +1,7 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+ # pylint: disable=line-too-long
4
+ # flake8: noqa: E501
3
5
  """Predefined Wikipedia search tool for Waldiez."""
4
6
 
5
7
  from typing import Any
@@ -84,11 +86,11 @@ class WikipediaSearchToolImpl(PredefinedTool):
84
86
  list[str]
85
87
  List of missing required keyword arguments.
86
88
  """
87
- for key, _ in self.kwargs.items():
89
+ for key, value in self.kwargs.items():
88
90
  if key in kwargs:
89
- type_of = self.required_kwargs.get(key, str)
91
+ type_of = self.kwargs_types.get(key, str)
90
92
  try:
91
- casted = type_of(kwargs[key])
93
+ casted = type_of(value)
92
94
  if key in self.kwargs:
93
95
  self.kwargs[key] = casted
94
96
  except Exception: # pylint: disable=broad-except
@@ -111,10 +113,28 @@ class WikipediaSearchToolImpl(PredefinedTool):
111
113
  str
112
114
  Content of the tool.
113
115
  """
114
- content = f"{self.name} = WikipediaQueryRunTool(\n"
116
+ content = f'''
117
+ def {self.name}(query: str, language: str = "en", top_k: int = 3, verbose: bool = False) -> Union[list[str], str]:
118
+ """Search Wikipedia for a given query and return results.
119
+
120
+ Args:
121
+ query: The search query string.
122
+ language: The language to search in (default: "en").
123
+ top_k: The number of top results to return (default: 3).
124
+ verbose: Whether to include additional information in the results (default: False).
125
+
126
+ Returns
127
+ -------
128
+ Union[list[str], str]: A list of search results or a message if no results found.
129
+ """
130
+ tool = WikipediaQueryRunTool(
131
+ '''
115
132
  for key, value in self.kwargs.items():
116
- content += f" {key}={value!r},\n"
117
- content += ")\n"
133
+ content += f" {key}={value!r},\n"
134
+ content += " )\n"
135
+ content += """
136
+ return tool(query=query)
137
+ """
118
138
  return content
119
139
 
120
140
 
@@ -1,5 +1,7 @@
1
1
  # SPDX-License-Identifier: Apache-2.0.
2
2
  # Copyright (c) 2024 - 2025 Waldiez and contributors.
3
+ # pylint: disable=line-too-long
4
+ # flake8: noqa: E501
3
5
  """Predefined YouTube search tool for Waldiez."""
4
6
 
5
7
  import os
@@ -100,14 +102,40 @@ class YouTubeSearchToolImpl(PredefinedTool):
100
102
  The content for the tool.
101
103
  """
102
104
  os.environ["YOUTUBE_API_KEY"] = secrets.get("YOUTUBE_API_KEY", "")
103
- content = f"""
104
- youtube_api_key = os.environ.get("YOUTUBE_API_KEY", "")
105
- if not youtube_api_key:
106
- raise ValueError("YOUTUBE_API_KEY is required for YouTube search tool.")
107
- {self.name} = YoutubeSearchTool(
108
- youtube_api_key=youtube_api_key,
109
- )
110
- """
105
+ content = f'''
106
+ def {self.name}(
107
+ query: str,
108
+ youtube_api_key: str = os.environ.get("YOUTUBE_API_KEY", ""),
109
+ max_results: int = 5,
110
+ include_video_details: bool = True,
111
+ ) -> list[dict[str, Any]]:
112
+ """Perform a YouTube search and return formatted results.
113
+
114
+ Args:
115
+ query: The search query string.
116
+ youtube_api_key: The API key for the YouTube Data API.
117
+ max_results: The maximum number of results to return. Defaults to 5.
118
+ include_video_details: Whether to include detailed video information. Defaults to True.
119
+
120
+ Returns:
121
+ A list of dictionaries of the search results.
122
+
123
+ Raises:
124
+ ValueError: If YOUTUBE_API_KEY is not set or if the search fails.
125
+ """
126
+ youtube_api_key = os.environ.get("YOUTUBE_API_KEY", "")
127
+ if not youtube_api_key:
128
+ raise ValueError("YOUTUBE_API_KEY is required for YouTube search tool.")
129
+ youtube_search_tool = YoutubeSearchTool(
130
+ youtube_api_key=youtube_api_key,
131
+ )
132
+ return youtube_search_tool(
133
+ query=query,
134
+ youtube_api_key=youtube_api_key,
135
+ max_results=max_results,
136
+ include_video_details=include_video_details,
137
+ )
138
+ '''
111
139
  return content
112
140
 
113
141
 
@@ -3,7 +3,10 @@
3
3
  """Predefined tools registry for Waldiez."""
4
4
 
5
5
  from ._config import PredefinedToolConfig
6
+ from ._duckduckgo import DuckDuckGoSearchConfig
6
7
  from ._google import GoogleSearchConfig
8
+ from ._perplexity import PerplexitySearchConfig
9
+ from ._searxng import SearxNGSearchConfig
7
10
  from ._tavily import TavilySearchConfig
8
11
  from ._wikipedia import WikipediaSearchConfig
9
12
  from ._youtube import YouTubeSearchConfig
@@ -13,6 +16,9 @@ PREDEFINED_TOOLS: dict[str, PredefinedToolConfig] = {
13
16
  WikipediaSearchConfig.name: WikipediaSearchConfig,
14
17
  YouTubeSearchConfig.name: YouTubeSearchConfig,
15
18
  TavilySearchConfig.name: TavilySearchConfig,
19
+ DuckDuckGoSearchConfig.name: DuckDuckGoSearchConfig,
20
+ PerplexitySearchConfig.name: PerplexitySearchConfig,
21
+ SearxNGSearchConfig.name: SearxNGSearchConfig,
16
22
  }
17
23
 
18
24
 
waldiez/models/waldiez.py CHANGED
@@ -163,6 +163,11 @@ class Waldiez:
163
163
  """Check if the flow has RAG agents."""
164
164
  return any(agent.is_rag_user for agent in self.agents)
165
165
 
166
+ @property
167
+ def has_doc_agents(self) -> bool:
168
+ """Check if the flow has document agents."""
169
+ return any(agent.is_doc_agent for agent in self.agents)
170
+
166
171
  @property
167
172
  def has_multimodal_agents(self) -> bool:
168
173
  """Check if the flow has multimodal agents."""
@@ -277,6 +282,13 @@ class Waldiez:
277
282
  if self.has_captain_agents: # pragma: no branch
278
283
  captain_extras = get_captain_agent_extra_requirements()
279
284
  requirements.update(captain_extras)
285
+ for doc_agent in self.flow.data.agents.docAgents:
286
+ requirements.update(
287
+ doc_agent.get_llm_requirements(
288
+ ag2_version=autogen_version,
289
+ all_models=list(self.models),
290
+ )
291
+ )
280
292
  requirements.update(
281
293
  get_models_extra_requirements(
282
294
  self.models,