waldiez 0.1.1__tar.gz → 0.1.3__tar.gz

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 (95) hide show
  1. {waldiez-0.1.1 → waldiez-0.1.3}/PKG-INFO +2 -2
  2. {waldiez-0.1.1 → waldiez-0.1.3}/README.md +1 -1
  3. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/_version.py +1 -1
  4. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/agents/rag_user/rag_user.py +16 -5
  5. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/flow/flow.py +9 -4
  6. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/models/__init__.py +69 -20
  7. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/utils/__init__.py +2 -0
  8. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/utils/importing.py +9 -11
  9. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/utils/object_string.py +2 -0
  10. waldiez-0.1.3/waldiez/exporting/utils/path_check.py +48 -0
  11. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/agent/agent_data.py +2 -13
  12. {waldiez-0.1.1 → waldiez-0.1.3}/.gitignore +0 -0
  13. {waldiez-0.1.1 → waldiez-0.1.3}/LICENSE +0 -0
  14. {waldiez-0.1.1 → waldiez-0.1.3}/pyproject.toml +0 -0
  15. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/__init__.py +0 -0
  16. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/__main__.py +0 -0
  17. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/cli.py +0 -0
  18. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporter.py +0 -0
  19. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/__init__.py +0 -0
  20. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/agents/__init__.py +0 -0
  21. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/agents/agent.py +0 -0
  22. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/agents/agent_skills.py +0 -0
  23. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/agents/code_execution.py +0 -0
  24. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/agents/group_manager.py +0 -0
  25. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/agents/llm_config.py +0 -0
  26. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/agents/rag_user/__init__.py +0 -0
  27. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/agents/rag_user/chroma_utils.py +0 -0
  28. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/agents/rag_user/mongo_utils.py +0 -0
  29. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/agents/rag_user/pgvector_utils.py +0 -0
  30. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/agents/rag_user/qdrant_utils.py +0 -0
  31. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/agents/rag_user/vector_db.py +0 -0
  32. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/agents/teachability.py +0 -0
  33. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/agents/termination_message.py +0 -0
  34. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/chats/__init__.py +0 -0
  35. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/chats/chats.py +0 -0
  36. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/chats/helpers.py +0 -0
  37. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/chats/nested.py +0 -0
  38. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/flow/__init__.py +0 -0
  39. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/flow/def_main.py +0 -0
  40. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/skills/__init__.py +0 -0
  41. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/utils/comments.py +0 -0
  42. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/utils/logging_utils.py +0 -0
  43. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/utils/method_utils.py +0 -0
  44. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/exporting/utils/naming.py +0 -0
  45. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/io_stream.py +0 -0
  46. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/__init__.py +0 -0
  47. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/__init__.py +0 -0
  48. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/agent/__init__.py +0 -0
  49. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/agent/agent.py +0 -0
  50. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/agent/code_execution.py +0 -0
  51. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/agent/linked_skill.py +0 -0
  52. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/agent/nested_chat.py +0 -0
  53. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/agent/teachability.py +0 -0
  54. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/agent/termination_message.py +0 -0
  55. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/agents.py +0 -0
  56. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/assistant/__init__.py +0 -0
  57. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/assistant/assistant.py +0 -0
  58. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/assistant/assistant_data.py +0 -0
  59. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/group_manager/__init__.py +0 -0
  60. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/group_manager/group_manager.py +0 -0
  61. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/group_manager/group_manager_data.py +0 -0
  62. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/group_manager/speakers.py +0 -0
  63. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/rag_user/__init__.py +0 -0
  64. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/rag_user/rag_user.py +0 -0
  65. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/rag_user/rag_user_data.py +0 -0
  66. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/rag_user/retrieve_config.py +0 -0
  67. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/rag_user/vector_db_config.py +0 -0
  68. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/user_proxy/__init__.py +0 -0
  69. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/user_proxy/user_proxy.py +0 -0
  70. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/agents/user_proxy/user_proxy_data.py +0 -0
  71. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/chat/__init__.py +0 -0
  72. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/chat/chat.py +0 -0
  73. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/chat/chat_data.py +0 -0
  74. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/chat/chat_message.py +0 -0
  75. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/chat/chat_nested.py +0 -0
  76. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/chat/chat_summary.py +0 -0
  77. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/common/__init__.py +0 -0
  78. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/common/base.py +0 -0
  79. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/common/method_utils.py +0 -0
  80. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/flow/__init__.py +0 -0
  81. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/flow/flow.py +0 -0
  82. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/flow/flow_data.py +0 -0
  83. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/model/__init__.py +0 -0
  84. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/model/model.py +0 -0
  85. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/model/model_data.py +0 -0
  86. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/skill/__init__.py +0 -0
  87. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/skill/skill.py +0 -0
  88. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/skill/skill_data.py +0 -0
  89. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/models/waldiez.py +0 -0
  90. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/py.typed +0 -0
  91. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/runner.py +0 -0
  92. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/stream/__init__.py +0 -0
  93. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/stream/consumer.py +0 -0
  94. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/stream/provider.py +0 -0
  95. {waldiez-0.1.1 → waldiez-0.1.3}/waldiez/stream/server.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: waldiez
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: waldiez
5
5
  Project-URL: homepage, https://waldiez.github.io/py/
