waldiez 0.1.2__tar.gz → 0.1.4__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.2 → waldiez-0.1.4}/PKG-INFO +2 -2
  2. {waldiez-0.1.2 → waldiez-0.1.4}/README.md +1 -1
  3. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/_version.py +1 -1
  4. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/flow/flow.py +9 -4
  5. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/models/__init__.py +69 -20
  6. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/utils/importing.py +9 -11
  7. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/agent/termination_message.py +2 -1
  8. {waldiez-0.1.2 → waldiez-0.1.4}/.gitignore +0 -0
  9. {waldiez-0.1.2 → waldiez-0.1.4}/LICENSE +0 -0
  10. {waldiez-0.1.2 → waldiez-0.1.4}/pyproject.toml +0 -0
  11. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/__init__.py +0 -0
  12. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/__main__.py +0 -0
  13. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/cli.py +0 -0
  14. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporter.py +0 -0
  15. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/__init__.py +0 -0
  16. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/agents/__init__.py +0 -0
  17. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/agents/agent.py +0 -0
  18. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/agents/agent_skills.py +0 -0
  19. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/agents/code_execution.py +0 -0
  20. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/agents/group_manager.py +0 -0
  21. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/agents/llm_config.py +0 -0
  22. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/agents/rag_user/__init__.py +0 -0
  23. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/agents/rag_user/chroma_utils.py +0 -0
  24. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/agents/rag_user/mongo_utils.py +0 -0
  25. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/agents/rag_user/pgvector_utils.py +0 -0
  26. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/agents/rag_user/qdrant_utils.py +0 -0
  27. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/agents/rag_user/rag_user.py +0 -0
  28. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/agents/rag_user/vector_db.py +0 -0
  29. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/agents/teachability.py +0 -0
  30. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/agents/termination_message.py +0 -0
  31. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/chats/__init__.py +0 -0
  32. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/chats/chats.py +0 -0
  33. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/chats/helpers.py +0 -0
  34. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/chats/nested.py +0 -0
  35. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/flow/__init__.py +0 -0
  36. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/flow/def_main.py +0 -0
  37. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/skills/__init__.py +0 -0
  38. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/utils/__init__.py +0 -0
  39. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/utils/comments.py +0 -0
  40. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/utils/logging_utils.py +0 -0
  41. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/utils/method_utils.py +0 -0
  42. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/utils/naming.py +0 -0
  43. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/utils/object_string.py +0 -0
  44. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/exporting/utils/path_check.py +0 -0
  45. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/io_stream.py +0 -0
  46. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/__init__.py +0 -0
  47. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/__init__.py +0 -0
  48. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/agent/__init__.py +0 -0
  49. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/agent/agent.py +0 -0
  50. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/agent/agent_data.py +0 -0
  51. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/agent/code_execution.py +0 -0
  52. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/agent/linked_skill.py +0 -0
  53. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/agent/nested_chat.py +0 -0
  54. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/agent/teachability.py +0 -0
  55. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/agents.py +0 -0
  56. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/assistant/__init__.py +0 -0
  57. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/assistant/assistant.py +0 -0
  58. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/assistant/assistant_data.py +0 -0
  59. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/group_manager/__init__.py +0 -0
  60. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/group_manager/group_manager.py +0 -0
  61. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/group_manager/group_manager_data.py +0 -0
  62. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/group_manager/speakers.py +0 -0
  63. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/rag_user/__init__.py +0 -0
  64. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/rag_user/rag_user.py +0 -0
  65. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/rag_user/rag_user_data.py +0 -0
  66. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/rag_user/retrieve_config.py +0 -0
  67. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/rag_user/vector_db_config.py +0 -0
  68. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/user_proxy/__init__.py +0 -0
  69. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/user_proxy/user_proxy.py +0 -0
  70. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/agents/user_proxy/user_proxy_data.py +0 -0
  71. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/chat/__init__.py +0 -0
  72. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/chat/chat.py +0 -0
  73. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/chat/chat_data.py +0 -0
  74. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/chat/chat_message.py +0 -0
  75. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/chat/chat_nested.py +0 -0
  76. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/chat/chat_summary.py +0 -0
  77. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/common/__init__.py +0 -0
  78. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/common/base.py +0 -0
  79. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/common/method_utils.py +0 -0
  80. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/flow/__init__.py +0 -0
  81. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/flow/flow.py +0 -0
  82. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/flow/flow_data.py +0 -0
  83. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/model/__init__.py +0 -0
  84. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/model/model.py +0 -0
  85. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/model/model_data.py +0 -0
  86. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/skill/__init__.py +0 -0
  87. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/skill/skill.py +0 -0
  88. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/skill/skill_data.py +0 -0
  89. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/models/waldiez.py +0 -0
  90. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/py.typed +0 -0
  91. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/runner.py +0 -0
  92. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/stream/__init__.py +0 -0
  93. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/stream/consumer.py +0 -0
  94. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/stream/provider.py +0 -0
  95. {waldiez-0.1.2 → waldiez-0.1.4}/waldiez/stream/server.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: waldiez
3
- Version: 0.1.2
3
+ Version: 0.1.4
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.2"
3
+ __version__ = "0.1.4"
@@ -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)
@@ -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,
@@ -136,7 +136,8 @@ class WaldiezAgentTerminationMessage(WaldiezBase):
136
136
  )
137
137
  if self.criterion == "ending":
138
138
  self._string = (
139
- 'lambda x: any(x.get("content", "").endswith(keyword) '
139
+ 'lambda x: any(x.get("content", "") and '
140
+ 'x.get("content", "").endswith(keyword) '
140
141
  f"for keyword in [{keywords_str}])"
141
142
  )
142
143
  if self.criterion == "exact":
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