Skip to content

Commit

Permalink
Test and update getting started page (#396)
Browse files Browse the repository at this point in the history
* Update getting started page

* Update getting started page

* polishing

* polishing

* Update getting started and readme.md

* Polishing

* Update line numbers

* Add target blank

* Update line numbers

* Update chat.png

* LFS fix

---------

Co-authored-by: Davor Runje <[email protected]>
Co-authored-by: Kumaran Rajendhiran <[email protected]>
  • Loading branch information
3 people authored Oct 15, 2024
1 parent 04a9c90 commit dd6ed3c
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
"filename": "docs/docs/en/getting-started/index.md",
"hashed_secret": "3be2e9dd1980856faddf5bd205e3ff96b24776aa",
"is_verified": false,
"line_number": 420,
"line_number": 431,
"is_secret": false
}
],
Expand Down Expand Up @@ -174,5 +174,5 @@
}
]
},
"generated_at": "2024-10-15T12:15:52Z"
"generated_at": "2024-10-15T13:23:39Z"
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ We will show you how to deploy your workflow using the **FastAPI + Mesop** combi
To get started, you need to install FastAgency. You can do this using `pip`, Python's package installer. Choose the installation command based on the interface you want to use:

```console
pip install "fastagency[autogen,mesop,fastapi]"
pip install "fastagency[autogen,mesop,fastapi,server]"
```

This command installs FastAgency with support for both the Console and Mesop
Expand Down Expand Up @@ -326,14 +326,14 @@ app = FastAgency(provider=provider, ui=MesopUI())
Once everything is set up, you can run your FastAgency application using the following command:


In this setup, we need to run two command in separate terminal windows:
In this setup, we need to run **two** commands in **separate** terminal windows:

#### Terminal 1
**Terminal 1** - Start **FastAPI** application using uvicorn
```
uvicorn main_1_fastapi:app --host 0.0.0.0 --port 8008 --reload
```

#### Terminal 2
**Terminal 2** - Start **Mesop** web interface using gunicorn
```
gunicorn main_2_mesop:app -b 0.0.0.0:8888 --reload
```
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/en/getting-started/images/chat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 31 additions & 17 deletions docs/docs/en/getting-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ To get started, you need to install FastAgency. You can do this using `pip`, Pyt

=== "FastAPI + Mesop"
```console
pip install "fastagency[autogen,mesop,fastapi]"
pip install "fastagency[autogen,mesop,fastapi,server]"
```

This command installs FastAgency with support for both the Console and Mesop
Expand All @@ -148,7 +148,7 @@ To get started, you need to install FastAgency. You can do this using `pip`, Pyt

=== "NATS + FastAPI + Mesop"
```console
pip install "fastagency[autogen,mesop,fastapi,nats]"
pip install "fastagency[autogen,mesop,fastapi,server,nats]"
```

This command installs FastAgency with support for both the Console and Mesop
Expand All @@ -172,12 +172,12 @@ To get started, you need to install FastAgency. You can do this using `pip`, Pyt

=== "FastAPI + Mesop"
```console
pip install "fastagency[pyautogen,mesop,fastapi]"
pip install "fastagency[pyautogen,mesop,fastapi,server]"
```

=== "NATS + FastAPI + Mesop"
```console
pip install "fastagency[pyautogen,mesop,fastapi,nats]"
pip install "fastagency[pyautogen,mesop,fastapi,server,nats]"
```

### Imports
Expand Down Expand Up @@ -383,53 +383,67 @@ Once everything is set up, you can run your FastAgency application using the fol

=== "Mesop"

!!! note "Terminal"
```
fastagency run
```
There are two options of running a Mesop application:

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` and then run it as follows:
1. Using [`fastagency`](../cli/cli/){target="_blank"} command line:

!!! note "Terminal (alternative)"
```
pip install gunicorn
gunicorn main:app
```
!!! note "Terminal (using [fastagency](../cli/cli/){target="_blank"})"
```
fastagency run
```

!!! danger "Currently not working on **MacOS**"
The above command is currently not working on **MacOS**, please use the alternative way of starting the application from below ([#362](https://github.com/airtai/fastagency/issues/362)).

2. Using [Gunicorn](https://gunicorn.org/){target="_blank"} WSGI HTTP server:

The preferred way to run the Mesop application is using a Python WSGI HTTP server like [Gunicorn](https://gunicorn.org/){target="_blank"}. First, you need to install it using package manager such as `pip` and then run it as follows:

!!! note "Terminal (using [Gunicorn](https://gunicorn.org/){target="_blank"})"
```
pip install gunicorn
gunicorn main:app
```

=== "FastAPI + Mesop"

In this setup, we need to run two command in separate terminal windows:
In this setup, we need to run **two** commands in **separate** terminal windows:

- Start **FastAPI** application using uvicorn:
!!! note "Terminal 1"
```
uvicorn main_1_fastapi:app --host 0.0.0.0 --port 8008 --reload
```

- Start **Mesop** web interface using gunicorn:
!!! note "Terminal 2"
```
gunicorn main_2_mesop:app -b 0.0.0.0:8888 --reload
```

=== "NATS + FastAPI + Mesop"

In this setup, we need to run four command in separate terminal windows:
In this setup, we need to run **four** commands in **separate** terminal windows:

- 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
```

