You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* add msg_to param to ConversableAgene.run
* Add agent name, user input control, and max turns control to run. Docstrings and termination condition update.
Signed-off-by: Mark Sze <[email protected]>
* Rearrange docstring arguments
* Updated notebook for run
Signed-off-by: Mark Sze <[email protected]>
* Add commas to notebook
Signed-off-by: Mark Sze <[email protected]>
---------
Signed-off-by: Mark Sze <[email protected]>
Co-authored-by: Mark Sze <[email protected]>
"""Run a chat with the agent using the given message.
2968
+
2969
+
A second agent will be created to represent the user, this agent will by known by the name 'user'.
2970
+
2971
+
The user can terminate the conversation when prompted or, if agent's reply contains 'TERMINATE', it will terminate.
2955
2972
2956
2973
Args:
2957
2974
message: the message to be processed.
2958
-
clear_history: whether to clear the chat history.
2959
-
executor_kwargs: the keyword arguments for the executor.
2960
2975
tools: the tools to be used by the agent.
2976
+
executor_kwargs: the keyword arguments for the executor.
2977
+
max_turns: maximum number of turns (a turn is equivalent to both agents having replied), defaults no None which means unlimited. The original message is included.
2978
+
msg_to: which agent is receiving the message and will be the first to reply, defaults to the agent.
2979
+
clear_history: whether to clear the chat history.
2980
+
user_input: the user will be asked for input at their turn.
"""Run a chat asynchronously with the agent using the given message.
3005
+
3006
+
A second agent will be created to represent the user, this agent will by known by the name 'user'.
3007
+
3008
+
The user can terminate the conversation when prompted or, if agent's reply contains 'TERMINATE', it will terminate.
2974
3009
2975
3010
Args:
2976
3011
message: the message to be processed.
2977
-
clear_history: whether to clear the chat history.
2978
-
executor_kwargs: the keyword arguments for the executor.
2979
3012
tools: the tools to be used by the agent.
3013
+
executor_kwargs: the keyword arguments for the executor.
3014
+
max_turns: maximum number of turns (a turn is equivalent to both agents having replied), defaults no None which means unlimited. The original message is included.
3015
+
msg_to: which agent is receiving the message and will be the first to reply, defaults to the agent.
3016
+
clear_history: whether to clear the chat history.
3017
+
user_input: the user will be asked for input at their turn.
Copy file name to clipboardexpand all lines: notebook/agentchat_assistant_agent_standalone.ipynb
+29-21
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@
8
8
"\n",
9
9
"AG2 supports running `AssistantAgent` as a standalone agent with the ability to execute simple tasks without the need for interacting with other agents.\n",
10
10
"\n",
11
-
"To enable our assistant agent to surf the web, we will use `BrowserUseTool` fow which we need to install the browser-use optional dependency and [playwright](https://playwright.dev/python/docs/intro)\n",
11
+
"To enable our assistant agent access to surf the web, we will use the `BrowserUseTool` Tool for which we need to install the browser-use optional dependency and [playwright](https://playwright.dev/python/docs/intro).\n",
12
12
"\n",
13
13
"````{=mdx}\n",
14
14
":::info Requirements\n",
@@ -33,7 +33,7 @@
33
33
},
34
34
{
35
35
"cell_type": "code",
36
-
"execution_count": 2,
36
+
"execution_count": null,
37
37
"metadata": {},
38
38
"outputs": [],
39
39
"source": [
@@ -48,12 +48,12 @@
48
48
"source": [
49
49
"## Set your API Endpoint\n",
50
50
"\n",
51
-
"The [`config_list_from_json`](https://docs.ag2.ai/reference/autogen/config_list_from_json#config-list-from-json) function loads a list of configurations from an environment variable or a json file."
51
+
"The [`config_list_from_json`](https://docs.ag2.ai/reference/autogen/config_list_from_json#config-list-from-json) function loads a list of configurations from an environment variable or a JSON file."
52
52
]
53
53
},
54
54
{
55
55
"cell_type": "code",
56
-
"execution_count": 3,
56
+
"execution_count": null,
57
57
"metadata": {},
58
58
"outputs": [],
59
59
"source": [
@@ -78,8 +78,10 @@
78
78
"# Configure your assistant agent\n",
79
79
"\n",
80
80
"Here we will configure two assistant agents:\n",
81
-
"1. x_assistant, tasked with exploring the trending topics on X (Formally Twitter)\n",
82
-
"2. arxiv_researcher, tasked with discovery of papers that allign with the hot topic of the day"
81
+
"1. x_assistant, tasked with exploring the trending topics on X (formally Twitter)\n",
82
+
"2. arxiv_researcher, tasked with discovery of papers that allign with the hot topic of the day\n",
83
+
"\n",
84
+
"We will set the browser configuration to not run headless, this will open the browser as a window so you can see it in action."
83
85
]
84
86
},
85
87
{
@@ -94,6 +96,7 @@
94
96
"\n",
95
97
"browser_use_tool = BrowserUseTool(\n",
96
98
" llm_config=llm_config,\n",
99
+
" browser_config={\"headless\": False},\n",
97
100
")"
98
101
]
99
102
},
@@ -108,8 +111,9 @@
108
111
"cell_type": "markdown",
109
112
"metadata": {},
110
113
"source": [
111
-
"Lets run our x_assistant to discover the hot topic of the day\n",
112
-
"To be able to do this let's give our assistant the capability to browse the web using a `BrowserUseTool`"
114
+
"Let's run our x_assistant to discover the hot topic of the day.\n",
115
+
"\n",
116
+
"To be able to do this we give our assistant the capability to browse the web using a `BrowserUseTool` Tool."
113
117
]
114
118
},
115
119
{
@@ -121,16 +125,17 @@
121
125
"hot_topic_res = x_assistant.run(\n",
122
126
"\"Find out today's hot topic and an influencer who is talking about it on X using a web search\",\n",
123
127
" tools=browser_use_tool,\n",
128
+
" user_input=False,\n",
124
129
")\n",
125
130
"\n",
126
-
"print(hot_topic_res)"
131
+
"print(hot_topic_res.summary)"
127
132
]
128
133
},
129
134
{
130
135
"cell_type": "markdown",
131
136
"metadata": {},
132
137
"source": [
133
-
"After discovering the hot topic, lets run the discovery of papers that allign with the topic"
138
+
"After discovering the hot topic, let's run the discovery of papers that align with the topic"
134
139
]
135
140
},
136
141
{
@@ -140,17 +145,18 @@
140
145
"outputs": [],
141
146
"source": [
142
147
"paper_abstract = arxiv_researcher.run(\n",
143
-
"\"Get the abstract of a relevant paper based on \" + hot_topic_res,\n",
148
+
"\"Get the abstract of a relevant paper based on:\\n\" + hot_topic_res.summary,\n",
149
+
" user_input=False,\n",
144
150
")\n",
145
151
"\n",
146
-
"print(paper_abstract)"
152
+
"print(paper_abstract.summary)"
147
153
]
148
154
},
149
155
{
150
156
"cell_type": "markdown",
151
157
"metadata": {},
152
158
"source": [
153
-
"Now, Lets create a twitter post using our x_assistant"
159
+
"Now, let's create an X post using our x_assistant"
154
160
]
155
161
},
156
162
{
@@ -159,19 +165,20 @@
159
165
"metadata": {},
160
166
"outputs": [],
161
167
"source": [
162
-
"# Secneario 1. This task requires x_assistant's past state\n",
168
+
"# Scenario 1. This task requires x_assistant's past state\n",
163
169
"post = x_assistant.run(\n",
164
-
"\"Create an X post based on the hot topic and this \" + paper_abstract + \"and mention the influencer\",\n",
170
+
"\"Create an X post based on the hot topic and the following and mention the influencer:\\n\" + paper_abstract.summary,\n",
171
+
" user_input=False,\n",
165
172
")\n",
166
173
"\n",
167
-
"print(post)"
174
+
"print(post.summary)"
168
175
]
169
176
},
170
177
{
171
178
"cell_type": "markdown",
172
179
"metadata": {},
173
180
"source": [
174
-
"Finally, lets ask our x_assistant who should we follow on twitter"
181
+
"Finally, let's ask our x_assistant who should we follow on X"
175
182
]
176
183
},
177
184
{
@@ -180,21 +187,22 @@
180
187
"metadata": {},
181
188
"outputs": [],
182
189
"source": [
183
-
"# Scenario 2. Doing another task that does not require history or past state\n",
190
+
"# Scenario 2. Doing another task that does not require history or past state\n",
184
191
"\n",
185
192
"influencer_choice = x_assistant.run(\n",
186
193
"\"Find a influencer I should follow on Twitter by searching the web\",\n",
0 commit comments