6
6
  Project-URL: repository, https://github.com/waldiez/py.git
@@ -177,4 +177,4 @@ io_stream.close()
177
177
 
178
178
  ## License
179
179
 
180
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
180
+ This project is licensed under the MIT License - see the [LICENSE](https://github.com/waldiez/py/blob/main/LICENSE) file for details.
@@ -103,4 +103,4 @@ io_stream.close()
103
103
 
104
104
  ## License
105
105
 
106
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
106
+ This project is licensed under the MIT License - see the [LICENSE](https://github.com/waldiez/py/blob/main/LICENSE) file for details.
@@ -1,3 +1,3 @@
1
1
  """Version information for Waldiez."""
2
2
 
3
- __version__ = "0.1.1"
3
+ __version__ = "0.1.3"
@@ -1,6 +1,6 @@
1
1
  """RAG User related exporting utils."""
2
2
 
3
- from typing import Dict, Set, Tuple
3
+ from typing import Dict, List, Set, Tuple, Union
4
4
 
5
5
  from waldiez.models import (
6
6
  WaldiezAgent,
@@ -9,7 +9,7 @@ from waldiez.models import (
9
9
  WaldiezRagUserRetrieveConfig,
10
10
  )
11
11
 
12
- from ...utils import get_object_string
12
+ from ...utils import get_object_string, get_path_string
13
13
  from .vector_db import get_rag_user_vector_db_string
14
14
 
15
15
 
@@ -60,6 +60,7 @@ def get_rag_user_retrieve_config_str(
60
60
  "\n\n"
61
61
  )
62
62
  args_dict["custom_text_split_function"] = text_split_arg_name
63
+ # docs_path = args_dict.pop("docs_path", [])
63
64
  args_content = get_object_string(args_dict)
64
65
  # get the last line (where the dict ends)
65
66
  args_parts = args_content.split("\n")
@@ -131,9 +132,9 @@ def _get_args_dict(
131
132
  agent: WaldiezRagUser,
132
133
  retrieve_config: WaldiezRagUserRetrieveConfig,
133
134
  model_names: Dict[str, str],
134
- ) -> Dict[str, str]:
135
+ ) -> Dict[str, Union[str, List[str]]]:
135
136
  model_arg = _get_model_arg(agent, retrieve_config, model_names)
136
- args_dict = {
137
+ args_dict: Dict[str, Union[str, List[str]]] = {
137
138
  "task": retrieve_config.task,
138
139
  "model": model_arg,
139
140
  }
@@ -142,13 +143,23 @@ def _get_args_dict(
142
143
  "context_max_tokens",
143
144
  "customized_prompt",
144
145
  "customized_answer_prefix",
145
- "docs_path",
146
146
  ]
147
147
  for arg in optional_args:
148
148
  arg_value = getattr(retrieve_config, arg)
149
149
  if arg_value is not None:
150
150
  args_dict[arg] = arg_value
151
151
  args_dict[arg] = getattr(retrieve_config, arg)
152
+ docs_path: Union[str, List[str]] = []
153
+ if retrieve_config.docs_path:
154
+ docs_path = (
155
+ retrieve_config.docs_path
156
+ if isinstance(retrieve_config.docs_path, list)
157
+ else [retrieve_config.docs_path]
158
+ )
159
+ docs_path = [get_path_string(path) for path in docs_path]
160
+ args_dict["docs_path"] = docs_path
161
+ if docs_path:
162
+ args_dict["docs_path"] = docs_path
152
163
  non_optional_args = [
153
164
  "new_docs",
154
165
  "update_context",
@@ -80,19 +80,22 @@ def export_flow(
80
80
  "import os",
81
81
  "import sqlite3",
82
82
  }
83
- other_imports: Set[str] = {
83
+ common_imports: Set[str] = {
84
84
  "from autogen import Agent",
85
85
  "from autogen import ConversableAgent",
86
86
  "from autogen import ChatResult",
87
87
  "from autogen import runtime_logging",
88
88
  }
89
+ local_imports: Set[str] = {
90
+ "from waldiez_api_keys import get_model_api_key",
91
+ }
89
92
  skill_imports, _ = export_skills(
90
93
  skills=all_skills,
91
94
  skill_names=skill_names,
92
95
  output_dir=output_dir,
93
96
  )
94
97
  if len(waldiez.chats) > 1:
95
- other_imports.add("from autogen import initiate_chats")
98
+ common_imports.add("from autogen import initiate_chats")
96
99
  for agent in all_agents:
97
100
  agent_string, after_agent, agent_imports = export_agent(
98
101
  agent=agent,
@@ -103,7 +106,7 @@ def export_flow(
103
106
  all_skills=all_skills,
104
107
  group_chat_members=waldiez.flow.get_group_chat_members(agent.id),
105
108
  )
106
- other_imports.update(agent_imports)
109
+ common_imports.update(agent_imports)
107
110
  if after_agent:
108
111
  skipped_agent_strings += after_agent
109
112
  if agent.agent_type == "manager":
@@ -123,11 +126,13 @@ def export_flow(
123
126
  all_models=all_models,
124
127
  model_names=model_names,
125
128
  notebook=notebook,
129
+ output_dir=output_dir,
126
130
  )
127
131
  all_imports_string = get_imports_string(
128
- imports=other_imports,
132
+ imports=common_imports,
129
133
  builtin_imports=builtin_imports,
130
134
  skill_imports=skill_imports,
135
+ local_imports=local_imports,
131
136
  )
132
137
  return _combine_strings(
133
138
  waldiez=waldiez,
@@ -6,7 +6,8 @@ export_models
6
6
  Get the string representations of the LLM configs.
7
7
  """
8
8
 
9
- from typing import Dict, List
9
+ from pathlib import Path
10
+ from typing import Dict, List, Optional
10
11
 
11
12
  from waldiez.models import WaldiezModel
12
13
 
@@ -17,6 +18,7 @@ def export_models(
17
18
  all_models: List[WaldiezModel],
18
19
  model_names: Dict[str, str],
19
20
  notebook: bool,
21
+ output_dir: Optional[Path] = None,
20
22
  ) -> str:
21
23
  """Get the string representations of the LLM configs.
22
24
 
@@ -28,7 +30,8 @@ def export_models(
28
30
  A mapping of model ids to model names.
29
31
  notebook : bool
30
32
  Whether to export the string for a jupyter notebook.
31
-
33
+ output_dir : Optional[Path]
34
+ The output directory to write the api keys.
32
35
  Returns
33
36
  -------
34
37
  str
@@ -38,7 +41,8 @@ def export_models(
38
41
  -------
39
42
  ```python
40
43
  >>> from waldiez.models import WaldiezModel, WaldiezModelData
41
- >>> model = WaldiezModel(
44
+ >>> api_key = "1234567890"
45
+ ... model = WaldiezModel(
42
46
  ... id="wm-1",
43
47
  ... name="llama3.1" ,
44
48
  ... description="A model for llamas :P.",
@@ -46,7 +50,7 @@ def export_models(
46
50
  ... requirements=[],
47
51
  ... data=WaldiezModelData(
48
52
  ... base_url="https://example.com/v1",
49
- ... api_key="1234567890",
53
+ ... api_key=api_key,
50
54
  ... api_type="openai",
51
55
  ... temperature=0.5,
52
56
  ... price={
@@ -61,9 +65,9 @@ def export_models(
61
65
  # # Models
62
66
  llama3_1_llm_config = {
63
67
  "config_list": [{
64
- "model": "llama3.1",
68
+ "model": "llama3_1",
65
69
  "base_url": "https://example.com/v1",
66
- "api_key": "1234567890",
70
+ "api_key": get_model_api_key("llama3_1"),
67
71
  "api_type": "openai",
68
72
  "temperature": 0.5,
69
73
  "price": [0.0001, 0.0002],
@@ -72,26 +76,22 @@ def export_models(
72
76
  ```
73
77
  """
74
78
  content = get_comment("models", notebook) + "\n"
75
- if len(all_models) == 1:
76
- only_model = all_models[0]
77
- model_name = model_names[only_model.id]
78
- llm_config = only_model.get_llm_config()
79
+ for model in all_models:
80
+ model_name = model_names[model.id]
81
+ llm_config = model.get_llm_config()
82
+ llm_config["api_key"] = f'get_model_api_key("{model_name}")'
79
83
  model_dict_str = get_object_string(llm_config, tabs=2)
84
+ model_dict_str = model_dict_str.replace(
85
+ f'"get_model_api_key("{model_name}")"',
86
+ f'get_model_api_key("{model_name}")',
87
+ )
80
88
  content += f"{model_name}_llm_config = " + "{\n"
81
89
  content += ' "config_list": [\n'
82
90
  content += f" {model_dict_str}\n"
83
91
  content += " ]\n"
84
92
  content += "}\n"
85
- else:
86
- for model in all_models:
87
- model_name = model_names[model.id]
88
- llm_config = model.get_llm_config()
89
- model_dict_str = get_object_string(llm_config, tabs=2)
90
- content += f"{model_name}_llm_config = " + "{\n"
91
- content += ' "config_list": [\n'
92
- content += f" {model_dict_str}\n"
93
- content += " ]\n"
94
- content += "}\n"
93
+ if output_dir:
94
+ write_api_keys(all_models, model_names, output_dir)
95
95
  return content
96
96
 
97
97
 
@@ -191,3 +191,52 @@ def export_agent_models(
191
191
  content += " ]\n"
192
192
  content += "}\n"
193
193
  return content
194
+
195
+
196
+ def write_api_keys(
197
+ all_models: List[WaldiezModel],
198
+ model_names: Dict[str, str],
199
+ output_dir: Path,
200
+ ) -> None:
201
+ """Write the api keys to a separate file.
202
+
203
+ Parameters
204
+ ----------
205
+ all_models : List[WaldiezModel]
206
+ All the models in the flow.
207
+ model_names : Dict[str, str]
208
+ A mapping of model ids to model names.
209
+ output_dir : Path
210
+ The output directory to write the api keys.
211
+ """
212
+ # example call: llama3_1_api_key = get_model_api_key("llama3_1")
213
+ api_keys_content = '''
214
+ """API keys for the models."""
215
+
216
+ __ALL_MODEL_API_KEYS__ = {
217
+ '''
218
+ for model in all_models:
219
+ model_name = model_names[model.id]
220
+ api_keys_content += f' "{model_name}": "{model.api_key}",\n'
221
+ api_keys_content += "}\n"
222
+
223
+ api_keys_content += '''
224
+
225
+ def get_model_api_key(model_name: str) -> str:
226
+ """Get the api key for the model.
227
+
228
+ Parameters
229
+ ----------
230
+ model_name : str
231
+ The name of the model.
232
+
233
+ Returns
234
+ -------
235
+ str
236
+ The api key for the model.
237
+ """
238
+ return __ALL_MODEL_API_KEYS__.get(model_name, "")
239
+ '''
240
+
241
+ with open(output_dir / "waldiez_api_keys.py", "w", encoding="utf-8") as f:
242
+ f.write(api_keys_content)
@@ -15,12 +15,14 @@ from .naming import (
15
15
  get_valid_python_variable_name,
16
16
  )
17
17
  from .object_string import get_object_string
18
+ from .path_check import get_path_string
18
19
 
19
20
  __all__ = [
20
21
  "add_autogen_dot_import",
21
22
  "comment",
22
23
  "get_logging_start_string",
23
24
  "get_logging_stop_string",
25
+ "get_path_string",
24
26
  "get_pylint_ignore_comment",
25
27
  "get_sqlite_to_csv_string",
26
28
  "get_sqlite_to_csv_call_string",
@@ -65,7 +65,7 @@ def get_imports_string(
65
65
  skill_imports: Set[str],
66
66
  typing_imports: Optional[Set[str]] = None,
67
67
  builtin_imports: Optional[Set[str]] = None,
68
- other_imports: Optional[Set[str]] = None,
68
+ local_imports: Optional[Set[str]] = None,
69
69
  ) -> str:
70
70
  """Get the imports.
71
71
 
@@ -79,8 +79,8 @@ def get_imports_string(
79
79
  The typing imports, by default None.
80
80
  builtin_imports : Set[str], optional
81
81
  The builtin imports, by default None.
82
- other_imports : Set[str], optional
83
- Other third party imports, by default None.
82
+ local_imports : Set[str], optional
83
+ The local imports (like for getting model api keys), by default None.
84
84
 
85
85
  Returns
86
86
  -------
@@ -107,10 +107,12 @@ def get_imports_string(
107
107
  typing_imports = DEFAULT_TYPING_IMPORTS
108
108
  if not builtin_imports:
109
109
  builtin_imports = set()
110
- if not other_imports:
111
- other_imports = set()
110
+ if not local_imports:
111
+ local_imports = set()
112
112
  string = _get_builtin_imports_string(builtin_imports, typing_imports)
113
- string += _get_third_party_imports_string(imports, other_imports)
113
+ string += _get_third_party_imports_string(imports)
114
+ if local_imports:
115
+ string += "\n\n" + "\n".join(sorted(local_imports)) + "\n"
114
116
  string += _get_skill_imports_string(skill_imports)
115
117
  string = "\n\n".join([line for line in string.split("\n\n") if line])
116
118
  while not string.endswith("\n\n"):
@@ -234,13 +236,9 @@ def _get_autogen_imports(
234
236
  return autogen_imports, autogen_dot_imports, remaining_imports
235
237
 
236
238
 
237
- def _get_third_party_imports_string(
238
- imports: Set[str],
239
- other_imports: Set[str],
240
- ) -> str:
239
+ def _get_third_party_imports_string(imports: Set[str]) -> str:
241
240
  """Get the third party imports."""
242
241
  autogen_imports, autogen_dot_imports, rest = _get_autogen_imports(imports)
243
- rest.update(other_imports)
244
242
  plain_imports, from_imports_dict = _prepare_imports(
245
243
  autogen_imports=autogen_imports,
246
244
  autogen_dot_imports=autogen_dot_imports,
@@ -74,6 +74,8 @@ def get_object_string(obj: Any, tabs: int = 1) -> str:
74
74
  return f"[{to_return}]"
75
75
 
76
76
  if isinstance(obj, str):
77
+ if obj.startswith("r'") or obj.startswith('r"'):
78
+ return obj
77
79
  return f'"{obj}"'
78
80
 
79
81
  if obj is None:
@@ -0,0 +1,48 @@
1
+ """Path check utility functions."""
2
+
3
+ import os
4
+ from pathlib import Path
5
+
6
+ # pylint: disable=broad-except
7
+
8
+
9
+ def _is_local_path(string: str) -> bool:
10
+ """Check if a string is a local path.
11
+
12
+ Parameters
13
+ ----------
14
+ string : str
15
+ The string to check.
16
+
17
+ Returns
18
+ -------
19
+ bool
20
+ True if the path is a local path.
21
+ """
22
+ try:
23
+ path = Path(string).resolve()
24
+ return path.exists()
25
+ except Exception: # pragma: no cover
26
+ return False
27
+
28
+
29
+ def get_path_string(string: str) -> str:
30
+ """Get the path string.
31
+
32
+ Parameters
33
+ ----------
34
+ string : str
35
+ The string to check.
36
+
37
+ Returns
38
+ -------
39
+ str
40
+ The local path string.
41
+ """
42
+ # On windows, we get paths like "C:\path\to\file"
43
+ # if so, let's try to avoid invalid escape sequences
44
+ if not _is_local_path(string):
45
+ return string
46
+ if os.name == "nt": # pragma: no cover
47
+ return f"r'{string}'"
48
+ return f"'{string}'"
@@ -24,9 +24,7 @@ class WaldiezAgentData(WaldiezBase):
24
24
  human_input_mode : Literal["ALWAYS", "NEVER", "TERMINATE"]
25
25
  The human input mode to use for the agent.
26
26
  code_execution_config : Union[WaldiezAgentCodeExecutionConfig, False]
27
- The code execution config. Either False (no execution) or a dict
28
- max_tokens : Optional[int]
29
- The maximum tokens to use. Default: None (no limit).
27
+ The code execution config. Either False (no execution) or a dict.
30
28
  agent_default_auto_reply : Optional[str]
31
29
  The agent's default auto reply when no input is received.
32
30
  max_consecutive_auto_reply : Optional[int]
@@ -45,7 +43,7 @@ class WaldiezAgentData(WaldiezBase):
45
43
  """
46
44
 
47
45
  model_config = ConfigDict(
48
- extra="forbid",
46
+ extra="ignore",
49
47
  alias_generator=to_camel,
50
48
  populate_by_name=True,
51
49
  # we have a field starting with "model_" (model_ids)
@@ -71,15 +69,6 @@ class WaldiezAgentData(WaldiezBase):
71
69
  alias="humanInputMode",
72
70
  ),
73
71
  ]
74
- max_tokens: Annotated[
75
- Optional[int],
76
- Field(
77
- None,
78
- title="Max tokens",
79
- description="The maximum tokens to use. Default: None (no limit).",
80
- alias="maxTokens",
81
- ),
82
- ]
83
72
  code_execution_config: Annotated[
84
73
  Union[WaldiezAgentCodeExecutionConfig, Literal[False]],
85
74
  Field(
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes