@@ -101,37 +101,33 @@ We look forward to your contributions!
101
101
First install the packages:
102
102
103
103
``` bash
104
- pip install autogen-agentchat==0.4.0.dev2 autogen-ext==0.4.0.dev2
104
+ pip install ' autogen-agentchat==0.4.0.dev3 ' ' autogen-ext[docker] ==0.4.0.dev3 '
105
105
```
106
106
107
107
The following code uses code execution, you need to have [ Docker installed] ( https://docs.docker.com/engine/install/ )
108
108
and running on your machine.
109
109
110
110
``` python
111
111
import asyncio
112
- import logging
113
- from autogen_agentchat import EVENT_LOGGER_NAME
114
- from autogen_agentchat.agents import CodeExecutorAgent, CodingAssistantAgent
115
- from autogen_agentchat.logging import ConsoleLogHandler
116
- from autogen_agentchat.teams import RoundRobinGroupChat, StopMessageTermination
117
112
from autogen_ext.code_executor.docker_executor import DockerCommandLineCodeExecutor
118
113
from autogen_ext.models import OpenAIChatCompletionClient
119
-
120
- logger = logging.getLogger(EVENT_LOGGER_NAME )
121
- logger.addHandler(ConsoleLogHandler())
122
- logger.setLevel(logging.INFO )
114
+ from autogen_agentchat.agents import CodeExecutorAgent, CodingAssistantAgent
115
+ from autogen_agentchat.teams import RoundRobinGroupChat
116
+ from autogen_agentchat.task import TextMentionTermination
123
117
124
118
async def main () -> None :
125
119
async with DockerCommandLineCodeExecutor(work_dir = " coding" ) as code_executor:
126
120
code_executor_agent = CodeExecutorAgent(" code_executor" , code_executor = code_executor)
127
121
coding_assistant_agent = CodingAssistantAgent(
128
122
" coding_assistant" , model_client = OpenAIChatCompletionClient(model = " gpt-4o" , api_key = " YOUR_API_KEY" )
129
123
)
130
- group_chat = RoundRobinGroupChat([coding_assistant_agent, code_executor_agent] )
131
- result = await group_chat.run(
132
- task = " Create a plot of NVDIA and TSLA stock returns YTD from 2024-01-01 and save it to 'nvidia_tesla_2024_ytd.png'. " ,
133
- termination_condition = StopMessageTermination(),
124
+ termination = TextMentionTermination( " TERMINATE " )
125
+ group_chat = RoundRobinGroupChat([coding_assistant_agent, code_executor_agent], termination_condition = termination)
126
+ stream = group_chat.run_stream(
127
+ " Create a plot of NVDIA and TSLA stock returns YTD from 2024-01-01 and save it to 'nvidia_tesla_2024_ytd.png'. "
134
128
)
129
+ async for message in stream:
130
+ print (message)
135
131
136
132
asyncio.run(main())
137
133
```
0 commit comments