ag2 0.9.9__py3-none-any.whl → 0.10.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 ag2 might be problematic. Click here for more details.
- {ag2-0.9.9.dist-info → ag2-0.10.0.dist-info}/METADATA +243 -214
- {ag2-0.9.9.dist-info → ag2-0.10.0.dist-info}/RECORD +113 -87
- autogen/_website/generate_mkdocs.py +3 -3
- autogen/_website/notebook_processor.py +1 -1
- autogen/_website/utils.py +1 -1
- autogen/a2a/__init__.py +36 -0
- autogen/a2a/agent_executor.py +105 -0
- autogen/a2a/client.py +280 -0
- autogen/a2a/errors.py +18 -0
- autogen/a2a/httpx_client_factory.py +79 -0
- autogen/a2a/server.py +221 -0
- autogen/a2a/utils.py +165 -0
- autogen/agentchat/__init__.py +3 -0
- autogen/agentchat/agent.py +0 -2
- autogen/agentchat/assistant_agent.py +15 -15
- autogen/agentchat/chat.py +57 -41
- autogen/agentchat/contrib/agent_eval/criterion.py +1 -1
- autogen/agentchat/contrib/capabilities/text_compressors.py +5 -5
- autogen/agentchat/contrib/capabilities/tools_capability.py +1 -1
- autogen/agentchat/contrib/capabilities/transforms.py +1 -1
- autogen/agentchat/contrib/captainagent/agent_builder.py +1 -1
- autogen/agentchat/contrib/captainagent/captainagent.py +20 -19
- autogen/agentchat/contrib/graph_rag/falkor_graph_query_engine.py +2 -5
- autogen/agentchat/contrib/graph_rag/graph_rag_capability.py +5 -5
- autogen/agentchat/contrib/graph_rag/neo4j_graph_query_engine.py +18 -17
- autogen/agentchat/contrib/llava_agent.py +1 -13
- autogen/agentchat/contrib/rag/mongodb_query_engine.py +2 -2
- autogen/agentchat/contrib/rag/query_engine.py +11 -11
- autogen/agentchat/contrib/retrieve_assistant_agent.py +3 -0
- autogen/agentchat/contrib/swarm_agent.py +3 -2
- autogen/agentchat/contrib/vectordb/couchbase.py +1 -1
- autogen/agentchat/contrib/vectordb/mongodb.py +1 -1
- autogen/agentchat/contrib/web_surfer.py +1 -1
- autogen/agentchat/conversable_agent.py +359 -150
- autogen/agentchat/group/context_expression.py +21 -21
- autogen/agentchat/group/group_tool_executor.py +46 -15
- autogen/agentchat/group/guardrails.py +41 -33
- autogen/agentchat/group/handoffs.py +11 -11
- autogen/agentchat/group/multi_agent_chat.py +56 -2
- autogen/agentchat/group/on_condition.py +11 -11
- autogen/agentchat/group/safeguards/__init__.py +21 -0
- autogen/agentchat/group/safeguards/api.py +241 -0
- autogen/agentchat/group/safeguards/enforcer.py +1158 -0
- autogen/agentchat/group/safeguards/events.py +119 -0
- autogen/agentchat/group/safeguards/validator.py +435 -0
- autogen/agentchat/groupchat.py +102 -49
- autogen/agentchat/realtime/experimental/clients/realtime_client.py +2 -2
- autogen/agentchat/realtime/experimental/function_observer.py +2 -3
- autogen/agentchat/realtime/experimental/realtime_agent.py +2 -3
- autogen/agentchat/realtime/experimental/realtime_swarm.py +22 -13
- autogen/agentchat/user_proxy_agent.py +55 -53
- autogen/agents/experimental/document_agent/document_agent.py +1 -10
- autogen/agents/experimental/document_agent/parser_utils.py +5 -1
- autogen/browser_utils.py +4 -4
- autogen/cache/abstract_cache_base.py +2 -6
- autogen/cache/disk_cache.py +1 -6
- autogen/cache/in_memory_cache.py +2 -6
- autogen/cache/redis_cache.py +1 -5
- autogen/coding/__init__.py +10 -2
- autogen/coding/base.py +2 -1
- autogen/coding/docker_commandline_code_executor.py +1 -6
- autogen/coding/factory.py +9 -0
- autogen/coding/jupyter/docker_jupyter_server.py +1 -7
- autogen/coding/jupyter/jupyter_client.py +2 -9
- autogen/coding/jupyter/jupyter_code_executor.py +2 -7
- autogen/coding/jupyter/local_jupyter_server.py +2 -6
- autogen/coding/local_commandline_code_executor.py +0 -65
- autogen/coding/yepcode_code_executor.py +197 -0
- autogen/environments/docker_python_environment.py +3 -3
- autogen/environments/system_python_environment.py +5 -5
- autogen/environments/venv_python_environment.py +5 -5
- autogen/events/agent_events.py +1 -1
- autogen/events/client_events.py +1 -1
- autogen/fast_depends/utils.py +10 -0
- autogen/graph_utils.py +5 -7
- autogen/import_utils.py +3 -1
- autogen/interop/pydantic_ai/pydantic_ai.py +8 -5
- autogen/io/processors/console_event_processor.py +8 -3
- autogen/llm_config/client.py +3 -2
- autogen/llm_config/config.py +168 -91
- autogen/llm_config/entry.py +38 -26
- autogen/llm_config/types.py +35 -0
- autogen/llm_config/utils.py +223 -0
- autogen/mcp/mcp_proxy/operation_grouping.py +48 -39
- autogen/messages/agent_messages.py +1 -1
- autogen/messages/client_messages.py +1 -1
- autogen/oai/__init__.py +8 -1
- autogen/oai/bedrock.py +0 -13
- autogen/oai/client.py +25 -11
- autogen/oai/client_utils.py +31 -1
- autogen/oai/cohere.py +4 -14
- autogen/oai/gemini.py +4 -6
- autogen/oai/gemini_types.py +1 -0
- autogen/oai/openai_utils.py +44 -115
- autogen/remote/__init__.py +18 -0
- autogen/remote/agent.py +199 -0
- autogen/remote/agent_service.py +142 -0
- autogen/remote/errors.py +17 -0
- autogen/remote/httpx_client_factory.py +131 -0
- autogen/remote/protocol.py +37 -0
- autogen/remote/retry.py +102 -0
- autogen/remote/runtime.py +96 -0
- autogen/testing/__init__.py +12 -0
- autogen/testing/messages.py +45 -0
- autogen/testing/test_agent.py +111 -0
- autogen/tools/dependency_injection.py +4 -8
- autogen/tools/experimental/reliable/reliable.py +3 -2
- autogen/tools/experimental/web_search_preview/web_search_preview.py +1 -1
- autogen/tools/function_utils.py +2 -1
- autogen/version.py +1 -1
- {ag2-0.9.9.dist-info → ag2-0.10.0.dist-info}/WHEEL +0 -0
- {ag2-0.9.9.dist-info → ag2-0.10.0.dist-info}/licenses/LICENSE +0 -0
- {ag2-0.9.9.dist-info → ag2-0.10.0.dist-info}/licenses/NOTICE.md +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ag2
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.10.0
|
|
4
4
|
Summary: A programming framework for agentic AI
|
|
5
5
|
Project-URL: Homepage, https://ag2.ai/
|
|
6
6
|
Project-URL: Documentation, https://docs.ag2.ai
|
|
@@ -28,9 +28,8 @@ Classifier: Topic :: Software Development
|
|
|
28
28
|
Classifier: Topic :: Software Development :: Libraries
|
|
29
29
|
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
30
30
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
31
|
-
Requires-Python:
|
|
31
|
+
Requires-Python: >=3.10
|
|
32
32
|
Requires-Dist: anyio<5.0.0,>=3.0.0
|
|
33
|
-
Requires-Dist: asyncer==0.0.8
|
|
34
33
|
Requires-Dist: diskcache
|
|
35
34
|
Requires-Dist: docker
|
|
36
35
|
Requires-Dist: httpx<1,>=0.28.1
|
|
@@ -39,6 +38,8 @@ Requires-Dist: pydantic<3,>=2.6.1
|
|
|
39
38
|
Requires-Dist: python-dotenv
|
|
40
39
|
Requires-Dist: termcolor
|
|
41
40
|
Requires-Dist: tiktoken
|
|
41
|
+
Provides-Extra: a2a
|
|
42
|
+
Requires-Dist: a2a-sdk[http-server]<0.4,>=0.3.7; extra == 'a2a'
|
|
42
43
|
Provides-Extra: anthropic
|
|
43
44
|
Requires-Dist: anthropic[vertex]>=0.23.1; extra == 'anthropic'
|
|
44
45
|
Provides-Extra: autobuild
|
|
@@ -61,7 +62,7 @@ Requires-Dist: cerebras-cloud-sdk>=1.0.0; extra == 'cerebras'
|
|
|
61
62
|
Provides-Extra: cohere
|
|
62
63
|
Requires-Dist: cohere>=5.13.5; extra == 'cohere'
|
|
63
64
|
Provides-Extra: commsagent-discord
|
|
64
|
-
Requires-Dist: discord-py<2.
|
|
65
|
+
Requires-Dist: discord-py<2.7,>=2.4.0; extra == 'commsagent-discord'
|
|
65
66
|
Provides-Extra: commsagent-slack
|
|
66
67
|
Requires-Dist: slack-sdk<3.40,>=3.33.0; extra == 'commsagent-slack'
|
|
67
68
|
Provides-Extra: commsagent-telegram
|
|
@@ -73,61 +74,63 @@ Requires-Dist: crawl4ai<0.8,>=0.4.247; extra == 'crawl4ai'
|
|
|
73
74
|
Provides-Extra: deepseek
|
|
74
75
|
Requires-Dist: openai>=1.99.3; extra == 'deepseek'
|
|
75
76
|
Provides-Extra: dev
|
|
77
|
+
Requires-Dist: a2a-sdk[http-server]<0.4,>=0.3.7; extra == 'dev'
|
|
76
78
|
Requires-Dist: cairosvg; extra == 'dev'
|
|
77
79
|
Requires-Dist: codespell==2.4.1; extra == 'dev'
|
|
78
80
|
Requires-Dist: detect-secrets==1.5.0; extra == 'dev'
|
|
79
81
|
Requires-Dist: dirty-equals==0.9.0; extra == 'dev'
|
|
80
82
|
Requires-Dist: fastapi==0.116.1; extra == 'dev'
|
|
83
|
+
Requires-Dist: freezegun==1.5.5; extra == 'dev'
|
|
81
84
|
Requires-Dist: ipykernel==6.30.1; extra == 'dev'
|
|
82
85
|
Requires-Dist: jinja2==3.1.6; extra == 'dev'
|
|
83
86
|
Requires-Dist: mcp>=1.11.0; extra == 'dev'
|
|
84
87
|
Requires-Dist: mdx-include==1.4.2; extra == 'dev'
|
|
85
88
|
Requires-Dist: mike==2.1.3; extra == 'dev'
|
|
86
89
|
Requires-Dist: mkdocs-git-revision-date-localized-plugin==1.4.7; extra == 'dev'
|
|
87
|
-
Requires-Dist: mkdocs-glightbox==0.
|
|
90
|
+
Requires-Dist: mkdocs-glightbox==0.5.1; extra == 'dev'
|
|
88
91
|
Requires-Dist: mkdocs-literate-nav==0.6.2; extra == 'dev'
|
|
89
|
-
Requires-Dist: mkdocs-macros-plugin==1.3.
|
|
90
|
-
Requires-Dist: mkdocs-material==9.6.
|
|
92
|
+
Requires-Dist: mkdocs-macros-plugin==1.3.9; extra == 'dev'
|
|
93
|
+
Requires-Dist: mkdocs-material==9.6.19; extra == 'dev'
|
|
91
94
|
Requires-Dist: mkdocs-minify-plugin==0.8.0; extra == 'dev'
|
|
92
95
|
Requires-Dist: mkdocs-redirects==1.2.2; extra == 'dev'
|
|
93
96
|
Requires-Dist: mkdocstrings[python]==0.30.0; extra == 'dev'
|
|
94
|
-
Requires-Dist: mock==5.2.0; extra == 'dev'
|
|
95
97
|
Requires-Dist: mypy==1.17.1; extra == 'dev'
|
|
96
98
|
Requires-Dist: nbclient==0.10.2; extra == 'dev'
|
|
97
99
|
Requires-Dist: nbconvert==7.16.6; extra == 'dev'
|
|
98
100
|
Requires-Dist: nbformat==5.10.4; extra == 'dev'
|
|
99
101
|
Requires-Dist: openai>=1.99.3; extra == 'dev'
|
|
100
|
-
Requires-Dist: pandas==2.3.
|
|
102
|
+
Requires-Dist: pandas==2.3.2; extra == 'dev'
|
|
101
103
|
Requires-Dist: pdoc3==0.11.6; extra == 'dev'
|
|
102
104
|
Requires-Dist: pillow; extra == 'dev'
|
|
103
105
|
Requires-Dist: pre-commit==4.3.0; extra == 'dev'
|
|
104
106
|
Requires-Dist: pytest-asyncio==1.1.0; extra == 'dev'
|
|
105
|
-
Requires-Dist: pytest-cov==6.
|
|
106
|
-
Requires-Dist: pytest==8.4.
|
|
107
|
+
Requires-Dist: pytest-cov==6.3.0; extra == 'dev'
|
|
108
|
+
Requires-Dist: pytest==8.4.2; extra == 'dev'
|
|
107
109
|
Requires-Dist: pyupgrade-directories==0.3.0; extra == 'dev'
|
|
108
110
|
Requires-Dist: pyyaml==6.0.2; extra == 'dev'
|
|
109
|
-
Requires-Dist: ruff==0.12.
|
|
111
|
+
Requires-Dist: ruff==0.12.12; extra == 'dev'
|
|
110
112
|
Requires-Dist: termcolor==3.1.0; extra == 'dev'
|
|
111
113
|
Requires-Dist: toml==0.10.2; extra == 'dev'
|
|
112
|
-
Requires-Dist: typer==0.
|
|
114
|
+
Requires-Dist: typer==0.17.4; extra == 'dev'
|
|
113
115
|
Requires-Dist: types-decorator; extra == 'dev'
|
|
114
116
|
Requires-Dist: types-pycurl; extra == 'dev'
|
|
115
117
|
Requires-Dist: types-python-dateutil; extra == 'dev'
|
|
116
118
|
Requires-Dist: types-pyyaml; extra == 'dev'
|
|
117
119
|
Requires-Dist: types-requests; extra == 'dev'
|
|
118
120
|
Requires-Dist: types-ujson; extra == 'dev'
|
|
119
|
-
Requires-Dist: uv==0.8.
|
|
121
|
+
Requires-Dist: uv==0.8.15; extra == 'dev'
|
|
120
122
|
Provides-Extra: docs
|
|
123
|
+
Requires-Dist: a2a-sdk[http-server]<0.4,>=0.3.7; extra == 'docs'
|
|
121
124
|
Requires-Dist: cairosvg; extra == 'docs'
|
|
122
125
|
Requires-Dist: jinja2==3.1.6; extra == 'docs'
|
|
123
126
|
Requires-Dist: mcp>=1.11.0; extra == 'docs'
|
|
124
127
|
Requires-Dist: mdx-include==1.4.2; extra == 'docs'
|
|
125
128
|
Requires-Dist: mike==2.1.3; extra == 'docs'
|
|
126
129
|
Requires-Dist: mkdocs-git-revision-date-localized-plugin==1.4.7; extra == 'docs'
|
|
127
|
-
Requires-Dist: mkdocs-glightbox==0.
|
|
130
|
+
Requires-Dist: mkdocs-glightbox==0.5.1; extra == 'docs'
|
|
128
131
|
Requires-Dist: mkdocs-literate-nav==0.6.2; extra == 'docs'
|
|
129
|
-
Requires-Dist: mkdocs-macros-plugin==1.3.
|
|
130
|
-
Requires-Dist: mkdocs-material==9.6.
|
|
132
|
+
Requires-Dist: mkdocs-macros-plugin==1.3.9; extra == 'docs'
|
|
133
|
+
Requires-Dist: mkdocs-material==9.6.19; extra == 'docs'
|
|
131
134
|
Requires-Dist: mkdocs-minify-plugin==0.8.0; extra == 'docs'
|
|
132
135
|
Requires-Dist: mkdocs-redirects==1.2.2; extra == 'docs'
|
|
133
136
|
Requires-Dist: mkdocstrings[python]==0.30.0; extra == 'docs'
|
|
@@ -136,7 +139,7 @@ Requires-Dist: pdoc3==0.11.6; extra == 'docs'
|
|
|
136
139
|
Requires-Dist: pillow; extra == 'docs'
|
|
137
140
|
Requires-Dist: pyyaml==6.0.2; extra == 'docs'
|
|
138
141
|
Requires-Dist: termcolor==3.1.0; extra == 'docs'
|
|
139
|
-
Requires-Dist: typer==0.
|
|
142
|
+
Requires-Dist: typer==0.17.4; extra == 'docs'
|
|
140
143
|
Provides-Extra: duckduckgo
|
|
141
144
|
Requires-Dist: duckduckgo-search>=8.0.2; extra == 'duckduckgo'
|
|
142
145
|
Provides-Extra: flaml
|
|
@@ -171,23 +174,25 @@ Requires-Dist: matplotlib; extra == 'graph'
|
|
|
171
174
|
Requires-Dist: networkx; extra == 'graph'
|
|
172
175
|
Provides-Extra: graph-rag-falkor-db
|
|
173
176
|
Requires-Dist: falkordb>=1.0.10; extra == 'graph-rag-falkor-db'
|
|
174
|
-
Requires-Dist: graphrag-sdk==0.
|
|
177
|
+
Requires-Dist: graphrag-sdk==0.8.0; extra == 'graph-rag-falkor-db'
|
|
175
178
|
Provides-Extra: groq
|
|
176
179
|
Requires-Dist: groq>=0.9.0; extra == 'groq'
|
|
177
180
|
Provides-Extra: interop
|
|
178
181
|
Requires-Dist: crewai[tools]<1,>=0.76; (python_version >= '3.10' and python_version < '3.13') and extra == 'interop'
|
|
182
|
+
Requires-Dist: fasta2a; extra == 'interop'
|
|
179
183
|
Requires-Dist: langchain-community<1,>=0.3.12; extra == 'interop'
|
|
180
|
-
Requires-Dist: litellm<=1.
|
|
181
|
-
Requires-Dist: pydantic-ai
|
|
184
|
+
Requires-Dist: litellm<=1.76.3; extra == 'interop'
|
|
185
|
+
Requires-Dist: pydantic-ai>=1.0.12; extra == 'interop'
|
|
182
186
|
Requires-Dist: weaviate-client<5,>=4; (python_version >= '3.10' and python_version < '3.13') and extra == 'interop'
|
|
183
187
|
Provides-Extra: interop-crewai
|
|
184
188
|
Requires-Dist: crewai[tools]<1,>=0.76; (python_version >= '3.10' and python_version < '3.13') and extra == 'interop-crewai'
|
|
185
|
-
Requires-Dist: litellm<=1.
|
|
189
|
+
Requires-Dist: litellm<=1.76.3; extra == 'interop-crewai'
|
|
186
190
|
Requires-Dist: weaviate-client<5,>=4; (python_version >= '3.10' and python_version < '3.13') and extra == 'interop-crewai'
|
|
187
191
|
Provides-Extra: interop-langchain
|
|
188
192
|
Requires-Dist: langchain-community<1,>=0.3.12; extra == 'interop-langchain'
|
|
189
193
|
Provides-Extra: interop-pydantic-ai
|
|
190
|
-
Requires-Dist:
|
|
194
|
+
Requires-Dist: fasta2a; extra == 'interop-pydantic-ai'
|
|
195
|
+
Requires-Dist: pydantic-ai>=1.0.12; extra == 'interop-pydantic-ai'
|
|
191
196
|
Provides-Extra: jupyter-executor
|
|
192
197
|
Requires-Dist: ipykernel>=6.29.0; extra == 'jupyter-executor'
|
|
193
198
|
Requires-Dist: jupyter-client>=8.6.0; extra == 'jupyter-executor'
|
|
@@ -197,7 +202,7 @@ Requires-Dist: websocket-client; extra == 'jupyter-executor'
|
|
|
197
202
|
Provides-Extra: lint
|
|
198
203
|
Requires-Dist: codespell==2.4.1; extra == 'lint'
|
|
199
204
|
Requires-Dist: pyupgrade-directories==0.3.0; extra == 'lint'
|
|
200
|
-
Requires-Dist: ruff==0.12.
|
|
205
|
+
Requires-Dist: ruff==0.12.12; extra == 'lint'
|
|
201
206
|
Provides-Extra: lmm
|
|
202
207
|
Requires-Dist: pillow; extra == 'lmm'
|
|
203
208
|
Requires-Dist: replicate; extra == 'lmm'
|
|
@@ -218,9 +223,10 @@ Provides-Extra: mistral
|
|
|
218
223
|
Requires-Dist: mistralai>=1.0.1; extra == 'mistral'
|
|
219
224
|
Provides-Extra: neo4j
|
|
220
225
|
Requires-Dist: docx2txt==0.9; extra == 'neo4j'
|
|
221
|
-
Requires-Dist: llama-index-
|
|
222
|
-
Requires-Dist: llama-index-
|
|
223
|
-
Requires-Dist: llama-index<
|
|
226
|
+
Requires-Dist: llama-index-core<0.14,>=0.12; extra == 'neo4j'
|
|
227
|
+
Requires-Dist: llama-index-graph-stores-neo4j<0.6,>=0.4; extra == 'neo4j'
|
|
228
|
+
Requires-Dist: llama-index-readers-web<0.6,>=0.4; extra == 'neo4j'
|
|
229
|
+
Requires-Dist: llama-index<0.14,>=0.12; extra == 'neo4j'
|
|
224
230
|
Provides-Extra: ollama
|
|
225
231
|
Requires-Dist: fix-busted-json>=0.0.18; extra == 'ollama'
|
|
226
232
|
Requires-Dist: ollama>=0.4.7; extra == 'ollama'
|
|
@@ -232,11 +238,14 @@ Requires-Dist: openai[realtime]; extra == 'openai-realtime'
|
|
|
232
238
|
Provides-Extra: rag
|
|
233
239
|
Requires-Dist: chromadb<2,>=0.5; extra == 'rag'
|
|
234
240
|
Requires-Dist: docling<3,>=2.15.1; extra == 'rag'
|
|
235
|
-
Requires-Dist: llama-index-
|
|
236
|
-
Requires-Dist: llama-index-
|
|
237
|
-
Requires-Dist: llama-index-
|
|
238
|
-
Requires-Dist: llama-index-
|
|
239
|
-
Requires-Dist: llama-index<
|
|
241
|
+
Requires-Dist: llama-index-core<0.14,>=0.12; extra == 'rag'
|
|
242
|
+
Requires-Dist: llama-index-embeddings-huggingface<0.7,>=0.5; extra == 'rag'
|
|
243
|
+
Requires-Dist: llama-index-embeddings-openai<0.6,>=0.3; extra == 'rag'
|
|
244
|
+
Requires-Dist: llama-index-llms-langchain<0.8,>=0.6; extra == 'rag'
|
|
245
|
+
Requires-Dist: llama-index-llms-openai<0.6,>=0.4; extra == 'rag'
|
|
246
|
+
Requires-Dist: llama-index-vector-stores-chroma<0.6,>=0.4; extra == 'rag'
|
|
247
|
+
Requires-Dist: llama-index-vector-stores-mongodb<0.9,>=0.6; extra == 'rag'
|
|
248
|
+
Requires-Dist: llama-index<0.14,>=0.12; extra == 'rag'
|
|
240
249
|
Requires-Dist: requests<3,>=2.32.3; extra == 'rag'
|
|
241
250
|
Requires-Dist: selenium<5,>=4.28.1; extra == 'rag'
|
|
242
251
|
Requires-Dist: webdriver-manager==4.0.2; extra == 'rag'
|
|
@@ -244,50 +253,50 @@ Provides-Extra: redis
|
|
|
244
253
|
Requires-Dist: redis; extra == 'redis'
|
|
245
254
|
Provides-Extra: retrievechat
|
|
246
255
|
Requires-Dist: beautifulsoup4; extra == 'retrievechat'
|
|
247
|
-
Requires-Dist: chromadb==1.0.
|
|
256
|
+
Requires-Dist: chromadb==1.0.20; extra == 'retrievechat'
|
|
248
257
|
Requires-Dist: ipython; extra == 'retrievechat'
|
|
249
258
|
Requires-Dist: markdownify; extra == 'retrievechat'
|
|
250
|
-
Requires-Dist: protobuf==6.
|
|
259
|
+
Requires-Dist: protobuf==6.32.0; extra == 'retrievechat'
|
|
251
260
|
Requires-Dist: pypdf; extra == 'retrievechat'
|
|
252
261
|
Requires-Dist: sentence-transformers<=5.1.0; extra == 'retrievechat'
|
|
253
262
|
Provides-Extra: retrievechat-couchbase
|
|
254
263
|
Requires-Dist: beautifulsoup4; extra == 'retrievechat-couchbase'
|
|
255
|
-
Requires-Dist: chromadb==1.0.
|
|
264
|
+
Requires-Dist: chromadb==1.0.20; extra == 'retrievechat-couchbase'
|
|
256
265
|
Requires-Dist: couchbase>=4.3.0; extra == 'retrievechat-couchbase'
|
|
257
266
|
Requires-Dist: ipython; extra == 'retrievechat-couchbase'
|
|
258
267
|
Requires-Dist: markdownify; extra == 'retrievechat-couchbase'
|
|
259
268
|
Requires-Dist: numpy; extra == 'retrievechat-couchbase'
|
|
260
|
-
Requires-Dist: protobuf==6.
|
|
269
|
+
Requires-Dist: protobuf==6.32.0; extra == 'retrievechat-couchbase'
|
|
261
270
|
Requires-Dist: pypdf; extra == 'retrievechat-couchbase'
|
|
262
271
|
Requires-Dist: sentence-transformers<=5.1.0; extra == 'retrievechat-couchbase'
|
|
263
272
|
Provides-Extra: retrievechat-mongodb
|
|
264
273
|
Requires-Dist: beautifulsoup4; extra == 'retrievechat-mongodb'
|
|
265
|
-
Requires-Dist: chromadb==1.0.
|
|
274
|
+
Requires-Dist: chromadb==1.0.20; extra == 'retrievechat-mongodb'
|
|
266
275
|
Requires-Dist: ipython; extra == 'retrievechat-mongodb'
|
|
267
276
|
Requires-Dist: markdownify; extra == 'retrievechat-mongodb'
|
|
268
277
|
Requires-Dist: numpy; extra == 'retrievechat-mongodb'
|
|
269
|
-
Requires-Dist: protobuf==6.
|
|
278
|
+
Requires-Dist: protobuf==6.32.0; extra == 'retrievechat-mongodb'
|
|
270
279
|
Requires-Dist: pymongo>=4.0.0; extra == 'retrievechat-mongodb'
|
|
271
280
|
Requires-Dist: pypdf; extra == 'retrievechat-mongodb'
|
|
272
281
|
Requires-Dist: sentence-transformers<=5.1.0; extra == 'retrievechat-mongodb'
|
|
273
282
|
Provides-Extra: retrievechat-pgvector
|
|
274
283
|
Requires-Dist: beautifulsoup4; extra == 'retrievechat-pgvector'
|
|
275
|
-
Requires-Dist: chromadb==1.0.
|
|
284
|
+
Requires-Dist: chromadb==1.0.20; extra == 'retrievechat-pgvector'
|
|
276
285
|
Requires-Dist: ipython; extra == 'retrievechat-pgvector'
|
|
277
286
|
Requires-Dist: markdownify; extra == 'retrievechat-pgvector'
|
|
278
287
|
Requires-Dist: pgvector>=0.2.5; extra == 'retrievechat-pgvector'
|
|
279
|
-
Requires-Dist: protobuf==6.
|
|
288
|
+
Requires-Dist: protobuf==6.32.0; extra == 'retrievechat-pgvector'
|
|
280
289
|
Requires-Dist: psycopg>=3.1.18; (platform_system == 'Linux') and extra == 'retrievechat-pgvector'
|
|
281
290
|
Requires-Dist: psycopg[binary]>=3.1.18; (platform_system == 'Windows' or platform_system == 'Darwin') and extra == 'retrievechat-pgvector'
|
|
282
291
|
Requires-Dist: pypdf; extra == 'retrievechat-pgvector'
|
|
283
292
|
Requires-Dist: sentence-transformers<=5.1.0; extra == 'retrievechat-pgvector'
|
|
284
293
|
Provides-Extra: retrievechat-qdrant
|
|
285
294
|
Requires-Dist: beautifulsoup4; extra == 'retrievechat-qdrant'
|
|
286
|
-
Requires-Dist: chromadb==1.0.
|
|
295
|
+
Requires-Dist: chromadb==1.0.20; extra == 'retrievechat-qdrant'
|
|
287
296
|
Requires-Dist: fastembed>=0.3.1; extra == 'retrievechat-qdrant'
|
|
288
297
|
Requires-Dist: ipython; extra == 'retrievechat-qdrant'
|
|
289
298
|
Requires-Dist: markdownify; extra == 'retrievechat-qdrant'
|
|
290
|
-
Requires-Dist: protobuf==6.
|
|
299
|
+
Requires-Dist: protobuf==6.32.0; extra == 'retrievechat-qdrant'
|
|
291
300
|
Requires-Dist: pypdf; extra == 'retrievechat-qdrant'
|
|
292
301
|
Requires-Dist: qdrant-client; extra == 'retrievechat-qdrant'
|
|
293
302
|
Requires-Dist: sentence-transformers<=5.1.0; extra == 'retrievechat-qdrant'
|
|
@@ -298,15 +307,15 @@ Requires-Dist: chromadb; extra == 'teachable'
|
|
|
298
307
|
Provides-Extra: test
|
|
299
308
|
Requires-Dist: dirty-equals==0.9.0; extra == 'test'
|
|
300
309
|
Requires-Dist: fastapi==0.116.1; extra == 'test'
|
|
310
|
+
Requires-Dist: freezegun==1.5.5; extra == 'test'
|
|
301
311
|
Requires-Dist: ipykernel==6.30.1; extra == 'test'
|
|
302
312
|
Requires-Dist: mcp>=1.11.0; extra == 'test'
|
|
303
|
-
Requires-Dist: mock==5.2.0; extra == 'test'
|
|
304
313
|
Requires-Dist: nbconvert==7.16.6; extra == 'test'
|
|
305
314
|
Requires-Dist: nbformat==5.10.4; extra == 'test'
|
|
306
|
-
Requires-Dist: pandas==2.3.
|
|
315
|
+
Requires-Dist: pandas==2.3.2; extra == 'test'
|
|
307
316
|
Requires-Dist: pytest-asyncio==1.1.0; extra == 'test'
|
|
308
|
-
Requires-Dist: pytest-cov==6.
|
|
309
|
-
Requires-Dist: pytest==8.4.
|
|
317
|
+
Requires-Dist: pytest-cov==6.3.0; extra == 'test'
|
|
318
|
+
Requires-Dist: pytest==8.4.2; extra == 'test'
|
|
310
319
|
Provides-Extra: together
|
|
311
320
|
Requires-Dist: together>=1.2; extra == 'together'
|
|
312
321
|
Provides-Extra: twilio
|
|
@@ -314,19 +323,20 @@ Requires-Dist: fastapi<1,>=0.115.0; extra == 'twilio'
|
|
|
314
323
|
Requires-Dist: twilio>=9.3.2; extra == 'twilio'
|
|
315
324
|
Requires-Dist: uvicorn<1,>=0.30.6; extra == 'twilio'
|
|
316
325
|
Provides-Extra: types
|
|
326
|
+
Requires-Dist: a2a-sdk[http-server]<0.4,>=0.3.7; extra == 'types'
|
|
317
327
|
Requires-Dist: dirty-equals==0.9.0; extra == 'types'
|
|
318
328
|
Requires-Dist: fastapi==0.116.1; extra == 'types'
|
|
329
|
+
Requires-Dist: freezegun==1.5.5; extra == 'types'
|
|
319
330
|
Requires-Dist: ipykernel==6.30.1; extra == 'types'
|
|
320
331
|
Requires-Dist: mcp>=1.11.0; extra == 'types'
|
|
321
|
-
Requires-Dist: mock==5.2.0; extra == 'types'
|
|
322
332
|
Requires-Dist: mypy==1.17.1; extra == 'types'
|
|
323
333
|
Requires-Dist: nbconvert==7.16.6; extra == 'types'
|
|
324
334
|
Requires-Dist: nbformat==5.10.4; extra == 'types'
|
|
325
335
|
Requires-Dist: openai>=1.99.3; extra == 'types'
|
|
326
|
-
Requires-Dist: pandas==2.3.
|
|
336
|
+
Requires-Dist: pandas==2.3.2; extra == 'types'
|
|
327
337
|
Requires-Dist: pytest-asyncio==1.1.0; extra == 'types'
|
|
328
|
-
Requires-Dist: pytest-cov==6.
|
|
329
|
-
Requires-Dist: pytest==8.4.
|
|
338
|
+
Requires-Dist: pytest-cov==6.3.0; extra == 'types'
|
|
339
|
+
Requires-Dist: pytest==8.4.2; extra == 'types'
|
|
330
340
|
Requires-Dist: types-decorator; extra == 'types'
|
|
331
341
|
Requires-Dist: types-pycurl; extra == 'types'
|
|
332
342
|
Requires-Dist: types-python-dateutil; extra == 'types'
|
|
@@ -342,6 +352,9 @@ Requires-Dist: pathvalidate; extra == 'websurfer'
|
|
|
342
352
|
Requires-Dist: pdfminer-six; extra == 'websurfer'
|
|
343
353
|
Provides-Extra: wikipedia
|
|
344
354
|
Requires-Dist: wikipedia-api<1.0,>=0.8.1; extra == 'wikipedia'
|
|
355
|
+
Provides-Extra: yepcode
|
|
356
|
+
Requires-Dist: python-dotenv; extra == 'yepcode'
|
|
357
|
+
Requires-Dist: yepcode-run>=1.6.1; extra == 'yepcode'
|
|
345
358
|
Description-Content-Type: text/markdown
|
|
346
359
|
|
|
347
360
|
<a name="readme-top"></a>
|
|
@@ -411,9 +424,9 @@ The project is currently maintained by a [dynamic group of volunteers](MAINTAINE
|
|
|
411
424
|
- [Tools](#tools)
|
|
412
425
|
- [Advanced agentic design patterns](#advanced-agentic-design-patterns)
|
|
413
426
|
- [Announcements](#announcements)
|
|
414
|
-
- [Contributors Wall](#contributors-wall)
|
|
415
427
|
- [Code style and linting](#code-style-and-linting)
|
|
416
428
|
- [Related papers](#related-papers)
|
|
429
|
+
- [Contributors Wall](#contributors-wall)
|
|
417
430
|
- [Cite the project](#cite-the-project)
|
|
418
431
|
- [License](#license)
|
|
419
432
|
|
|
@@ -425,22 +438,30 @@ For a step-by-step walk through of AG2 concepts and code, see [Basic Concepts](h
|
|
|
425
438
|
|
|
426
439
|
AG2 requires **Python version >= 3.10, < 3.14**. AG2 is available via `ag2` (or its alias `autogen`) on PyPI.
|
|
427
440
|
|
|
441
|
+
**Windows/Linux:**
|
|
428
442
|
```bash
|
|
429
443
|
pip install ag2[openai]
|
|
430
444
|
```
|
|
431
445
|
|
|
446
|
+
**Mac:**
|
|
447
|
+
```bash
|
|
448
|
+
pip install 'ag2[openai]'
|
|
449
|
+
```
|
|
450
|
+
|
|
432
451
|
Minimal dependencies are installed by default. You can install extra options based on the features you need.
|
|
433
452
|
|
|
434
453
|
### Setup your API keys
|
|
435
454
|
|
|
436
|
-
To keep your LLM dependencies neat
|
|
455
|
+
To keep your LLM dependencies neat and avoid accidentally checking in code with your API key, we recommend storing your keys in a configuration file.
|
|
437
456
|
|
|
438
|
-
You can
|
|
457
|
+
In our examples, we use a file named **`OAI_CONFIG_LIST`** to store API keys. You can choose any filename, but make sure to add it to `.gitignore` so it will not be committed to source control.
|
|
458
|
+
|
|
459
|
+
You can use the following content as a template:
|
|
439
460
|
|
|
440
461
|
```json
|
|
441
462
|
[
|
|
442
463
|
{
|
|
443
|
-
"model": "gpt-
|
|
464
|
+
"model": "gpt-5",
|
|
444
465
|
"api_key": "<your OpenAI API key here>"
|
|
445
466
|
}
|
|
446
467
|
]
|
|
@@ -455,12 +476,11 @@ from autogen import AssistantAgent, UserProxyAgent, LLMConfig
|
|
|
455
476
|
|
|
456
477
|
llm_config = LLMConfig.from_json(path="OAI_CONFIG_LIST")
|
|
457
478
|
|
|
479
|
+
assistant = AssistantAgent("assistant", llm_config=llm_config)
|
|
458
480
|
|
|
459
|
-
with llm_config:
|
|
460
|
-
assistant = AssistantAgent("assistant")
|
|
461
481
|
user_proxy = UserProxyAgent("user_proxy", code_execution_config={"work_dir": "coding", "use_docker": False})
|
|
462
|
-
|
|
463
|
-
|
|
482
|
+
|
|
483
|
+
user_proxy.run(assistant, message="Summarize the main differences between Python lists and tuples.").process()
|
|
464
484
|
```
|
|
465
485
|
|
|
466
486
|
## Example applications
|
|
@@ -484,208 +504,216 @@ We have several agent concepts in AG2 to help you build your AI agents. We intro
|
|
|
484
504
|
|
|
485
505
|
The [ConversableAgent](https://docs.ag2.ai/latest/docs/api-reference/autogen/ConversableAgent) is the fundamental building block of AG2, designed to enable seamless communication between AI entities. This core agent type handles message exchange and response generation, serving as the base class for all agents in the framework.
|
|
486
506
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
507
|
+
Let's begin with a simple example where two agents collaborate:
|
|
508
|
+
- A **coder agent** that writes Python code.
|
|
509
|
+
- A **reviewer agent** that critiques the code without rewriting it.
|
|
490
510
|
|
|
491
511
|
```python
|
|
492
|
-
|
|
512
|
+
import logging
|
|
493
513
|
from autogen import ConversableAgent, LLMConfig
|
|
494
514
|
|
|
495
|
-
#
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
# Create another AI agent
|
|
509
|
-
fact_checker = ConversableAgent(
|
|
510
|
-
name="fact_checker",
|
|
511
|
-
system_message="You are a fact-checking assistant.",
|
|
512
|
-
)
|
|
513
|
-
|
|
514
|
-
# 4. Start the conversation
|
|
515
|
-
assistant.initiate_chat(
|
|
516
|
-
recipient=fact_checker,
|
|
517
|
-
message="What is AG2?",
|
|
518
|
-
max_turns=2
|
|
515
|
+
# Configure logging
|
|
516
|
+
logging.basicConfig(level=logging.INFO)
|
|
517
|
+
logger = logging.getLogger(__name__)
|
|
518
|
+
|
|
519
|
+
# Load LLM configuration
|
|
520
|
+
llm_config = LLMConfig.from_json(path="OAI_CONFIG_LIST")
|
|
521
|
+
|
|
522
|
+
# Define agents
|
|
523
|
+
coder = ConversableAgent(
|
|
524
|
+
name="coder",
|
|
525
|
+
system_message="You are a Python developer. Write short Python scripts.",
|
|
526
|
+
llm_config=llm_config,
|
|
519
527
|
)
|
|
520
|
-
```
|
|
521
528
|
|
|
522
|
-
|
|
529
|
+
reviewer = ConversableAgent(
|
|
530
|
+
name="reviewer",
|
|
531
|
+
system_message="You are a code reviewer. Analyze provided code and suggest improvements. "
|
|
532
|
+
"Do not generate code, only suggest improvements.",
|
|
533
|
+
llm_config=llm_config,
|
|
534
|
+
)
|
|
523
535
|
|
|
524
|
-
|
|
525
|
-
|
|
536
|
+
# Start a conversation
|
|
537
|
+
response = reviewer.run(
|
|
538
|
+
recipient=coder,
|
|
539
|
+
message="Write a Python function that computes Fibonacci numbers.",
|
|
540
|
+
max_turns=10
|
|
541
|
+
)
|
|
526
542
|
|
|
527
|
-
|
|
528
|
-
- `NEVER`: Operates autonomously without human involvement
|
|
529
|
-
- `TERMINATE`: Only requests human input to end conversations
|
|
543
|
+
response.process()
|
|
530
544
|
|
|
531
|
-
|
|
545
|
+
logger.info("Final output:\n%s", response.summary)
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
---
|
|
549
|
+
### Orchestrating Multiple Agents
|
|
550
|
+
|
|
551
|
+
AG2 enables sophisticated multi-agent collaboration through flexible orchestration patterns, allowing you to create dynamic systems where specialized agents work together to solve complex problems.
|
|
532
552
|
|
|
533
|
-
|
|
553
|
+
Here’s how to build a team of **teacher**, **lesson planner**, and **reviewer** agents working together to design a lesson plan:
|
|
534
554
|
|
|
535
555
|
```python
|
|
536
|
-
|
|
537
|
-
from autogen import ConversableAgent,
|
|
556
|
+
import logging
|
|
557
|
+
from autogen import ConversableAgent, LLMConfig
|
|
558
|
+
from autogen.agentchat import run_group_chat
|
|
559
|
+
from autogen.agentchat.group.patterns import AutoPattern
|
|
538
560
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
llm_config = LLMConfig(api_type="openai", model="gpt-4o-mini")
|
|
561
|
+
logging.basicConfig(level=logging.INFO)
|
|
562
|
+
logger = logging.getLogger(__name__)
|
|
542
563
|
|
|
564
|
+
llm_config = LLMConfig.from_json(path="OAI_CONFIG_LIST")
|
|
543
565
|
|
|
544
|
-
#
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
name="assistant",
|
|
548
|
-
system_message="You are a helpful assistant.",
|
|
549
|
-
)
|
|
566
|
+
# Define lesson planner and reviewer
|
|
567
|
+
planner_message = "You are a classroom lesson planner. Given a topic, write a lesson plan for a fourth grade class."
|
|
568
|
+
reviewer_message = "You are a classroom lesson reviewer. Compare the plan to the curriculum and suggest up to 3 improvements."
|
|
550
569
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
570
|
+
lesson_planner = ConversableAgent(
|
|
571
|
+
name="planner_agent",
|
|
572
|
+
system_message=planner_message,
|
|
573
|
+
description="Creates or revises lesson plans.",
|
|
574
|
+
llm_config=llm_config,
|
|
555
575
|
)
|
|
556
|
-
# or
|
|
557
|
-
human = UserProxyAgent(name="human", code_execution_config={"work_dir": "coding", "use_docker": False})
|
|
558
576
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
577
|
+
lesson_reviewer = ConversableAgent(
|
|
578
|
+
name="reviewer_agent",
|
|
579
|
+
system_message=reviewer_message,
|
|
580
|
+
description="Provides one round of feedback to lesson plans.",
|
|
581
|
+
llm_config=llm_config,
|
|
563
582
|
)
|
|
564
583
|
|
|
565
|
-
|
|
584
|
+
teacher_message = "You are a classroom teacher. You decide topics and collaborate with planner and reviewer to finalize lesson plans. When satisfied, output DONE!"
|
|
566
585
|
|
|
567
|
-
|
|
586
|
+
teacher = ConversableAgent(
|
|
587
|
+
name="teacher_agent",
|
|
588
|
+
system_message=teacher_message,
|
|
589
|
+
is_termination_msg=lambda x: "DONE!" in (x.get("content", "") or "").upper(),
|
|
590
|
+
llm_config=llm_config,
|
|
591
|
+
)
|
|
568
592
|
|
|
569
|
-
|
|
593
|
+
auto_selection = AutoPattern(
|
|
594
|
+
agents=[teacher, lesson_planner, lesson_reviewer],
|
|
595
|
+
initial_agent=lesson_planner,
|
|
596
|
+
group_manager_args={"name": "group_manager", "llm_config": llm_config},
|
|
597
|
+
)
|
|
598
|
+
|
|
599
|
+
response = run_group_chat(
|
|
600
|
+
pattern=auto_selection,
|
|
601
|
+
messages="Let's introduce our kids to the solar system.",
|
|
602
|
+
max_rounds=20,
|
|
603
|
+
)
|
|
570
604
|
|
|
571
|
-
|
|
605
|
+
response.process()
|
|
606
|
+
|
|
607
|
+
logger.info("Final output:\n%s", response.summary)
|
|
608
|
+
```
|
|
572
609
|
|
|
573
|
-
|
|
610
|
+
---
|
|
574
611
|
|
|
575
|
-
|
|
612
|
+
### Human in the Loop
|
|
613
|
+
|
|
614
|
+
Human oversight is often essential for validating or guiding AI outputs.
|
|
615
|
+
AG2 provides the `UserProxyAgent` for seamless integration of human feedback.
|
|
616
|
+
|
|
617
|
+
Here we extend the **teacher–planner–reviewer** example by introducing a **human agent** who validates the final lesson:
|
|
576
618
|
|
|
577
619
|
```python
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
""
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
""
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
for the lesson_planner to revise."""
|
|
601
|
-
|
|
602
|
-
with llm_config:
|
|
603
|
-
lesson_planner = ConversableAgent(
|
|
604
|
-
name="planner_agent",
|
|
605
|
-
system_message=planner_message,
|
|
606
|
-
description=planner_description,
|
|
607
|
-
)
|
|
608
|
-
|
|
609
|
-
lesson_reviewer = ConversableAgent(
|
|
610
|
-
name="reviewer_agent",
|
|
611
|
-
system_message=reviewer_message,
|
|
612
|
-
description=reviewer_description,
|
|
613
|
-
)
|
|
614
|
-
|
|
615
|
-
# 2. The teacher's system message can also be used as a description, so we don't define it
|
|
616
|
-
teacher_message = """You are a classroom teacher.
|
|
617
|
-
You decide topics for lessons and work with a lesson planner.
|
|
618
|
-
and reviewer to create and finalise lesson plans.
|
|
619
|
-
When you are happy with a lesson plan, output "DONE!".
|
|
620
|
-
"""
|
|
621
|
-
|
|
622
|
-
with llm_config:
|
|
623
|
-
teacher = ConversableAgent(
|
|
624
|
-
name="teacher_agent",
|
|
625
|
-
system_message=teacher_message,
|
|
626
|
-
# 3. Our teacher can end the conversation by saying DONE!
|
|
627
|
-
is_termination_msg=lambda x: "DONE!" in (x.get("content", "") or "").upper(),
|
|
628
|
-
)
|
|
629
|
-
|
|
630
|
-
# 4. Create the GroupChat with agents and selection method
|
|
631
|
-
groupchat = GroupChat(
|
|
632
|
-
agents=[teacher, lesson_planner, lesson_reviewer],
|
|
633
|
-
speaker_selection_method="auto",
|
|
634
|
-
messages=[],
|
|
620
|
+
import logging
|
|
621
|
+
from autogen import ConversableAgent, LLMConfig, UserProxyAgent
|
|
622
|
+
from autogen.agentchat import run_group_chat
|
|
623
|
+
from autogen.agentchat.group.patterns import AutoPattern
|
|
624
|
+
|
|
625
|
+
logging.basicConfig(level=logging.INFO)
|
|
626
|
+
logger = logging.getLogger(__name__)
|
|
627
|
+
|
|
628
|
+
llm_config = LLMConfig.from_json(path="OAI_CONFIG_LIST")
|
|
629
|
+
|
|
630
|
+
# Same agents as before, but now the human validator will pass to the planner who will check for "APPROVED" and terminate
|
|
631
|
+
planner_message = "You are a classroom lesson planner. Given a topic, write a lesson plan for a fourth grade class."
|
|
632
|
+
reviewer_message = "You are a classroom lesson reviewer. Compare the plan to the curriculum and suggest up to 3 improvements."
|
|
633
|
+
teacher_message = "You are an experienced classroom teacher. You don't prepare plans, you provide simple guidance to the planner to prepare a lesson plan on the key topic."
|
|
634
|
+
|
|
635
|
+
lesson_planner = ConversableAgent(
|
|
636
|
+
name="planner_agent",
|
|
637
|
+
system_message=planner_message,
|
|
638
|
+
description="Creates or revises lesson plans before having them reviewed.",
|
|
639
|
+
is_termination_msg=lambda x: "APPROVED" in (x.get("content", "") or "").upper(),
|
|
640
|
+
human_input_mode="NEVER",
|
|
641
|
+
llm_config=llm_config,
|
|
635
642
|
)
|
|
636
643
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
644
|
+
lesson_reviewer = ConversableAgent(
|
|
645
|
+
name="reviewer_agent",
|
|
646
|
+
system_message=reviewer_message,
|
|
647
|
+
description="Provides one round of feedback to lesson plans back to the lesson planner before requiring the human validator.",
|
|
641
648
|
llm_config=llm_config,
|
|
642
649
|
)
|
|
643
650
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
651
|
+
teacher = ConversableAgent(
|
|
652
|
+
name="teacher_agent",
|
|
653
|
+
system_message=teacher_message,
|
|
654
|
+
description="Provides guidance on the topic and content, if required.",
|
|
655
|
+
llm_config=llm_config,
|
|
656
|
+
)
|
|
657
|
+
|
|
658
|
+
human_validator = UserProxyAgent(
|
|
659
|
+
name="human_validator",
|
|
660
|
+
system_message="You are a human educator who provides final approval for lesson plans.",
|
|
661
|
+
description="Evaluates the proposed lesson plan and either approves it or requests revisions, before returning to the planner.",
|
|
648
662
|
)
|
|
649
|
-
```
|
|
650
663
|
|
|
651
|
-
|
|
664
|
+
auto_selection = AutoPattern(
|
|
665
|
+
agents=[teacher, lesson_planner, lesson_reviewer],
|
|
666
|
+
initial_agent=teacher,
|
|
667
|
+
user_agent=human_validator,
|
|
668
|
+
group_manager_args={"name": "group_manager", "llm_config": llm_config},
|
|
669
|
+
)
|
|
652
670
|
|
|
653
|
-
|
|
671
|
+
response = run_group_chat(
|
|
672
|
+
pattern=auto_selection,
|
|
673
|
+
messages="Let's introduce our kids to the solar system.",
|
|
674
|
+
max_rounds=20,
|
|
675
|
+
)
|
|
654
676
|
|
|
655
|
-
|
|
677
|
+
response.process()
|
|
656
678
|
|
|
657
|
-
|
|
679
|
+
logger.info("Final output:\n%s", response.summary)
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
---
|
|
683
|
+
|
|
684
|
+
### Tools
|
|
658
685
|
|
|
659
|
-
|
|
686
|
+
Agents gain significant utility through **tools**, which extend their capabilities with external data, APIs, or functions.
|
|
660
687
|
|
|
661
688
|
```python
|
|
689
|
+
import logging
|
|
662
690
|
from datetime import datetime
|
|
663
691
|
from typing import Annotated
|
|
664
|
-
|
|
665
692
|
from autogen import ConversableAgent, register_function, LLMConfig
|
|
666
693
|
|
|
667
|
-
|
|
668
|
-
|
|
694
|
+
logging.basicConfig(level=logging.INFO)
|
|
695
|
+
logger = logging.getLogger(__name__)
|
|
696
|
+
|
|
697
|
+
llm_config = LLMConfig.from_json(path="OAI_CONFIG_LIST")
|
|
669
698
|
|
|
670
|
-
#
|
|
699
|
+
# Tool: returns weekday for a given date
|
|
671
700
|
def get_weekday(date_string: Annotated[str, "Format: YYYY-MM-DD"]) -> str:
|
|
672
701
|
date = datetime.strptime(date_string, "%Y-%m-%d")
|
|
673
702
|
return date.strftime("%A")
|
|
674
703
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
)
|
|
704
|
+
date_agent = ConversableAgent(
|
|
705
|
+
name="date_agent",
|
|
706
|
+
system_message="You find the day of the week for a given date.",
|
|
707
|
+
llm_config=llm_config,
|
|
708
|
+
)
|
|
681
709
|
|
|
682
|
-
# 3. And an agent for executing the tool
|
|
683
710
|
executor_agent = ConversableAgent(
|
|
684
711
|
name="executor_agent",
|
|
685
712
|
human_input_mode="NEVER",
|
|
713
|
+
llm_config=llm_config,
|
|
686
714
|
)
|
|
687
715
|
|
|
688
|
-
#
|
|
716
|
+
# Register tool
|
|
689
717
|
register_function(
|
|
690
718
|
get_weekday,
|
|
691
719
|
caller=date_agent,
|
|
@@ -693,14 +721,14 @@ register_function(
|
|
|
693
721
|
description="Get the day of the week for a given date",
|
|
694
722
|
)
|
|
695
723
|
|
|
696
|
-
#
|
|
724
|
+
# Use tool in chat
|
|
697
725
|
chat_result = executor_agent.initiate_chat(
|
|
698
726
|
recipient=date_agent,
|
|
699
|
-
message="I was born on
|
|
727
|
+
message="I was born on 1995-03-25, what day was it?",
|
|
700
728
|
max_turns=2,
|
|
701
729
|
)
|
|
702
730
|
|
|
703
|
-
|
|
731
|
+
logger.info("Final output:\n%s", chat_result.chat_history[-1]["content"])
|
|
704
732
|
```
|
|
705
733
|
|
|
706
734
|
### Advanced agentic design patterns
|
|
@@ -712,6 +740,7 @@ AG2 supports more advanced concepts to help you build your AI agent workflows. Y
|
|
|
712
740
|
- [Retrieval Augmented Generation (RAG)](https://docs.ag2.ai/latest/docs/user-guide/advanced-concepts/rag/)
|
|
713
741
|
- [Code Execution](https://docs.ag2.ai/latest/docs/user-guide/advanced-concepts/code-execution)
|
|
714
742
|
- [Tools with Secrets](https://docs.ag2.ai/latest/docs/user-guide/advanced-concepts/tools/tools-with-secrets/)
|
|
743
|
+
- [Pattern Cookbook (9 group orchestrations)](https://docs.ag2.ai/latest/docs/user-guide/advanced-concepts/pattern-cookbook/overview/)
|
|
715
744
|
|
|
716
745
|
## Announcements
|
|
717
746
|
|
|
@@ -729,12 +758,6 @@ We adopt the Apache 2.0 license from v0.3. This enhances our commitment to open-
|
|
|
729
758
|
|
|
730
759
|
[More Announcements](announcements.md)
|
|
731
760
|
|
|
732
|
-
## Contributors Wall
|
|
733
|
-
|
|
734
|
-
<a href="https://github.com/ag2ai/ag2/graphs/contributors">
|
|
735
|
-
<img src="https://contrib.rocks/image?repo=ag2ai/ag2&max=204" />
|
|
736
|
-
</a>
|
|
737
|
-
|
|
738
761
|
## Code style and linting
|
|
739
762
|
|
|
740
763
|
This project uses pre-commit hooks to maintain code quality. Before contributing:
|
|
@@ -764,6 +787,12 @@ pre-commit run --all-files
|
|
|
764
787
|
|
|
765
788
|
- [StateFlow: Enhancing LLM Task-Solving through State-Driven Workflows](https://arxiv.org/abs/2403.11322)
|
|
766
789
|
|
|
790
|
+
## Contributors Wall
|
|
791
|
+
|
|
792
|
+
<a href="https://github.com/ag2ai/ag2/graphs/contributors">
|
|
793
|
+
<img src="https://contrib.rocks/image?repo=ag2ai/ag2&max=204" />
|
|
794
|
+
</a>
|
|
795
|
+
|
|
767
796
|
## Cite the project
|
|
768
797
|
|
|
769
798
|
```
|