diff --git a/docs/docs/en/getting-started/images/chat.png b/docs/docs/en/getting-started/images/chat.png
index 150a7ad64..c588df8a3 100644
--- a/docs/docs/en/getting-started/images/chat.png
+++ b/docs/docs/en/getting-started/images/chat.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:322092b446fcc67679a91a21937e9ad9aa2c5e9945d222355d91bcbc2519256a
-size 265833
+oid sha256:2eb14bd85e87d0abacf927c4df988ae2ede3277412a4a97e426c453edb917af1
+size 92092
diff --git a/docs/docs/en/getting-started/index.md b/docs/docs/en/getting-started/index.md
index e513169ef..fb9166fd2 100644
--- a/docs/docs/en/getting-started/index.md
+++ b/docs/docs/en/getting-started/index.md
@@ -119,15 +119,15 @@ To get started, you need to install FastAgency. You can do this using `pip`, Pyt
Depending on the interface you choose, you'll need to import different modules. These imports set up the necessary components for your application:
=== "Console"
- ```python hl_lines="7"
- {!> docs_src/getting_started/main_console.py [ln:1-7] !}
+ ```python hl_lines="8"
+ {!> docs_src/getting_started/main_console.py [ln:1-8] !}
```
For Console applications, import `ConsoleUI` to handle command-line input and output.
=== "Mesop"
- ```python hl_lines="7"
- {!> docs_src/getting_started/main_mesop.py [ln:1-7] !}
+ ```python hl_lines="8"
+ {!> docs_src/getting_started/main_mesop.py [ln:1-8] !}
```
For Mesop applications, import `MesopUI` to integrate with the Mesop web interface.
@@ -137,7 +137,7 @@ Depending on the interface you choose, you'll need to import different modules.
You need to define the workflow that your application will use. This is where you specify how the agents interact and what they do. Here's a simple example of a workflow definition:
```python
-{! docs_src/getting_started/main_console.py [ln:9-45] !}
+{! docs_src/getting_started/main_console.py [ln:9-53] !}
```
This code snippet sets up a simple learning chat between a student and a teacher. You define the agents and how they should interact, specifying how the conversation should be summarized.
@@ -148,14 +148,14 @@ Next, define your FastAgency application. This ties together your workflow and t
=== "Console"
```python hl_lines="1"
- {!> docs_src/getting_started/main_console.py [ln:47] !}
+ {!> docs_src/getting_started/main_console.py [ln:55] !}
```
For Console applications, use `ConsoleUI` to handle user interaction via the command line.
=== "Mesop"
```python hl_lines="1"
- {!> docs_src/getting_started/main_mesop.py [ln:47] !}
+ {!> docs_src/getting_started/main_mesop.py [ln:55] !}
```
For Mesop applications, use `MesopUI` to enable web-based interactions.
@@ -197,7 +197,7 @@ Once everything is set up, you can run your FastAgency application using the fol
fastagency run
```
- However, the preferred way of running Mesop application is a Python WSGI HTTP Server such as [Gunicorn](https://gunicorn.org/). First,
+ However, the preferred way to run the Mesop application is using a Python WSGI HTTP server like [Gunicorn](https://gunicorn.org/). First,
you need to install it using package manager such as `pip`:
```
pip install gunicorn
@@ -226,15 +226,20 @@ The output will vary based on the interface:
│ │
╰─────────────────────────────╯
- ╭─ FastAgency -> user [text_input] ────────────────────────────────────────────╮
+ ╭─ FastAgency -> user [workflow_started] ──────────────────────────────────────╮
│ │
- │ Starting a new workflow 'simple_learning' with the following │
- │ description: │
- │ │
- │ Student and teacher learning chat │
+ │ { │
+ │ "name": "simple_learning", │
+ │ "description": "Student and teacher │
+ │ learning chat", │
+ │ "params": {} │
+ │ } │
+ ╰──────────────────────────────────────────────────────────────────────────────╯
+
+ ╭─ Workflow -> User [text_input] ──────────────────────────────────────────────╮
│ │
- │ Please enter an │
- │ initial message: │
+ │ I can help you learn about geometry. What subject you would like to │
+ │ explore?: │
╰──────────────────────────────────────────────────────────────────────────────╯
```
@@ -242,10 +247,10 @@ The output will vary based on the interface:
=== "Mesop"
```console
- [2024-10-01 16:18:59 +0000] [20390] [INFO] Starting gunicorn 23.0.0
- [2024-10-01 16:18:59 +0000] [20390] [INFO] Listening at: http://127.0.0.1:8000 (20390)
- [2024-10-01 16:18:59 +0000] [20390] [INFO] Using worker: sync
- [2024-10-01 16:18:59 +0000] [20391] [INFO] Booting worker with pid: 20391
+ [2024-10-10 13:19:18 +0530] [23635] [INFO] Starting gunicorn 23.0.0
+ [2024-10-10 13:19:18 +0530] [23635] [INFO] Listening at: http://127.0.0.1:8000 (23635)
+ [2024-10-10 13:19:18 +0530] [23635] [INFO] Using worker: sync
+ [2024-10-10 13:19:18 +0530] [23645] [INFO] Booting worker with pid: 23645
```
![Initial message](./images/chat.png)
diff --git a/docs/docs/en/tutorial/giphy/images/gifs.png b/docs/docs/en/tutorial/giphy/images/gifs.png
index 4130817b7..ad5a992da 100644
--- a/docs/docs/en/tutorial/giphy/images/gifs.png
+++ b/docs/docs/en/tutorial/giphy/images/gifs.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:02dc90291407d81e6b896be0944f8f3773b145cb5a18469a60201ff9f41a5369
-size 1586747
+oid sha256:0628dd2d7feffe4b63565872f33a405b3eee7e6a0500b2efcca279a27477141e
+size 387453
diff --git a/docs/docs/en/tutorial/giphy/images/initial_message.png b/docs/docs/en/tutorial/giphy/images/initial_message.png
index 2ab7146ba..edf610c0d 100644
--- a/docs/docs/en/tutorial/giphy/images/initial_message.png
+++ b/docs/docs/en/tutorial/giphy/images/initial_message.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:553c12adc399dba8693585c1290b112a9e1314f0f29d6ae62b0e4f5fd20e942a
-size 50827
+oid sha256:fe6433fc46562ffc82e90f98bdd66eb68102fa048782e0f14f0470a4a60766d5
+size 43139
diff --git a/docs/docs/en/tutorial/giphy/images/scraped_info.png b/docs/docs/en/tutorial/giphy/images/scraped_info.png
index 2b3d62ad7..7052b4ff5 100644
--- a/docs/docs/en/tutorial/giphy/images/scraped_info.png
+++ b/docs/docs/en/tutorial/giphy/images/scraped_info.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:fc93b2012ddbf9b5abf9f70e416b0ce5077a30ad88098395d3bb94d737ca5a35
-size 306451
+oid sha256:122ac4dd71b69d38debfd65c258ffb04846756440c436412f98edd72c2b37ac7
+size 163251
diff --git a/docs/docs/en/tutorial/giphy/images/scraping1.png b/docs/docs/en/tutorial/giphy/images/scraping1.png
index 3b1001ba0..128537bf2 100644
--- a/docs/docs/en/tutorial/giphy/images/scraping1.png
+++ b/docs/docs/en/tutorial/giphy/images/scraping1.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:68b8966b18425f55877883e2adcc5d24e777afd66106ec7f45e5e72c7f8dad7d
-size 1112194
+oid sha256:9dae00723800db8fb17b5265250b81a933437d841a16d070d4c1f3e076049783
+size 179511
diff --git a/docs/docs/en/tutorial/giphy/images/scraping2.png b/docs/docs/en/tutorial/giphy/images/scraping2.png
index 633a5a4d9..8c4b39191 100644
--- a/docs/docs/en/tutorial/giphy/images/scraping2.png
+++ b/docs/docs/en/tutorial/giphy/images/scraping2.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:ac7b98a37e2ea5bacb1983c71a3604590122d4c227affad744837ce63977b096
-size 2043179
+oid sha256:c69da12b64ed0dbc5b17ef8e9849b7a5d02801496ad680a576068d17e20e62d8
+size 149643
diff --git a/docs/docs/en/tutorial/giphy/index.md b/docs/docs/en/tutorial/giphy/index.md
index a87f9e7da..5b12433bf 100644
--- a/docs/docs/en/tutorial/giphy/index.md
+++ b/docs/docs/en/tutorial/giphy/index.md
@@ -95,7 +95,7 @@ The following lines shows hot to initializes the Giphy API by loading the OpenAP
Also, we configure the **Giphy API** with the __*GIPHY_API_KEY*__ using __*set_security_params*__ to authenticate our requests.
```python
-{! docs_src/tutorial/giphy/main.py [ln:26-30] !}
+{! docs_src/tutorial/giphy/main.py [ln:25-29] !}
```
For more information, visit [**API Integration User Guide**](../../user-guide/api){target="_blank"}.
@@ -105,14 +105,14 @@ For more information, visit [**API Integration User Guide**](../../user-guide/ap
Here, we initialize a new workflow using ***AutoGenWorkflows()*** and register it under the name ***"giphy_and_websurfer"***. The ***@wf.register*** decorator registers the function to handle chat flow with security enabled, combining both GiphyAgent and WebSurferAgent.
```python
-{! docs_src/tutorial/giphy/main.py [ln:59-62] !}
+{! docs_src/tutorial/giphy/main.py [ln:58-61] !}
```
### Interaction with the user
This is a core function used by the **GiphyAgent** to either present the task result or ask a follow-up question to the user. The message is wrapped in a ***TextInput*** object, and then ***ui.process_message()*** sends it for user interaction.
```python
-{! docs_src/tutorial/giphy/main.py [ln:66-77] !}
+{! docs_src/tutorial/giphy/main.py [ln:65-76] !}
```
### Creating the Giphy and WebSurfer Agents
@@ -121,7 +121,7 @@ This is a core function used by the **GiphyAgent** to either present the task re
- **WebSurferAgent**: The ***WebSurferAgent*** is responsible for scraping web content and passes the retrieved data to the **GiphyAgent**. It’s configured with a summarizer to condense web content, which is useful when presenting concise data to the user. For more information, visit [**WebSurfer User Guide**](../../user-guide/runtimes/autogen/websurfer){target="_blank"}.
```python
-{! docs_src/tutorial/giphy/main.py [ln:79-93] !}
+{! docs_src/tutorial/giphy/main.py [ln:78-92] !}
```
### Registering Functions
@@ -129,12 +129,12 @@ This is a core function used by the **GiphyAgent** to either present the task re
The function ***present_completed_task_or_ask_question*** is registered to allow the **GiphyAgent** to ask questions or present completed tasks after receiving data from the **WebSurferAgent**.
```python
-{! docs_src/tutorial/giphy/main.py [ln:95-102] !}
+{! docs_src/tutorial/giphy/main.py [ln:94-101] !}
```
We specify which Giphy API functions can be used by the **GiphyAgent**: *random_gif*, *search_gifs*, and *trending_gifs*. These functions allow the agent to generate GIFs based on user input or trending content.
```python
-{! docs_src/tutorial/giphy/main.py [ln:104-110] !}
+{! docs_src/tutorial/giphy/main.py [ln:103-109] !}
```
### Initiating the Chat
@@ -144,7 +144,7 @@ We initiate the conversation between the user, **WebSurferAgent**, and **GiphyAg
Once the conversation ends, the summary is returned to the user, wrapping up the session.
```python
-{! docs_src/tutorial/giphy/main.py [ln:112-119] !}
+{! docs_src/tutorial/giphy/main.py [ln:118-125] !}
```
### Starting the Application
@@ -152,7 +152,7 @@ Once the conversation ends, the summary is returned to the user, wrapping up the
The FastAgency app is created, using the registered workflows (***wf***) and web-based user interface (***MesopUI***). This makes the conversation between agents and the user interactive.
```python
-{! docs_src/tutorial/giphy/main.py [ln:122] !}
+{! docs_src/tutorial/giphy/main.py [ln:128] !}
```
For more information, visit [**Mesop User Guide**](../../user-guide/ui/mesop/basics){target="_blank"}.
diff --git a/docs/docs/en/user-guide/api/openapi/index.md b/docs/docs/en/user-guide/api/openapi/index.md
index d7b137830..195f65e0d 100644
--- a/docs/docs/en/user-guide/api/openapi/index.md
+++ b/docs/docs/en/user-guide/api/openapi/index.md
@@ -24,22 +24,52 @@ These imports are similar to the imports section we have already covered, with t
{! docs_src/user_guide/external_rest_apis/main.py [ln:1-9] !}
```
-## Define Workflow
+## Configure the Language Model (LLM)
+Here, the large language model is configured to use the `gpt-4o-mini` model, and the API key is retrieved from the environment. This setup ensures that both the user and weather agents can interact effectively.
-In this workflow, the only difference is that we create a Python client for the external REST API by passing the URL of the `openapi.json` to the `Client.create` method. Then, we register the generated client with the agent using the methods `register_for_llm` and `register_for_execution`. Here's a simple example of a workflow definition:
+```python
+{! docs_src/user_guide/external_rest_apis/main.py [ln:11-19] !}
+```
+
+## Set Up the Weather API
+We define the OpenAPI specification URL for the weather service. This API will later be used by the weather agent to fetch real-time weather data.
```python
-{! docs_src/user_guide/external_rest_apis/main.py [ln:11-57] !}
+{! docs_src/user_guide/external_rest_apis/main.py [ln:21-22] !}
```
-This code snippet sets up a simple weather agent that calls an external weather API using the registered functions generated from the `openapi.json` URL.
+## Define the Workflow and Agents
+
+In this step, we define two agents and specify the initial message that will be displayed to users when the workflow starts.
+
+- **UserProxyAgent**: This agent simulates the user interacting with the system.
+
+- **ConversableAgent**: This agent acts as the weather agent, responsible for fetching weather data from the API.
+
+```python
+{! docs_src/user_guide/external_rest_apis/main.py [ln:24-50] !}
+```
+
+## Register API Functions with the Agents
+In this step, we register the weather API functions to ensure that the weather agent can call the correct functions to retrieve the required weather data.
+
+```python
+{! docs_src/user_guide/external_rest_apis/main.py [ln:51-55] !}
+```
+
+## Enable Agent Interaction and Chat
+Here, the user agent initiates a chat with the weather agent, which queries the API and returns the weather information. The conversation is summarized using a method provided by the LLM.
+
+```python
+{! docs_src/user_guide/external_rest_apis/main.py [ln:56-64] !}
+```
## Define FastAgency Application
Next, define your FastAgency application.
```python
-{! docs_src/user_guide/external_rest_apis/main.py [ln:60] !}
+{! docs_src/user_guide/external_rest_apis/main.py [ln:67] !}
```
## Complete Application Code
@@ -65,48 +95,56 @@ fastagency run
The output will vary based on the city and the current weather conditions:
```console
- ╭─── Python package file structure ───╮
- │ │
- │ 📁 docs │
- │ ├── 🐍 __init__.py │
- │ └── 📁 docs_src │
- │ ├── 🐍 __init__.py │
- │ └── 📁 tutorial │
- │ ├── 🐍 __init__.py │
- │ └── 📁 external_rest_apis │
- │ ├── 🐍 __init__.py │
- │ └── 🐍 main.py │
- │ │
- ╰─────────────────────────────────────╯
-
- ╭─────────────────── Importable FastAgency app ────────────────────╮
- │ │
- │ from docs.docs_src.tutorial.external_rest_apis.main import app │
- │ │
- ╰──────────────────────────────────────────────────────────────────╯
-
-╭─ FastAgency -> user [text_input] ────────────────────────────────────────────╮
-│ │
-│ Starting a new workflow 'simple_weather' with the following │
-│ description: │
+╭─ Python module file ─╮
+│ │
+│ 🐍 main.py │
+│ │
+╰──────────────────────╯
+
+
+╭─ Importable FastAgency app ─╮
+│ │
+│ from main import app │
+│ │
+╰─────────────────────────────╯
+
+╭─ FastAgency -> user [workflow_started] ──────────────────────────────────────╮
│ │
-│ Weather chat │
+│ { │
+│ "name": "simple_weather", │
+│ "description": "Weather chat", │
│ │
-│ Please enter an initial message: │
+│ "params": {} │
+│ } │
╰──────────────────────────────────────────────────────────────────────────────╯
-Get me daily weather forecast for Chennai city
+ ╭─ Workflow -> User [text_input] ──────────────────────────────────────────────╮
+ │ │
+ │ What do you want to know about the weather?: │
+ ╰──────────────────────────────────────────────────────────────────────────────╯
+
+Get me daily weather forecast for Chennai city
╭─ User_Agent -> Weather_Agent [text_message] ─────────────────────────────────╮
│ │
│ Get me daily weather forecast for Chennai city │
╰──────────────────────────────────────────────────────────────────────────────╯
- ╭─ Weather_Agent -> User_Agent [suggested_function_call] ──────────────────────╮
+ ╭─ Weather_Agent -> User_Agent [text_message] ─────────────────────────────────╮
+ │ │
+ │ I'm unable to provide real-time weather forecasts. However, you can │
+ │ easily find the daily weather forecast for Chennai by checking │
+ │ reliable weather websites, using weather apps, or searching for │
+ │ "Chennai weather forecast" in your preferred search engine. If you │
+ │ have any other questions or need information about typical weather │
+ │ patterns in Chennai, feel free to ask! │
+ ╰──────────────────────────────────────────────────────────────────────────────╯
+
+ ╭─ User_Agent -> Weather_Agent [suggested_function_call] ──────────────────────╮
│ │
│ { │
│ "function_name": "get_daily_weather_daily_get", │
│ "call_id": │
- │ "call_VZ19VFNcTE9n8BnXa9aiMzFA", │
+ │ "call_lbik8BJJREriUyhbpuKE5hhC", │
│ "arguments": { │
│ "city": │
│ "Chennai" │
@@ -114,32 +152,57 @@ Get me daily weather forecast for Chennai city
│ } │
╰──────────────────────────────────────────────────────────────────────────────╯
- ╭─ User_Agent -> Weather_Agent [function_call_execution] ──────────────────────╮
+ ╭─ Weather_Agent -> User_Agent [function_call_execution] ──────────────────────╮
│ │
│ { │
│ "function_name": "get_daily_weather_daily_get", │
│ "call_id": │
- │ "call_VZ19VFNcTE9n8BnXa9aiMzFA", │
+ │ "call_lbik8BJJREriUyhbpuKE5hhC", │
│ "retval": "{\"city\": \"Chennai\", │
- │ \"temperature\": 31, \"daily_forecasts\": [{\"forecast_date\": │
- │ \"2024-09-10\", \"temperature\": 31, \"hourly_forecasts\": null}, │
- │ {\"forecast_date\": \"2024-09-11\", \"temperature\": 30, │
- │ \"hourly_forecasts\": null}, {\"forecast_date\": \"2024-09-12\", │
- │ \"temperature\": 30, \"hourly_forecasts\": null}]}\n" │
+ │ \"temperature\": 30, \"daily_forecasts\": [{\"forecast_date\": │
+ │ \"2024-10-10\", \"temperature\": 29, \"hourly_forecasts\": null}, │
+ │ {\"forecast_date\": \"2024-10-11\", \"temperature\": 29, │
+ │ \"hourly_forecasts\": null}, {\"forecast_date\": \"2024-10-12\", │
+ │ \"temperature\": 28, \"hourly_forecasts\": null}]}\n" │
│ } │
╰──────────────────────────────────────────────────────────────────────────────╯
+ ╭─ User_Agent -> Weather_Agent [text_message] ─────────────────────────────────╮
+ │ │
+ │ Here is the daily weather forecast for Chennai: │
+ │ │
+ │ - **October 10, │
+ │ 2024**: Temperature - 29°C │
+ │ - **October 11, 2024**: Temperature - 29°C │
+ │ │
+ │ - **October 12, 2024**: Temperature - 28°C │
+ │ │
+ │ If you need more details │
+ │ or hourly forecasts, let me know! │
+ ╰──────────────────────────────────────────────────────────────────────────────╯
+
╭─ Weather_Agent -> User_Agent [text_message] ─────────────────────────────────╮
│ │
- │ The daily weather forecast for Chennai is as follows: │
+ │ Here is the daily weather forecast for Chennai: │
+ │ │
+ │ - **October 10, │
+ │ 2024**: Temperature - 29°C │
+ │ - **October 11, 2024**: Temperature - 29°C │
│ │
- │ - **September │
- │ 10, 2024**: Temperature - 31°C │
- │ - **September 11, 2024**: Temperature - │
- │ 30°C │
- │ - **September 12, 2024**: Temperature - 30°C │
+ │ - **October 12, 2024**: Temperature - 28°C │
│ │
- │ If you need more │
- │ details or forecasts for more days, feel free to ask! │
+ │ If you need more details │
+ │ or hourly forecasts, feel free to ask! │
╰──────────────────────────────────────────────────────────────────────────────╯
+
+╭─ workflow -> user [workflow_completed] ──────────────────────────────────────╮
+│ │
+│ { │
+│ "result": "The user requested the daily weather forecast for │
+│ Chennai, and the assistant provided the forecast for October 10, 11, │
+│ and 12, 2024, with temperatures of 29\u00b0C, 29\u00b0C, and │
+│ 28\u00b0C, respectively. The assistant also offered to provide more │
+│ details or hourly forecasts if needed." │
+│ } │
+╰──────────────────────────────────────────────────────────────────────────────╯
```
diff --git a/docs/docs/en/user-guide/api/security.md b/docs/docs/en/user-guide/api/security.md
index 7e9cb97cc..841a99a78 100644
--- a/docs/docs/en/user-guide/api/security.md
+++ b/docs/docs/en/user-guide/api/security.md
@@ -18,34 +18,70 @@ pip install "fastagency[autogen,openapi]"
## Imports
The imports are the same as in the [previous chapter](./index.md){.internal-link}, except here we also import `APIKeyHeader` to set the security value in the header:
-```python hl_lines="11"
+```python hl_lines="8"
{! docs_src/user_guide/external_rest_apis/security.py [ln:1-10] !}
```
-## Define Workflow
+## Configure the Language Model (LLM)
+Here, the large language model is configured to use the `gpt-4o-mini` model, and the API key is retrieved from the environment. This setup ensures that both the user and weather agents can interact effectively.
-In this workflow, we create a Python client for the external REST API by passing the URL of the `openapi.json` to the `Client.create` method. Then, we register the generated client with the agent using the methods `register_for_llm` and `register_for_execution`.
+```python
+{! docs_src/user_guide/external_rest_apis/security.py [ln:11-20] !}
+```
+
+## Set Up the Weather API
+We define the OpenAPI specification URL for the weather service. This API will later be used by the weather agent to fetch real-time weather data.
+
+```python
+{! docs_src/user_guide/external_rest_apis/security.py [ln:22,23] !}
+```
-Additionally, we set the API key for the API using the `set_security_params` method:
+## Configuring API Security Parameters
-```python hl_lines="2"
+Here, we define security settings for the weather API by setting API keys for authentication. This ensures secure access when interacting with the API, globally across all methods.
+
+```python
{! docs_src/user_guide/external_rest_apis/security.py [ln:25,26] !}
```
-Here's a simple example of a workflow definition:
+You can also set security parameters for a specific method. The code below demonstrates how to apply security parameters to a specific method instead of globally. In this example, the security settings are only applied to the `get_daily_weather_daily_get` method.
-```python hl_lines="15"
-{! docs_src/user_guide/external_rest_apis/security.py [ln:12-69] !}
+```python
+{! docs_src/user_guide/external_rest_apis/security.py [ln:28-32] !}
```
-This code snippet sets up a simple weather agent that calls an external weather API with security, using the registered functions generated from the `openapi.json` URL.
+## Define the Workflow and Agents
+
+In this step, we define two agents and specify the initial message that will be displayed to users when the workflow starts.
+
+- **UserProxyAgent**: This agent simulates the user interacting with the system.
+
+- **ConversableAgent**: This agent acts as the weather agent, responsible for fetching weather data from the API.
+
+```python
+{! docs_src/user_guide/external_rest_apis/security.py [ln:34-61] !}
+```
+
+## Register API Functions with the Agents
+In this step, we register the weather API functions to ensure that the weather agent can call the correct functions to retrieve the required weather data.
+
+```python
+{! docs_src/user_guide/external_rest_apis/security.py [ln:62-67] !}
+```
+
+## Enable Agent Interaction and Chat
+Here, the user agent initiates a chat with the weather agent, which queries the API and returns the weather information. The conversation is summarized using a method provided by the LLM.
+
+```python
+{! docs_src/user_guide/external_rest_apis/security.py [ln:68-76] !}
+```
## Define FastAgency Application
Next, define your FastAgency application.
```python
-{! docs_src/user_guide/external_rest_apis/security.py [ln:72] !}
+{! docs_src/user_guide/external_rest_apis/security.py [ln:79] !}
```
## Complete Application Code
@@ -68,51 +104,59 @@ fastagency run
## Output
-The output will vary based on the city and current weather conditions:
+The output will vary based on the city and the current weather conditions:
```console
- ╭─── Python package file structure ───╮
- │ │
- │ 📁 docs │
- │ ├── 🐍 __init__.py │
- │ └── 📁 docs_src │
- │ ├── 🐍 __init__.py │
- │ └── 📁 tutorial │
- │ ├── 🐍 __init__.py │
- │ └── 📁 external_rest_apis │
- │ ├── 🐍 __init__.py │
- │ └── 🐍 security.py │
- │ │
- ╰─────────────────────────────────────╯
-
- ╭───────────────────── Importable FastAgency app ──────────────────────╮
- │ │
- │ from docs.docs_src.tutorial.external_rest_apis.security import app │
- │ │
- ╰──────────────────────────────────────────────────────────────────────╯
-
-╭─ FastAgency -> user [text_input] ────────────────────────────────────────────╮
-│ │
-│ Starting a new workflow 'simple_weather_with_security' with the │
-│ following description: │
-│ │
-│ Weather chat with security │
+╭─ Python module file ─╮
+│ │
+│ 🐍 main.py │
+│ │
+╰──────────────────────╯
+
+
+╭─ Importable FastAgency app ─╮
+│ │
+│ from main import app │
+│ │
+╰─────────────────────────────╯
+
+╭─ FastAgency -> user [workflow_started] ──────────────────────────────────────╮
│ │
-│ Please enter an │
-│ initial message: │
+│ { │
+│ "name": "simple_weather_with_security", │
+│ "description": "Weather │
+│ chat with security", │
+│ "params": {} │
+│ } │
╰──────────────────────────────────────────────────────────────────────────────╯
-Get me hourly weather forecast for Chennai city
+
+ ╭─ Workflow -> User [text_input] ──────────────────────────────────────────────╮
+ │ │
+ │ What do you want to know about the weather?: │
+ ╰──────────────────────────────────────────────────────────────────────────────╯
+
+Get me daily weather forecast for Chennai city
╭─ User_Agent -> Weather_Agent [text_message] ─────────────────────────────────╮
│ │
- │ Get me hourly weather forecast for Chennai city │
+ │ Get me daily weather forecast for Chennai city │
+ ╰──────────────────────────────────────────────────────────────────────────────╯
+
+ ╭─ Weather_Agent -> User_Agent [text_message] ─────────────────────────────────╮
+ │ │
+ │ I'm unable to provide real-time weather forecasts. However, you can │
+ │ easily find the daily weather forecast for Chennai by checking │
+ │ reliable weather websites, using weather apps, or searching for │
+ │ "Chennai weather forecast" in your preferred search engine. If you │
+ │ have any other questions or need information about typical weather │
+ │ patterns in Chennai, feel free to ask! │
╰──────────────────────────────────────────────────────────────────────────────╯
- ╭─ Weather_Agent -> User_Agent [suggested_function_call] ──────────────────────╮
+ ╭─ User_Agent -> Weather_Agent [suggested_function_call] ──────────────────────╮
│ │
│ { │
- │ "function_name": "get_hourly_weather_hourly_get", │
+ │ "function_name": "get_daily_weather_daily_get", │
│ "call_id": │
- │ "call_pAMWHJ1wIlsciSSOMIb4uhst", │
+ │ "call_lbik8BJJREriUyhbpuKE5hhC", │
│ "arguments": { │
│ "city": │
│ "Chennai" │
@@ -120,112 +164,57 @@ Get me hourly weather forecast for Chennai city
│ } │
╰──────────────────────────────────────────────────────────────────────────────╯
- ╭─ User_Agent -> Weather_Agent [function_call_execution] ──────────────────────╮
+ ╭─ Weather_Agent -> User_Agent [function_call_execution] ──────────────────────╮
│ │
│ { │
- │ "function_name": "get_hourly_weather_hourly_get", │
+ │ "function_name": "get_daily_weather_daily_get", │
│ "call_id": │
- │ "call_pAMWHJ1wIlsciSSOMIb4uhst", │
+ │ "call_lbik8BJJREriUyhbpuKE5hhC", │
│ "retval": "{\"city\": \"Chennai\", │
- │ \"temperature\": 35, \"daily_forecasts\": [{\"forecast_date\": │
- │ \"2024-09-10\", \"temperature\": 31, \"hourly_forecasts\": │
- │ [{\"forecast_time\": \"00:00:00\", \"temperature\": 30, │
- │ \"description\": \"Patchy rain nearby\"}, {\"forecast_time\": │
- │ \"03:00:00\", \"temperature\": 29, \"description\": \"Clear\"}, │
- │ {\"forecast_time\": \"06:00:00\", \"temperature\": 28, │
- │ \"description\": \"Sunny\"}, {\"forecast_time\": \"09:00:00\", │
- │ \"temperature\": 31, \"description\": \"Sunny\"}, {\"forecast_time\": │
- │ \"12:00:00\", \"temperature\": 35, \"description\": \"Partly │
- │ cloudy\"}, {\"forecast_time\": \"15:00:00\", \"temperature\": 32, │
- │ \"description\": \"Patchy light drizzle\"}, {\"forecast_time\": │
- │ \"18:00:00\", \"temperature\": 30, \"description\": \"Patchy light │
- │ drizzle\"}, {\"forecast_time\": \"21:00:00\", \"temperature\": 30, │
- │ \"description\": \"Patchy rain nearby\"}]}, {\"forecast_date\": │
- │ \"2024-09-11\", \"temperature\": 30, \"hourly_forecasts\": │
- │ [{\"forecast_time\": \"00:00:00\", \"temperature\": 29, │
- │ \"description\": \"Patchy rain nearby\"}, {\"forecast_time\": │
- │ \"03:00:00\", \"temperature\": 29, \"description\": \"Clear\"}, │
- │ {\"forecast_time\": \"06:00:00\", \"temperature\": 28, │
- │ \"description\": \"Sunny\"}, {\"forecast_time\": \"09:00:00\", │
- │ \"temperature\": 31, \"description\": \"Sunny\"}, {\"forecast_time\": │
- │ \"12:00:00\", \"temperature\": 34, \"description\": \"Partly │
- │ Cloudy\"}, {\"forecast_time\": \"15:00:00\", \"temperature\": 31, │
- │ \"description\": \"Cloudy\"}, {\"forecast_time\": \"18:00:00\", │
- │ \"temperature\": 29, \"description\": \"Partly Cloudy\"}, │
- │ {\"forecast_time\": \"21:00:00\", \"temperature\": 29, │
- │ \"description\": \"Cloudy\"}]}, {\"forecast_date\": \"2024-09-12\", │
- │ \"temperature\": 30, \"hourly_forecasts\": [{\"forecast_time\": │
- │ \"00:00:00\", \"temperature\": 29, \"description\": \"Patchy rain │
- │ nearby\"}, {\"forecast_time\": \"03:00:00\", \"temperature\": 29, │
- │ \"description\": \"Clear\"}, {\"forecast_time\": \"06:00:00\", │
- │ \"temperature\": 28, \"description\": \"Sunny\"}, {\"forecast_time\": │
- │ \"09:00:00\", \"temperature\": 31, \"description\": \"Sunny\"}, │
- │ {\"forecast_time\": \"12:00:00\", \"temperature\": 34, │
- │ \"description\": \"Partly Cloudy\"}, {\"forecast_time\": \"15:00:00\", │
- │ \"temperature\": 31, \"description\": \"Partly Cloudy\"}, │
- │ {\"forecast_time\": \"18:00:00\", \"temperature\": 29, │
- │ \"description\": \"Overcast\"}, {\"forecast_time\": \"21:00:00\", │
- │ \"temperature\": 29, \"description\": \"Partly Cloudy\"}]}]}\n" │
+ │ \"temperature\": 30, \"daily_forecasts\": [{\"forecast_date\": │
+ │ \"2024-10-10\", \"temperature\": 29, \"hourly_forecasts\": null}, │
+ │ {\"forecast_date\": \"2024-10-11\", \"temperature\": 29, │
+ │ \"hourly_forecasts\": null}, {\"forecast_date\": \"2024-10-12\", │
+ │ \"temperature\": 28, \"hourly_forecasts\": null}]}\n" │
│ } │
╰──────────────────────────────────────────────────────────────────────────────╯
- ╭─ Weather_Agent -> User_Agent [text_message] ─────────────────────────────────╮
+ ╭─ User_Agent -> Weather_Agent [text_message] ─────────────────────────────────╮
│ │
- │ Here is the hourly weather forecast for Chennai: │
+ │ Here is the daily weather forecast for Chennai: │
│ │
- │ ### September 10, │
- │ 2024 │
- │ - **00:00** - Temperature: 30°C, Description: Patchy rain nearby │
+ │ - **October 10, │
+ │ 2024**: Temperature - 29°C │
+ │ - **October 11, 2024**: Temperature - 29°C │
│ │
- │ - **03:00** - Temperature: 29°C, Description: Clear │
- │ - **06:00** - │
- │ Temperature: 28°C, Description: Sunny │
- │ - **09:00** - Temperature: 31°C, │
- │ Description: Sunny │
- │ - **12:00** - Temperature: 35°C, Description: │
- │ Partly cloudy │
- │ - **15:00** - Temperature: 32°C, Description: Patchy │
- │ light drizzle │
- │ - **18:00** - Temperature: 30°C, Description: Patchy │
- │ light drizzle │
- │ - **21:00** - Temperature: 30°C, Description: Patchy │
- │ rain nearby │
+ │ - **October 12, 2024**: Temperature - 28°C │
│ │
- │ ### September 11, 2024 │
- │ - **00:00** - Temperature: 29°C, │
- │ Description: Patchy rain nearby │
- │ - **03:00** - Temperature: 29°C, │
- │ Description: Clear │
- │ - **06:00** - Temperature: 28°C, Description: Sunny │
+ │ If you need more details │
+ │ or hourly forecasts, let me know! │
+ ╰──────────────────────────────────────────────────────────────────────────────╯
+
+ ╭─ Weather_Agent -> User_Agent [text_message] ─────────────────────────────────╮
+ │ │
+ │ Here is the daily weather forecast for Chennai: │
│ │
- │ - **09:00** - Temperature: 31°C, Description: Sunny │
- │ - **12:00** - │
- │ Temperature: 34°C, Description: Partly Cloudy │
- │ - **15:00** - │
- │ Temperature: 31°C, Description: Cloudy │
- │ - **18:00** - Temperature: │
- │ 29°C, Description: Partly Cloudy │
- │ - **21:00** - Temperature: 29°C, │
- │ Description: Cloudy │
+ │ - **October 10, │
+ │ 2024**: Temperature - 29°C │
+ │ - **October 11, 2024**: Temperature - 29°C │
│ │
- │ ### September 12, 2024 │
- │ - **00:00** - Temperature: │
- │ 29°C, Description: Patchy rain nearby │
- │ - **03:00** - Temperature: │
- │ 29°C, Description: Clear │
- │ - **06:00** - Temperature: 28°C, Description: │
- │ Sunny │
- │ - **09:00** - Temperature: 31°C, Description: Sunny │
- │ - **12:00** │
- │ - Temperature: 34°C, Description: Partly Cloudy │
- │ - **15:00** - │
- │ Temperature: 31°C, Description: Partly Cloudy │
- │ - **18:00** - │
- │ Temperature: 29°C, Description: Overcast │
- │ - **21:00** - Temperature: │
- │ 29°C, Description: Partly Cloudy │
+ │ - **October 12, 2024**: Temperature - 28°C │
│ │
- │ Feel free to ask if you need more │
- │ information! │
+ │ If you need more details │
+ │ or hourly forecasts, feel free to ask! │
╰──────────────────────────────────────────────────────────────────────────────╯
+
+╭─ workflow -> user [workflow_completed] ──────────────────────────────────────╮
+│ │
+│ { │
+│ "result": "The user requested the daily weather forecast for │
+│ Chennai, and the assistant provided the forecast for October 10, 11, │
+│ and 12, 2024, with temperatures of 29\u00b0C, 29\u00b0C, and │
+│ 28\u00b0C, respectively. The assistant also offered to provide more │
+│ details or hourly forecasts if needed." │
+│ } │
+╰──────────────────────────────────────────────────────────────────────────────╯
```
diff --git a/docs/docs/en/user-guide/runtimes/autogen/index.md b/docs/docs/en/user-guide/runtimes/autogen/index.md
index 834436e4e..ca93c4626 100644
--- a/docs/docs/en/user-guide/runtimes/autogen/index.md
+++ b/docs/docs/en/user-guide/runtimes/autogen/index.md
@@ -22,63 +22,63 @@ This installation includes the AutoGen runtime, allowing you to build multi-agen
The example starts by importing the necessary modules from **AutoGen** and **FastAgency**. These imports lay the foundation for building and running multi-agent workflows.
```python
-{! docs_src/user_guide/runtime/autogen/main.py [ln:1-9] !}
+{! docs_src/user_guide/runtimes/autogen/main.py [ln:1-10] !}
```
#### 2. **Configure the Language Model (LLM)**
Here, the large language model is configured to use the `gpt-4o` model, and the API key is retrieved from the environment. This setup ensures that both the user and weather agents can interact effectively.
```python
-{! docs_src/user_guide/runtime/autogen/main.py [ln:11-19] !}
+{! docs_src/user_guide/runtimes/autogen/main.py [ln:12-20] !}
```
#### 3. **Set Up the Weather API**
We define the OpenAPI specification URL for the weather service. This API will later be used by the weather agent to fetch real-time weather data.
```python
-{! docs_src/user_guide/runtime/autogen/main.py [ln:21-23] !}
+{! docs_src/user_guide/runtimes/autogen/main.py [ln:22-24] !}
```
#### 4. **Define the Workflow and Agents**
-In this step, we create two agents:
+In this step, we define two agents and specify the initial message that will be displayed to users when the workflow starts.
- **UserProxyAgent**: This agent simulates the user interacting with the system.
- **ConversableAgent**: This agent acts as the weather agent, responsible for fetching weather data from the API.
-The workflow is registered using **[AutoGenWorkflows](../../../api/fastagency/runtime/autogen/AutoGenWorkflows/)**.
+The workflow is registered using **[AutoGenWorkflows](../../../api/fastagency/runtimes/autogen/AutoGenWorkflows/)**.
```python
-{! docs_src/user_guide/runtime/autogen/main.py [ln:28-43] !}
+{! docs_src/user_guide/runtimes/autogen/main.py [ln:26-51] !}
```
#### 5. **Register API Functions with the Agents**
In this step, we register the weather API functions to ensure that the weather agent can call the correct functions, such as `get_daily_weather` and `get_daily_weather_weekly_get`, to retrieve the required weather data.
```python
-{! docs_src/user_guide/runtime/autogen/main.py [ln:45-58] !}
+{! docs_src/user_guide/runtimes/autogen/main.py [ln:53-66] !}
```
#### 6. **Enable Agent Interaction and Chat**
Here, the user agent initiates a chat with the weather agent, which queries the API and returns the weather information. The conversation is summarized using a method provided by the LLM.
```python
-{! docs_src/user_guide/runtime/autogen/main.py [ln:60-67] !}
+{! docs_src/user_guide/runtimes/autogen/main.py [ln:68-75] !}
```
#### 7. **Create and Run the Application**
Finally, we create the FastAgency application and launch it using the console interface.
```python
-{! docs_src/user_guide/runtime/autogen/main.py [ln:70] !}
+{! docs_src/user_guide/runtimes/autogen/main.py [ln:78] !}
```
-## Complete Application Code
+### Complete Application Code
main.py
```python
-{! docs_src/user_guide/runtime/autogen/main.py!}
+{! docs_src/user_guide/runtimes/autogen/main.py!}
```
@@ -91,8 +91,42 @@ fastagency run
Ensure you have set your OpenAI API key in the environment and that the weather API URL is accessible. The command will launch a console interface where users can input their requests and interact with the weather agent.
+### Output
+
+Once you run it, FastAgency automatically detects the appropriate app to execute and runs it. The application will then prompt you with: "I can help you with the weather. What would you like to know?".
+
+```console
+╭─ Python module file ─╮
+│ │
+│ 🐍 main.py │
+│ │
+╰──────────────────────╯
+
+
+╭─ Importable FastAgency app ─╮
+│ │
+│ from main import app │
+│ │
+╰─────────────────────────────╯
+
+╭─ FastAgency -> user [workflow_started] ──────────────────────────────────────╮
+│ │
+│ { │
+│ "name": "simple_weather", │
+│ "description": "Weather chat", │
+│ │
+│ "params": {} │
+│ } │
+╰──────────────────────────────────────────────────────────────────────────────╯
+
+╭─ Workflow -> User [text_input] ──────────────────────────────────────────────╮
+│ │
+│ I can help you with the weather. What would you like to know?: │
+╰──────────────────────────────────────────────────────────────────────────────╯
+```
+
---
This example demonstrates the power of the **AutoGen** runtime within FastAgency, showing how easy it is to integrate LLM-powered agents with real-time API services. By leveraging FastAgency, developers can quickly create interactive, scalable applications that interact with external data sources in real-time.
-For more detailed documentation, visit the [AutoGen Reference](../../../api/fastagency/runtime/autogen/AutoGenWorkflows/).
+For more detailed documentation, visit the [AutoGen Reference](../../../api/fastagency/runtimes/autogen/AutoGenWorkflows/).
diff --git a/docs/docs/en/user-guide/runtimes/autogen/interactions.md b/docs/docs/en/user-guide/runtimes/autogen/interactions.md
index 0319d699f..db6475bbe 100644
--- a/docs/docs/en/user-guide/runtimes/autogen/interactions.md
+++ b/docs/docs/en/user-guide/runtimes/autogen/interactions.md
@@ -23,7 +23,7 @@ Let's define three functions which will be available to the agents:
`TextInput` is suitable for free-form text messages, ideal for open-ended queries and dialogues. This function allows the student to request exam questions from the teacher and provides some suggestions using `TextInput`.
```python
-{! docs_src/user_guide/custom_user_interactions/main.py [ln:50.5,51.5,52.5,53.5,54.5,55.5,56.5,57.5,58.5,59.5,60.5,61.5,62.5,63.5,64.5,66.5,67.5,68.5] !}
+{! docs_src/user_guide/custom_user_interactions/main.py [ln:57.5,58.5,59.5,60.5,61.5,62.5,63.5,64.5,65.5,66.5,67.5,68.5,69.5,70.5,71.5,72.5,73.5,74.5,75.5] !}
```
### System Info Messages
@@ -31,7 +31,7 @@ Let's define three functions which will be available to the agents:
`SystemMessage` is used for operational or system-related instructions, such as logging data, and is not part of the agent dialogue. This function logs the final answers after the student completes the discussion using `SystemMessage` to log the event.
```python
-{! docs_src/user_guide/custom_user_interactions/main.py [ln:70.5,71.5,72.5,73.5,74.5,75.5,76.5,77.5,78.5,79.5,80.5,81.5,82.5,83.5] !}
+{! docs_src/user_guide/custom_user_interactions/main.py [ln:77.5,78.5,79.5,80.5,81.5,82.5,83.5,84.5,85.5,86.5,87.5,88.5,89.5,90.5] !}
```
### Multiple Choice
@@ -39,7 +39,7 @@ Let's define three functions which will be available to the agents:
`MultipleChoice` is used for structured responses where the user must select one of several predefined options. This function retrieves the final grade for the student's submitted answers using `MultipleChoice`, presenting the user with grading options.
```python
-{! docs_src/user_guide/custom_user_interactions/main.py [ln:85.5,86.5,87.5,88.5,89.5,90.5,91.5,92.5,93.5,94.5,96.5,97.5] !}
+{! docs_src/user_guide/custom_user_interactions/main.py [ln:92.5,93.5,94.5,95.5,96.5,97.5,98.5,99.5,100.5,101.5,102.5,103.5,104.5] !}
```
### Other Types of Messages
@@ -50,7 +50,7 @@ All supported messages are subclasses of the [IOMessage](../../../../api/fastage
We now register these functions with the workflow, linking the `student_agent` as the caller and the `teacher_agent` as the executor.
```python
-{! docs_src/user_guide/custom_user_interactions/main.py [ln:99.5,100.5,101.5,102.5,103.5,104.5,105.5,106.5,107.5,108.5,109.5,110.5,111.5,112.5,113.5,114.5,115.5,116.5,117.5,118.5,119.5,120.5,121.5] !}
+{! docs_src/user_guide/custom_user_interactions/main.py [ln:106.5,107.5,108.5,109.5,110.5,111.5,112.5,113.5,114.5,115.5,116.5,117.5,118.5,119.5,120.5,121.5,122.5,123.5,124.5,125.5,126.5,127.5,128.5] !}
```
## Complete Application Code
diff --git a/docs/docs/en/user-guide/runtimes/autogen/websurfer.md b/docs/docs/en/user-guide/runtimes/autogen/websurfer.md
index 79679ae29..ae63a0b1f 100644
--- a/docs/docs/en/user-guide/runtimes/autogen/websurfer.md
+++ b/docs/docs/en/user-guide/runtimes/autogen/websurfer.md
@@ -31,15 +31,15 @@ This command installs FastAgency with support for the Console interface and Auto
The example starts by importing the necessary modules from **AutoGen** and **FastAgency**. These imports lay the foundation for building and running multi-agent workflows.
=== "Using WebSurferAgent"
- ```python hl_lines="7"
- {!> docs_src/user_guide/runtime/autogen/websurfer.py [ln:1-9] !}
+ ```python hl_lines="8"
+ {!> docs_src/user_guide/runtimes/autogen/websurfer.py [ln:1-9] !}
```
To create a new web surfing agent, simply import `WebSurferAgent`, which comes with built-in web surfing capabilities, and use it as needed.
=== "Enhancing an existing agent"
- ```python hl_lines="4 8"
- {!> docs_src/user_guide/runtime/autogen/websurfer_tool.py [ln:1-9] !}
+ ```python hl_lines="4 9"
+ {!> docs_src/user_guide/runtimes/autogen/websurfer_tool.py [ln:1-10] !}
```
To enhance existing agents with web surfing capability, import `WebSurferTool` from FastAgency and `ConversableAgent` from AutoGen.
@@ -49,21 +49,21 @@ The example starts by importing the necessary modules from **AutoGen** and **Fas
Here, the large language model is configured to use the `gpt-4o` model, and the API key is retrieved from the environment. This setup ensures that both the user and websurfer agents can interact effectively.
```python
-{! docs_src/user_guide/runtime/autogen/websurfer.py [ln:10-19] !}
+{! docs_src/user_guide/runtimes/autogen/websurfer.py [ln:10-19] !}
```
#### 3. **Define the Workflow and Agents**
=== "Using WebSurferAgent"
- In this step, we are going to create two agents:
+ In this step, we are going to create two agents and specify the initial message that will be displayed to users when the workflow starts:
- **UserProxyAgent**: This agent simulates the user interacting with the system.
- **WebSurferAgent**: This agent functions as a web surfer, with built-in capability to browse the web and fetch real-time data as required.
- ```python hl_lines="18"
- {!> docs_src/user_guide/runtime/autogen/websurfer.py [ln:20-38] !}
+ ```python hl_lines="24"
+ {!> docs_src/user_guide/runtimes/autogen/websurfer.py [ln:20-45] !}
```
When initiating the `WebSurferAgent`, the executor parameter must be provided. This can be either a single instance of `ConversableAgent` or a `list of ConversableAgent` instances.
@@ -72,7 +72,7 @@ Here, the large language model is configured to use the `gpt-4o` model, and the
=== "Enhancing an existing agent"
- In this step, we create two agents and a web surfer tool:
+ In this step, we create two agents, a web surfer tool and set an initial message that will be displayed to users when the workflow starts:
- **UserProxyAgent**: This agent simulates the user interacting with the system.
@@ -81,13 +81,13 @@ Here, the large language model is configured to use the `gpt-4o` model, and the
- **WebSurferTool**: The tool that gives the ConversableAgent the ability to browse the web after it has been registered.
```python
- {!> docs_src/user_guide/runtime/autogen/websurfer_tool.py [ln:20-45] !}
+ {!> docs_src/user_guide/runtimes/autogen/websurfer_tool.py [ln:21-54] !}
```
Now, we need to register the WebSurferAgent with a caller and executor. This setup allows the caller to use the WebSurferAgent for performing real-time web interactions.
```python hl_lines="2 3"
- {!> docs_src/user_guide/runtime/autogen/websurfer_tool.py [ln:46-50] !}
+ {!> docs_src/user_guide/runtimes/autogen/websurfer_tool.py [ln:55-58] !}
```
The `executor` can be either a single instance of `ConversableAgent` or a `list of ConversableAgent` instances.
@@ -100,20 +100,20 @@ Here, the user agent starts a conversation with the websurfer agent, which perfo
=== "Using WebSurferAgent"
```python
- {! docs_src/user_guide/runtime/autogen/websurfer.py [ln:39-48] !}
+ {! docs_src/user_guide/runtimes/autogen/websurfer.py [ln:46-54] !}
```
=== "Enhancing an existing agent"
```python
- {! docs_src/user_guide/runtime/autogen/websurfer_tool.py [ln:51-60] !}
+ {! docs_src/user_guide/runtimes/autogen/websurfer_tool.py [ln:59-68] !}
```
#### 5. **Create and Run the Application**
Finally, we create the FastAgency application and launch it using the console interface.
```python
-{! docs_src/user_guide/runtime/autogen/websurfer.py [ln:50] !}
+{! docs_src/user_guide/runtimes/autogen/websurfer.py [ln:57] !}
```
### Complete Application Code
@@ -123,7 +123,7 @@ Finally, we create the FastAgency application and launch it using the console in
websurfer_agent.py
```python
- {!> docs_src/user_guide/runtime/autogen/websurfer.py !}
+ {!> docs_src/user_guide/runtimes/autogen/websurfer.py !}
```
@@ -132,7 +132,7 @@ Finally, we create the FastAgency application and launch it using the console in
websurfer_tool.py
```python
- {!> docs_src/user_guide/runtime/autogen/websurfer_tool.py !}
+ {!> docs_src/user_guide/runtimes/autogen/websurfer_tool.py !}
```
@@ -156,7 +156,7 @@ Ensure you have set your OpenAI API key in the environment. The command will lau
### Output
-Once you run it, FastAgency automatically detects the appropriate app to execute and runs it. The application will then prompt you with: "Please enter an initial message:".
+Once you run it, FastAgency automatically detects the appropriate app to execute and runs it. The application will then prompt you with: "I can help you with your web search. What would you like to know?:"
=== "Using WebSurferAgent"
@@ -168,6 +168,8 @@ Once you run it, FastAgency automatically detects the appropriate app to execute
╰─────────────────────────╯
[INFO] Importing autogen.base.py
+ [INFO] Initializing FastAgency with workflows: and UI:
+ [INFO] Initialized FastAgency:
╭──── Importable FastAgency app ────╮
│ │
@@ -175,14 +177,19 @@ Once you run it, FastAgency automatically detects the appropriate app to execute
│ │
╰───────────────────────────────────╯
- ╭─ FastAgency -> user [text_input] ────────────────────────────────────────────╮
+ ╭─ FastAgency -> user [workflow_started] ──────────────────────────────────────╮
│ │
- │ Starting a new workflow 'simple_websurfer' with the following │
- │ description: │
+ │ { │
+ │ "name": "simple_websurfer", │
+ │ "description": "WebSurfer chat", │
│ │
- │ WebSurfer chat │
+ │ "params": {} │
+ │ } │
+ ╰──────────────────────────────────────────────────────────────────────────────╯
+
+ ╭─ Workflow -> User [text_input] ──────────────────────────────────────────────╮
│ │
- │ Please enter an initial message: │
+ │ I can help you with your web search. What would you like to know?: │
╰──────────────────────────────────────────────────────────────────────────────╯
```
@@ -196,6 +203,8 @@ Once you run it, FastAgency automatically detects the appropriate app to execute
╰────────────────────────╯
[INFO] Importing autogen.base.py
+ [INFO] Initializing FastAgency with workflows: and UI:
+ [INFO] Initialized FastAgency:
╭─── Importable FastAgency app ────╮
│ │
@@ -203,14 +212,19 @@ Once you run it, FastAgency automatically detects the appropriate app to execute
│ │
╰──────────────────────────────────╯
- ╭─ FastAgency -> user [text_input] ────────────────────────────────────────────╮
+ ╭─ FastAgency -> user [workflow_started] ──────────────────────────────────────╮
│ │
- │ Starting a new workflow 'simple_websurfer' with the following │
- │ description: │
+ │ { │
+ │ "name": "simple_websurfer", │
+ │ "description": "WebSurfer chat", │
│ │
- │ WebSurfer chat │
+ │ "params": {} │
+ │ } │
+ ╰──────────────────────────────────────────────────────────────────────────────╯
+
+ ╭─ Workflow -> User [text_input] ──────────────────────────────────────────────╮
│ │
- │ Please enter an initial message: │
+ │ I can help you with your web search. What would you like to know?: │
╰──────────────────────────────────────────────────────────────────────────────╯
```
@@ -232,18 +246,24 @@ This will initiate the task, allowing you to see the real-time conversation betw
│ } │
╰──────────────────────────────────────────────────────────────────────────────╯
-╭─ FastAgency -> user [text_input] ────────────────────────────────────────────╮
-│ │
-│ Starting a new workflow 'simple_websurfer' with the following │
-│ description: │
+╭─ FastAgency -> user [workflow_started] ──────────────────────────────────────╮
│ │
-│ WebSurfer chat │
+│ { │
+│ "name": "simple_websurfer", │
+│ "description": "WebSurfer chat", │
│ │
-│ Please enter an initial message: │
+│ "params": {} │
+│ } │
╰──────────────────────────────────────────────────────────────────────────────╯
+
+ ╭─ Workflow -> User [text_input] ──────────────────────────────────────────────╮
+ │ │
+ │ I can help you with your web search. What would you like to know?: │
+ ╰──────────────────────────────────────────────────────────────────────────────╯
+
```
-The agent will summarize its findings and then prompt you again with "Please enter an initial message:", allowing you to continue the conversation with the web surfer agent.
+The agent will summarize its findings and then prompt you again with "I can help you with your web search. What would you like to know?:", allowing you to continue the conversation with the web surfer agent.
---
diff --git a/docs/docs/en/user-guide/ui/console/basics.md b/docs/docs/en/user-guide/ui/console/basics.md
index b1b56b041..db48f1219 100644
--- a/docs/docs/en/user-guide/ui/console/basics.md
+++ b/docs/docs/en/user-guide/ui/console/basics.md
@@ -14,7 +14,7 @@ This example demonstrates how to create a workflow where a student agent interac
We begin by importing the necessary modules from **FastAgency** and **AutoGen**. These imports provide the essential building blocks for creating agents, workflows, and integrating the ConsoleUI.
```python
-{! docs_src/getting_started/main_console.py [ln:1-7] !}
+{! docs_src/getting_started/main_console.py [ln:1-8] !}
```
- **ConversableAgent**: This class allows the creation of agents that can engage in conversational tasks.
@@ -35,7 +35,7 @@ Next, we configure the language model that will power the agents. In this case,
Here, we define a simple workflow where the **Student Agent** interacts with the **Teacher Agent**. The student asks questions, and the teacher responds as a math teacher. The workflow is registered using **AutoGenWorkflows**.
```python
-{! docs_src/getting_started/main_console.py [ln:22-44] !}
+{! docs_src/getting_started/main_console.py [ln:20-52] !}
```
- **Agent Overview**: The **Student Agent** is configured with a system message, "You are a student willing to learn," and will initiate questions during the interaction. The **Teacher Agent**, on the other hand, is set up as a math teacher and will respond to the student's questions.
@@ -45,7 +45,7 @@ Here, we define a simple workflow where the **Student Agent** interacts with the
Finally, we instantiate **[ConsoleUI](../../../../api/fastagency/ui/console/ConsoleUI/)** to link the workflow to a text-based console interface. This allows the user to interact with the agents via the terminal.
```python
-{! docs_src/getting_started/main_console.py [ln:47] !}
+{! docs_src/getting_started/main_console.py [ln:55] !}
```
- **Explanation**: Here, we set up the **ConsoleUI** as the user interface for the workflow, which will allow the entire agent interaction to take place within the terminal.
diff --git a/docs/docs/en/user-guide/ui/mesop/basics.md b/docs/docs/en/user-guide/ui/mesop/basics.md
index ed0f7b79f..9e4fcb97b 100644
--- a/docs/docs/en/user-guide/ui/mesop/basics.md
+++ b/docs/docs/en/user-guide/ui/mesop/basics.md
@@ -39,11 +39,11 @@ You can pass a custom [SecurityPolicy](https://google.github.io/mesop/api/page/#
- a flag to disable trusted types.
```python
-{! docs_src/user_guide/ui/mesop/main_mesop.py [ln:3] !}
+{! docs_src/user_guide/ui/mesop/main_mesop.py [ln:4] !}
{! docs_src/user_guide/ui/mesop/main_mesop.py [ln:9] !}
-{! docs_src/user_guide/ui/mesop/main_mesop.py [ln:54] !}
+{! docs_src/user_guide/ui/mesop/main_mesop.py [ln:61] !}
ui = MesopUI(security_policy=security_policy)
```
@@ -55,11 +55,11 @@ Please see the [Mesop documentation](https://google.github.io/mesop/api/page/#me
All [Styles](https://google.github.io/mesop/api/style/){target="_blank"} used in styling of Mesop components can be passed to the [`MesopUI`](../../../../api/fastagency/ui/mesop/MesopUI/)constructor and change the default behavior. They are specified in top-level styling class [`MesopHomePageStyles`](../../../../api/fastagency/ui/mesop/styles/MesopHomePageStyles/).
```python
-{! docs_src/user_guide/ui/mesop/main_mesop.py [ln:3] !}
+{! docs_src/user_guide/ui/mesop/main_mesop.py [ln:4] !}
{! docs_src/user_guide/ui/mesop/main_mesop.py [ln:9] !}
-{! docs_src/user_guide/ui/mesop/main_mesop.py [ln:56-79] !}
+{! docs_src/user_guide/ui/mesop/main_mesop.py [ln:63-86] !}
ui = MesopUI(styles=styles)
```
@@ -95,7 +95,7 @@ Next, we configure the language model that powers the agents. In this case, we'r
Here, we define a simple workflow where the **Student Agent** interacts with the **Teacher Agent**. The student asks questions, and the teacher responds as a math teacher. The workflow is registered using **AutoGenWorkflows**.
```python
-{! docs_src/user_guide/ui/mesop/main_mesop.py [ln:26-51] !}
+{! docs_src/user_guide/ui/mesop/main_mesop.py [ln:26-58] !}
```
- **Agent Overview**: The **Student Agent** is configured with a system message, "You are a student willing to learn," and will initiate questions during the interaction. The **Teacher Agent**, on the other hand, is set up as a math teacher and will respond to the student's questions.
@@ -105,7 +105,7 @@ Here, we define a simple workflow where the **Student Agent** interacts with the
Finally, we instantiate **[MesopUI](../../../../api/fastagency/ui/mesop/MesopUI/)** to link the workflow to a web-based interface. This allows the user to interact with the agents through a web browser.
```python
-{! docs_src/user_guide/ui/mesop/main_mesop.py [ln:54-83] !}
+{! docs_src/user_guide/ui/mesop/main_mesop.py [ln:61-90] !}
```
- **Explanation**: Here, we set up the **MesopUI** as the user interface for the workflow, which will allow the entire agent interaction to take place through a web-based platform.
diff --git a/docs/docs_src/user_guide/ui/mesop/main_mesop.py b/docs/docs_src/user_guide/ui/mesop/main_mesop.py
index 0e3d45239..ce5c6dc10 100644
--- a/docs/docs_src/user_guide/ui/mesop/main_mesop.py
+++ b/docs/docs_src/user_guide/ui/mesop/main_mesop.py
@@ -58,7 +58,7 @@ def simple_workflow(
return chat_result.summary # type: ignore[no-any-return]
-security_policy=me.SecurityPolicy(allowed_iframe_parents=["https://acme.com"])
+security_policy=me.SecurityPolicy(allowed_iframe_parents=["https://acme.com"], allowed_script_srcs=["https://cdn.jsdelivr.net"])
styles=MesopHomePageStyles(
stylesheets=[