- Start **FastAPI** application that provides a conversational workflow:
!!! note "Terminal 2"
```
uvicorn main_1_nats:app --reload
```

- Start **FastAPI** application integrated with a **NATS** messaging system:
!!! note "Terminal 3"
```
uvicorn main_2_fastapi:app --host 0.0.0.0 --port 8008 --reload
```

- Start **Mesop** web interface using gunicorn:
!!! note "Terminal 4"
```
gunicorn main_3_mesop:app -b 0.0.0.0:8888 --reload
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/en/user-guide/runtimes/autogen/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ The workflow is registered using **[AutoGenWorkflows](../../../api/fastagency/ru
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/runtimes/autogen/main.py [ln:53-66] !}
{! docs_src/user_guide/runtimes/autogen/main.py [ln:52-65] !}
```

#### 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/runtimes/autogen/main.py [ln:68-75] !}
{! docs_src/user_guide/runtimes/autogen/main.py [ln:67-74] !}
```

#### 7. **Create and Run the Application**
Finally, we create the FastAgency application and launch it using the console interface.

```python
{! docs_src/user_guide/runtimes/autogen/main.py [ln:78] !}
{! docs_src/user_guide/runtimes/autogen/main.py [ln:77] !}
```

### Complete Application Code
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/en/user-guide/runtimes/autogen/interactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ 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: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] !}
{! docs_src/user_guide/custom_user_interactions/main.py [ln:56.5,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] !}
```

### System Info Messages

`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: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] !}
{! docs_src/user_guide/custom_user_interactions/main.py [ln:75.5,76.5,77.5,78.5,79.5,80.5,81.5,82.5,83.5,84.5,85.5,86.5,87.5] !}
```

### Multiple Choice

`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: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] !}
{! docs_src/user_guide/custom_user_interactions/main.py [ln:89.5,90.5,91.5,92.5,93.5,94.5,95.5,96.5,97.5,98.5,99.5,100.5] !}
```

### Other Types of Messages
Expand All @@ -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: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] !}
{! docs_src/user_guide/custom_user_interactions/main.py [ln: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,122.5,123.5,124.5] !}
```

## Complete Application Code
Expand Down
12 changes: 6 additions & 6 deletions docs/docs/en/user-guide/runtimes/autogen/websurfer.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Here, the large language model is configured to use the `gpt-4o` model, and the

- **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="24"
```python hl_lines="18-25"
{!> docs_src/user_guide/runtimes/autogen/websurfer.py [ln:20-45] !}
```

Expand All @@ -80,14 +80,14 @@ 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/runtimes/autogen/websurfer_tool.py [ln:21-54] !}
```python hl_lines="27-31"
{!> docs_src/user_guide/runtimes/autogen/websurfer_tool.py [ln:21-52] !}
```

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/runtimes/autogen/websurfer_tool.py [ln:55-58] !}
{!> docs_src/user_guide/runtimes/autogen/websurfer_tool.py [ln:54-58] !}
```

The `executor` can be either a single instance of `ConversableAgent` or a `list of ConversableAgent` instances.
Expand All @@ -100,7 +100,7 @@ Here, the user agent starts a conversation with the websurfer agent, which perfo
=== "Using WebSurferAgent"

```python
{! docs_src/user_guide/runtimes/autogen/websurfer.py [ln:46-54] !}
{! docs_src/user_guide/runtimes/autogen/websurfer.py [ln:46-53] !}
```

=== "Enhancing an existing agent"
Expand All @@ -113,7 +113,7 @@ Here, the user agent starts a conversation with the websurfer agent, which perfo
Finally, we create the FastAgency application and launch it using the console interface.

```python
{! docs_src/user_guide/runtimes/autogen/websurfer.py [ln:57] !}
{! docs_src/user_guide/runtimes/autogen/websurfer.py [ln:56] !}
```

### Complete Application Code
Expand Down
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ nats = [
"faststream[nats]>=0.5.27,<0.6",
]

submodules = [
"fastagency[mesop,autogen,openapi,fastapi,nats]"
server = [
"uvicorn>=0.31.0",
"gunicorn>=23.0.0",
]

server = [
"uvicorn==0.31.0",
"gunicorn==23.0.0",
submodules = [
"fastagency[mesop,autogen,openapi,fastapi,nats,server]"
]

# dev dependencies
Expand Down Expand Up @@ -151,7 +151,7 @@ testing = [
]

dev = [
"fastagency[submodules,server,lint,testing,devdocs]",
"fastagency[submodules,lint,testing,devdocs]",
"pre-commit==4.0.1",
"detect-secrets==1.5.0",
]
Expand Down

0 comments on commit dd6ed3c

Please sign in to comment.