diff --git a/.secrets.baseline b/.secrets.baseline
index 816c898d..6158368e 100644
--- a/.secrets.baseline
+++ b/.secrets.baseline
@@ -169,7 +169,7 @@
"filename": "docs/docs/en/user-guide/adapters/fastapi_nats/index.md",
"hashed_secret": "3be2e9dd1980856faddf5bd205e3ff96b24776aa",
"is_verified": false,
- "line_number": 301,
+ "line_number": 315,
"is_secret": false
}
],
@@ -179,7 +179,7 @@
"filename": "docs/docs/en/user-guide/adapters/nats/index.md",
"hashed_secret": "3be2e9dd1980856faddf5bd205e3ff96b24776aa",
"is_verified": false,
- "line_number": 153,
+ "line_number": 160,
"is_secret": false
}
],
diff --git a/docs/docs/en/user-guide/adapters/fastapi/index.md b/docs/docs/en/user-guide/adapters/fastapi/index.md
index b13c1181..2ab6f224 100644
--- a/docs/docs/en/user-guide/adapters/fastapi/index.md
+++ b/docs/docs/en/user-guide/adapters/fastapi/index.md
@@ -214,38 +214,38 @@ Alternatively, you can use [**Cookiecutter**](../../cookiecutter/index.md), whic
### Step-by-Step Breakdown
-#### 1. **Import Required Modules**
+#### 1. **Define Workflow**
+
+To get started, 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/fastapi/my_fastagency_app/my_fastagency_app/workflow.py [ln:1-47] !}
+```
+
+#### 2. **Import Required Modules**
=== "Mesop"
- To get started, import the required modules from the **FastAgency** and **AutoGen**. These imports provide the essential building blocks for creating agents, workflows, and integrating [**`MesopUI`**](../../../api/fastagency/ui/mesop/MesopUI.md). Additionally, import the [**`FastAPIAdapter`**](../../../api/fastagency/adapters/fastapi/FastAPIAdapter.md) class to expose the workflows as a [**REST API**](https://en.wikipedia.org/wiki/REST){target="_blank"}.
+ Next, import the required modules from the **FastAgency**. Import the [**`FastAPIAdapter`**](../../../api/fastagency/adapters/fastapi/FastAPIAdapter.md) class to expose the workflows as a [**REST API**](https://en.wikipedia.org/wiki/REST){target="_blank"}.
- ```python hl_lines="8"
- {!> docs_src/getting_started/fastapi/main_1_fastapi.py [ln:1-9] !}
+ ```python hl_lines="3"
+ {!> docs_src/getting_started/fastapi/my_fastagency_app/my_fastagency_app/deployment/main_1_fastapi.py [ln:1-4] !}
```
=== "Custom REST API and Websocket"
- To get started, import the required modules from the **FastAgency** and **AutoGen**. These imports provide the essential building blocks for creating agents, workflows, and integrating with the custom client. Additionally, import the [**`FastAPIAdapter`**](../../../api/fastagency/adapters/fastapi/FastAPIAdapter.md) and [**`HTMLResponse`**](https://fastapi.tiangolo.com/advanced/custom-response/#html-response){target="_blank"} class to expose the workflows as a [**REST API**](https://en.wikipedia.org/wiki/REST){target="_blank"}.
+ Next, import the required modules from the **FastAgency** and **AutoGen**. These imports provide the essential building blocks for creating agents, workflows, and integrating with the custom client. Additionally, import the [**`FastAPIAdapter`**](../../../api/fastagency/adapters/fastapi/FastAPIAdapter.md) and [**`HTMLResponse`**](https://fastapi.tiangolo.com/advanced/custom-response/#html-response){target="_blank"} class to expose the workflows as a [**REST API**](https://en.wikipedia.org/wiki/REST){target="_blank"}.
```python hl_lines="6 9"
{!> docs_src/getting_started/fastapi/main_fastapi_custom_client.py [ln:1-10] !}
```
-#### 2. **Define Workflow**
-
-Next, 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/mesop/my_fastagency_app/my_fastagency_app/local/main_console.py [ln:9-53] !}
-```
-
#### 3. **Define FastAgency Application**
Create an instance of the [**`FastAPIAdapter`**](../../../api/fastagency/adapters/fastapi/FastAPIAdapter.md) and pass your workflow to it. Then, include a router to the [**FastAPI**](https://fastapi.tiangolo.com/){target="_blank"} application. The adapter will have all [**REST API**](https://en.wikipedia.org/wiki/REST){target="_blank"} and [**WebSocket**](https://en.wikipedia.org/wiki/WebSocket){target="_blank"} routes for communicating with the client.
```python hl_lines="1 4"
-{!> docs_src/getting_started/fastapi/main_1_fastapi.py [ln:55-58] !}
+{!> docs_src/getting_started/fastapi/my_fastagency_app/my_fastagency_app/deployment/main_1_fastapi.py [ln:8-11] !}
```
=== "Mesop"
@@ -256,7 +256,7 @@ Create an instance of the [**`FastAPIAdapter`**](../../../api/fastagency/adapter
!!! note "main_2_mesop.py"
```python
- {!> docs_src/getting_started/fastapi/main_2_mesop.py [ln:1-11] !}
+ {!> docs_src/getting_started/fastapi/my_fastagency_app/my_fastagency_app/deployment/main_2_mesop.py [ln:1-15] !}
```
=== "Custom REST API and Websocket"
@@ -275,17 +275,24 @@ Please copy and paste the following code into the same folder, using the file na
=== "Mesop"
+
+ workflow.py
+ ```python
+ {!> docs_src/getting_started/fastapi/my_fastagency_app/my_fastagency_app/workflow.py !}
+ ```
+
+
main_1_fastapi.py
```python
- {!> docs_src/getting_started/fastapi/main_1_fastapi.py !}
+ {!> docs_src/getting_started/fastapi/my_fastagency_app/my_fastagency_app/deployment/main_1_fastapi.py !}
```
main_2_mesop.py
```python
- {!> docs_src/getting_started/fastapi/main_2_mesop.py !}
+ {!> docs_src/getting_started/fastapi/my_fastagency_app/my_fastagency_app/deployment/main_2_mesop.py !}
```
diff --git a/docs/docs/en/user-guide/adapters/fastapi_nats/index.md b/docs/docs/en/user-guide/adapters/fastapi_nats/index.md
index b30b7e31..49b5dfc4 100644
--- a/docs/docs/en/user-guide/adapters/fastapi_nats/index.md
+++ b/docs/docs/en/user-guide/adapters/fastapi_nats/index.md
@@ -121,28 +121,28 @@ Alternatively, you can use [**Cookiecutter**](../../cookiecutter/index.md), whic
As shown in the [**architecture overview**](#architecture-overview), this setup requires **three** components (applications). Let's begin our code walkthrough, starting with the [**NATS App**](#3-nats-app).
-#### 1. **Import Required Modules**
+#### 1. **Define Workflow**
-To get started, import the required modules from the **FastAgency** and **AutoGen**. These imports provide the essential building blocks for creating agents, workflows, and integrating with the client. Additionally, import the [**`NatsAdapter`**](../../../api/fastagency/adapters/nats/NatsAdapter.md) class for workflow execution.
+To get started, 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 hl_lines="8"
-{!> docs_src/getting_started/nats_n_fastapi/main_1_nats.py [ln:1-9] !}
+```python
+{! docs_src/getting_started/nats_n_fastapi/my_fastagency_app/my_fastagency_app/workflow.py [ln:1-47] !}
```
-#### 2. **Define Workflow**
+#### 2. **Import Required Modules**
-Next, 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:
+Next, import the required modules from the **FastAgency**. These imports provide the essential building blocks for integrating with the client. Additionally, import the [**`NatsAdapter`**](../../../api/fastagency/adapters/nats/NatsAdapter.md) class for workflow execution.
-```python
-{! docs_src/getting_started/nats_n_fastapi/main_1_nats.py [ln:11-52] !}
+```python hl_lines="4"
+{!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/my_fastagency_app/deployment/main_1_nats.py [ln:1-7] !}
```
#### 3. **Configure the `NatsAdapter`**
Create an instance of the [**`NatsAdapter`**](../../../api/fastagency/adapters/nats/NatsAdapter.md) and pass your workflow to it. The adapter will handle the communication with the [**`NatsProvider`**](../../../api/fastagency/adapters/nats/NatsProvider.md) and distribute workflow execution to the workers.
-```python hl_lines="5 7"
-{!> docs_src/getting_started/nats_n_fastapi/main_1_nats.py [ln:55-60] !}
+```python hl_lines="5"
+{!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/my_fastagency_app/deployment/main_1_nats.py [ln:9-13] !}
```
#### 4. **Define FastAgency Application**
@@ -150,7 +150,7 @@ Create an instance of the [**`NatsAdapter`**](../../../api/fastagency/adapters/n
Create a [**`NatsAdapter`**](../../../api/fastagency/adapters/nats/NatsAdapter.md) and then add it to the [**FastAPI**](https://fastapi.tiangolo.com/){target="_blank"} application using the [**lifespan parameter**](https://fastapi.tiangolo.com/advanced/events/){target="_blank"}.
```python
-{!> docs_src/getting_started/nats_n_fastapi/main_1_nats.py [ln:61] !}
+{!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/my_fastagency_app/deployment/main_1_nats.py [ln:15] !}
```
#### 5. **Adapter Chaining**
@@ -162,15 +162,15 @@ Next, we set up a FastAPI service to interact with the NATS.io provider. This in
=== "Mesop"
!!! note "main_2_fastapi.py"
- ```python hl_lines="16-18 21-22"
- {!> docs_src/getting_started/nats_n_fastapi/main_2_fastapi.py [ln:1-22] !}
+ ```python hl_lines="15-17 19-20"
+ {!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/my_fastagency_app/deployment/main_2_fastapi.py [ln:1-20] !}
```
Finally, the last component is the [**Mesop Client App**](#1-mesop-client-app), which uses the [**`MesopUI`**](../../../api/fastagency/ui/mesop/MesopUI.md) to communicate with both the user and the [**`FastAPIProvider`**](../../../api/fastagency/adapters/fastapi/FastAPIProvider.md).
!!! note "main_3_mesop.py"
- ```python hl_lines="7-9 11"
- {!> docs_src/getting_started/nats_n_fastapi/main_3_mesop.py [ln:1-11] !}
+ ```python hl_lines="7-9 11-15"
+ {!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/my_fastagency_app/deployment/main_3_mesop.py [ln:1-15] !}
```
=== "Custom REST API and WebSocket"
@@ -198,8 +198,8 @@ Next, we set up a FastAPI service to interact with the NATS.io provider. This in
The [**`NatsAdapter`**](../../../api/fastagency/adapters/nats/NatsAdapter.md) requires a running NATS server. The easiest way to start the NATS server is by using [**Docker**](https://www.docker.com/){target="_blank"}. FastAgency leverages the [**JetStream**](https://docs.nats.io/nats-concepts/jetstream){target="_blank"} feature of NATS and also utilizes authentication.
-```python hl_lines="1 3 6 11 17"
-{!> docs_src/getting_started/nats_n_fastapi/nats-server.conf [ln:1-23]!}
+```python hl_lines="1 3 8 14"
+{!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/.devcontainer/nats_server.conf [ln:1-31]!}
```
In the above Nats configuration, we define a user called `fastagency`, and its password is read from the environment variable `FASTAGENCY_NATS_PASSWORD`. We also enable JetStream in Nats and configure Nats to serve via the appropriate ports.
@@ -211,46 +211,60 @@ Please copy and paste the following code into the same folder, using the file na
=== "Mesop"
- nats-server.conf
+ nats_server.conf
+ ```python
+ {!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/.devcontainer/nats_server.conf !}
+ ```
+
+
+
+ workflow.py
```python
- {!> docs_src/getting_started/nats_n_fastapi/nats-server.conf !}
+ {!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/my_fastagency_app/workflow.py !}
```
main_1_nats.py
```python
- {!> docs_src/getting_started/nats_n_fastapi/main_1_nats.py !}
+ {!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/my_fastagency_app/deployment/main_1_nats.py !}
```
main_2_fastapi.py
```python
- {!> docs_src/getting_started/nats_n_fastapi/main_2_fastapi.py !}
+ {!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/my_fastagency_app/deployment/main_2_fastapi.py !}
```
main_3_mesop.py
```python
- {!> docs_src/getting_started/nats_n_fastapi/main_3_mesop.py !}
+ {!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/my_fastagency_app/deployment/main_3_mesop.py !}
```
=== "Custom REST API and WebSocket"
- nats-server.conf
+ nats_server.conf
+ ```python
+ {!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/.devcontainer/nats_server.conf !}
+ ```
+
+
+
+ workflow.py
```python
- {!> docs_src/getting_started/nats_n_fastapi/nats-server.conf !}
+ {!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/my_fastagency_app/workflow.py !}
```
main_1_nats.py
```python
- {!> docs_src/getting_started/nats_n_fastapi/main_1_nats.py !}
+ {!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/my_fastagency_app/deployment/main_1_nats.py !}
```
@@ -298,7 +312,7 @@ Once everything is set up, you can run your FastAgency application using the fol
- Start **NATS** Docker container:
!!! note "Terminal 1"
```
- docker run -d --name nats-fastagency --rm -p 4222:4222 -p 9222:9222 -p 8222:8222 -v $(pwd)/nats-server.conf:/etc/nats/nats-server.conf -e FASTAGENCY_NATS_PASSWORD='fastagency_nats_password' nats:latest -c /etc/nats/nats-server.conf
+ docker run -d --name nats-fastagency --rm -p 4222:4222 -p 9222:9222 -p 8222:8222 -v $(pwd)/nats_server.conf:/etc/nats/nats_server.conf -e FASTAGENCY_NATS_PASSWORD='fastagency_nats_password' nats:latest -c /etc/nats/nats_server.conf
```
- Start **FastAPI** application that provides a conversational workflow:
@@ -326,7 +340,7 @@ Once everything is set up, you can run your FastAgency application using the fol
- Start **NATS** Docker container:
!!! note "Terminal 1"
```
- docker run -d --name nats-fastagency --rm -p 4222:4222 -p 9222:9222 -p 8222:8222 -v $(pwd)/nats-server.conf:/etc/nats/nats-server.conf -e FASTAGENCY_NATS_PASSWORD='fastagency_nats_password' nats:latest -c /etc/nats/nats-server.conf
+ docker run -d --name nats-fastagency --rm -p 4222:4222 -p 9222:9222 -p 8222:8222 -v $(pwd)/nats_server.conf:/etc/nats/nats_server.conf -e FASTAGENCY_NATS_PASSWORD='fastagency_nats_password' nats:latest -c /etc/nats/nats_server.conf
```
- Start **FastAPI** application that provides a conversational workflow:
@@ -356,7 +370,7 @@ Once everything is set up, you can run your FastAgency application using the fol
- Start **Nats** Docker container:
!!! note "Terminal 1"
```
- docker run -d --name nats-fastagency --rm -p 4222:4222 -p 9222:9222 -p 8222:8222 -v $(pwd)/nats-server.conf:/etc/nats/nats-server.conf -e FASTAGENCY_NATS_PASSWORD='fastagency_nats_password' nats:latest -c /etc/nats/nats-server.conf
+ docker run -d --name nats-fastagency --rm -p 4222:4222 -p 9222:9222 -p 8222:8222 -v $(pwd)/nats_server.conf:/etc/nats/nats_server.conf -e FASTAGENCY_NATS_PASSWORD='fastagency_nats_password' nats:latest -c /etc/nats/nats_server.conf
```
- Start **FastAPI** application that provides a conversational workflow:
diff --git a/docs/docs/en/user-guide/adapters/nats/index.md b/docs/docs/en/user-guide/adapters/nats/index.md
index 16ff4e8e..dd9111bd 100644
--- a/docs/docs/en/user-guide/adapters/nats/index.md
+++ b/docs/docs/en/user-guide/adapters/nats/index.md
@@ -56,20 +56,20 @@ In this example, we'll create a simple learning [**chatbot**](https://en.wikiped
### Step-by-Step Breakdown
-#### 1. **Import Required Modules**
+#### 1. **Define Workflow**
-To get started, import the required modules from the **FastAgency** and **AutoGen**. These imports provide the essential building blocks for creating agents, workflows, and integrating [**`MesopUI`**](../../../api/fastagency/ui/mesop/MesopUI.md). Additionally, import the [**`NatsAdapter`**](../../../api/fastagency/adapters/nats/NatsAdapter.md) class for workflow execution.
+Define the workflow that your application will use. This is where you specify how the agents interact and what they do. Here's an example workflow definition:
-```python hl_lines="9"
-{!> docs_src/getting_started/nats/main_1_nats.py [ln:1-11] !}
+```python
+{!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/my_fastagency_app/workflow.py [ln:1-47] !}
```
-#### 2. **Define Workflow**
+#### 2. **Import Required Modules**
-Define the workflow that your application will use. This is where you specify how the agents interact and what they do. Here's an example workflow definition:
+Next, import the required modules from the **FastAgency**. These imports provide the essential building blocks for integrating [**`MesopUI`**](../../../api/fastagency/ui/mesop/MesopUI.md). Additionally, import the [**`NatsAdapter`**](../../../api/fastagency/adapters/nats/NatsAdapter.md) class for workflow execution.
-```python
-{!> docs_src/getting_started/nats/main_1_nats.py [ln:3-57] !}
+```python hl_lines="4"
+{!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/my_fastagency_app/deployment/main_1_nats.py [ln:1-7] !}
```
#### 3. **Configure the Nats Adapter**
@@ -77,7 +77,7 @@ Define the workflow that your application will use. This is where you specify ho
Create an instance of the [**`NatsAdapter`**](../../../api/fastagency/adapters/nats/NatsAdapter.md) and pass your workflow to it. The adapter will handle the communication with the [**`NatsProvider`**](../../../api/fastagency/adapters/nats/NatsProvider.md) and distribute workflow execution to the workers.
```python
-{!> docs_src/getting_started/nats/main_1_nats.py [ln:59-64] !}
+{!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/my_fastagency_app/deployment/main_1_nats.py [ln:9-13] !}
```
#### 4. **Define FastAgency Application**
@@ -85,15 +85,15 @@ Create an instance of the [**`NatsAdapter`**](../../../api/fastagency/adapters/n
Create a [**`NatsAdapter`**](../../../api/fastagency/adapters/nats/NatsAdapter.md) and then add it to a [**FastAPI**](https://fastapi.tiangolo.com/){target="_blank"} application using the [**lifespan parameter**](https://fastapi.tiangolo.com/advanced/events/){target="_blank"}. The adapter will have all [**REST API**](https://en.wikipedia.org/wiki/REST){target="_blank"} and [**WebSocket**](https://en.wikipedia.org/wiki/WebSocket){target="_blank"} routes for communicating with a client.
```python
-{!> docs_src/getting_started/nats/main_1_nats.py [ln:66] !}
+{!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/my_fastagency_app/deployment/main_1_nats.py [ln:15] !}
```
#### 5. **Nats server setup**
The `NatsAdapter` requires a running NATS server. The easiest way to start the NATS server is by using [**Docker**](https://www.docker.com/){target="_blank"}. FastAgency leverages the [**JetStream**](https://docs.nats.io/nats-concepts/jetstream){target="_blank"} feature of NATS and also utilizes authentication.
-```python hl_lines="1 3 6 11 17"
-{!> docs_src/getting_started/nats_n_fastapi/nats-server.conf [ln:1-23]!}
+```python hl_lines="1 3 8 14"
+{!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/.devcontainer/nats_server.conf !}
```
In the above Nats configuration, we define a user called `fastagency`, and its password is read from the environment variable `FASTAGENCY_NATS_PASSWORD`. We also enable JetStream in Nats and configure Nats to serve via the appropriate ports.
@@ -103,23 +103,30 @@ In the above Nats configuration, we define a user called `fastagency`, and its p
Please copy and paste the following code into the same folder, using the file names exactly as mentioned below.
- nats-server.conf
+ nats_server.conf
+ ```python
+ {!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/.devcontainer/nats_server.conf !}
+ ```
+
+
+
+ workflow.py
```python
- {!> docs_src/getting_started/nats_n_fastapi/nats-server.conf !}
+ {!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/my_fastagency_app/workflow.py !}
```
main_1_nats.py
```python
- {!> docs_src/getting_started/nats/main_1_nats.py !}
+ {!> docs_src/getting_started/nats_n_fastapi/my_fastagency_app/my_fastagency_app/deployment/main_1_nats.py !}
```
main_2_mesop.py
```python
- {!> docs_src/getting_started/nats/main_2_mesop.py !}
+ {!> docs_src/getting_started/nats_n_fastapi/main_2_mesop.py !}
```
@@ -150,7 +157,7 @@ Please copy and paste the following code into the same folder, using the file na
- Start **NATS** Docker container:
!!! note "Terminal 1"
```
- docker run -d --name nats-fastagency --rm -p 4222:4222 -p 9222:9222 -p 8222:8222 -v $(pwd)/nats-server.conf:/etc/nats/nats-server.conf -e FASTAGENCY_NATS_PASSWORD='fastagency_nats_password' nats:latest -c /etc/nats/nats-server.conf
+ docker run -d --name nats-fastagency --rm -p 4222:4222 -p 9222:9222 -p 8222:8222 -v $(pwd)/nats_server.conf:/etc/nats/nats_server.conf -e FASTAGENCY_NATS_PASSWORD='fastagency_nats_password' nats:latest -c /etc/nats/nats_server.conf
```
- Start **FastAPI** application that provides a conversational workflow:
@@ -172,7 +179,7 @@ Please copy and paste the following code into the same folder, using the file na
- Start **NATS** Docker container:
!!! note "Terminal 1"
```
- docker run -d --name nats-fastagency --rm -p 4222:4222 -p 9222:9222 -p 8222:8222 -v $(pwd)/nats-server.conf:/etc/nats/nats-server.conf -e FASTAGENCY_NATS_PASSWORD='fastagency_nats_password' nats:latest -c /etc/nats/nats-server.conf
+ docker run -d --name nats-fastagency --rm -p 4222:4222 -p 9222:9222 -p 8222:8222 -v $(pwd)/nats_server.conf:/etc/nats/nats_server.conf -e FASTAGENCY_NATS_PASSWORD='fastagency_nats_password' nats:latest -c /etc/nats/nats_server.conf
```
- Start **FastAPI** application that provides a conversational workflow:
diff --git a/docs/docs_src/getting_started/fastapi/main_fastapi_custom_client.py b/docs/docs_src/getting_started/fastapi/main_fastapi_custom_client.py
new file mode 100644
index 00000000..98147fb2
--- /dev/null
+++ b/docs/docs_src/getting_started/fastapi/main_fastapi_custom_client.py
@@ -0,0 +1,152 @@
+import os
+from typing import Any
+
+from autogen.agentchat import ConversableAgent
+from fastapi import FastAPI
+from fastapi.responses import HTMLResponse
+
+from fastagency import UI
+from fastagency.adapters.fastapi import FastAPIAdapter
+from fastagency.runtimes.autogen import AutoGenWorkflows
+
+html = """
+
+
+
+ FastAgency Chat App
+
+
+ FastAgency Chat App
+
+
+
+
+
+"""
+
+llm_config = {
+ "config_list": [
+ {
+ "model": "gpt-4o-mini",
+ "api_key": os.getenv("OPENAI_API_KEY"),
+ }
+ ],
+ "temperature": 0.8,
+}
+
+wf = AutoGenWorkflows()
+
+@wf.register(name="simple_learning", description="Student and teacher learning chat")
+def simple_workflow(ui: UI, params: dict[str, Any]) -> str:
+ initial_message = ui.text_input(
+ sender="Workflow",
+ recipient="User",
+ prompt="I can help you learn about mathematics. What subject you would like to explore?",
+ )
+
+ student_agent = ConversableAgent(
+ name="Student_Agent",
+ system_message="You are a student willing to learn.",
+ llm_config=llm_config,
+ # human_input_mode="ALWAYS",
+ )
+ teacher_agent = ConversableAgent(
+ name="Teacher_Agent",
+ system_message="You are a math teacher.",
+ llm_config=llm_config,
+ # human_input_mode="ALWAYS",
+ )
+
+ chat_result = student_agent.initiate_chat(
+ teacher_agent,
+ message=initial_message,
+ summary_method="reflection_with_llm",
+ max_turns=5,
+ )
+
+ return chat_result.summary # type: ignore[no-any-return]
+
+adapter = FastAPIAdapter(provider=wf)
+
+app = FastAPI()
+app.include_router(adapter.router)
+
+@app.get("/")
+async def get() -> HTMLResponse:
+ return HTMLResponse(html)
+
+
+# start the provider with the following command
+# uvicorn main_fastapi_custom_client:app --port 8008 --reload
diff --git a/docs/docs_src/getting_started/nats_n_fastapi/main_2_fastapi_custom_client.py b/docs/docs_src/getting_started/nats_n_fastapi/main_2_fastapi_custom_client.py
new file mode 100644
index 00000000..5a5a1eba
--- /dev/null
+++ b/docs/docs_src/getting_started/nats_n_fastapi/main_2_fastapi_custom_client.py
@@ -0,0 +1,119 @@
+from os import environ
+
+from fastapi import FastAPI
+from fastapi.responses import HTMLResponse
+
+from fastagency.adapters.fastapi import FastAPIAdapter
+from fastagency.adapters.nats import NatsAdapter
+
+html = """
+
+
+
+ FastAgency Chat App
+
+
+ FastAgency Chat App
+
+
+
+
+
+"""
+
+nats_url = environ.get("NATS_URL", "nats://localhost:4222")
+nats_user: str = "fastagency"
+nats_password: str = environ.get("FASTAGENCY_NATS_PASSWORD", "fastagency_nats_password") # type: ignore[assignment]
+
+provider = NatsAdapter.create_provider(
+ nats_url=nats_url, user=nats_user, password=nats_password
+)
+
+adapter = FastAPIAdapter(
+ provider=provider,
+)
+
+# app = FastAPI(lifespan=provider.lifespan)
+app = FastAPI()
+app.include_router(adapter.router)
+
+
+@app.get("/")
+async def get() -> HTMLResponse:
+ return HTMLResponse(html)
+
+
+# start the provider with the following command
+# uvicorn main_2_fastapi_custom_client:app --port 8008 --reload
diff --git a/docs/docs_src/getting_started/nats_n_fastapi/main_2_mesop.py b/docs/docs_src/getting_started/nats_n_fastapi/main_2_mesop.py
new file mode 100644
index 00000000..4f3cdf52
--- /dev/null
+++ b/docs/docs_src/getting_started/nats_n_fastapi/main_2_mesop.py
@@ -0,0 +1,20 @@
+from os import environ
+
+from fastagency.adapters.nats import NatsAdapter
+from fastagency.app import FastAgency
+from fastagency.ui.mesop.mesop import MesopUI
+
+nats_url = environ.get("NATS_URL", "nats://localhost:4222")
+nats_user: str = "fastagency"
+nats_password: str = environ.get("FASTAGENCY_NATS_PASSWORD", "fastagency_nats_password") # type: ignore[assignment]
+
+provider = NatsAdapter.create_provider(
+ nats_url=nats_url, user=nats_user, password=nats_password
+)
+
+ui = MesopUI()
+
+app = FastAgency(provider=provider, ui=ui)
+
+# start the provider with the following command
+# gunicorn main_2_mesop:app -b 0.0.0.0:8888 --reload
diff --git a/scripts/build-docs.sh b/scripts/build-docs.sh
index 5e31755f..299096c2 100755
--- a/scripts/build-docs.sh
+++ b/scripts/build-docs.sh
@@ -7,7 +7,7 @@ set -x
# build docs/docs_src/getting_started
cd docs/docs_src/getting_started && \
- rm -rf fastapi mesop nats_n_fastapi; \
+ rm -rf fastapi/my_fastagency_app/ mesop/my_fastagency_app/ nats_n_fastapi/my_fastagency_app/; \
cookiecutter -f -o mesop --no-input https://github.com/airtai/cookiecutter-fastagency.git app_type=mesop && \
cd mesop && tree --noreport --dirsfirst my_fastagency_app > folder_structure.txt && cd .. && \
cookiecutter -f -o fastapi --no-input https://github.com/airtai/cookiecutter-fastagency.git app_type=fastapi+mesop && \