Skip to content

Commit

Permalink
Update docs (#214)
Browse files Browse the repository at this point in the history
* Fix runtime docs

* Remove 'cd docs' from documentation

* Fix security docs

* Add collapsable app code to each docs page

* Update security docs
  • Loading branch information
rjambrecic authored Sep 13, 2024
1 parent bdc676c commit 6b632f8
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 32 deletions.
17 changes: 17 additions & 0 deletions docs/docs/en/getting-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,23 @@ Next, define your FastAgency application. This ties together your workflow and t

For Mesop applications, use `MesopUI` to enable web-based interactions.


## Complete Application Code

<details>
<summary>Console</summary>
```python
{! docs_src/getting_started/main_console.py!}
```
</details>

<details>
<summary>Mesop</summary>
```python
{! docs_src/getting_started/main_mesop.py!}
```
</details>

### Run Application

Once everything is set up, you can run your FastAgency application using the following command:
Expand Down
14 changes: 12 additions & 2 deletions docs/docs/en/user-guide/api/openapi/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,25 @@ This code snippet sets up a simple weather agent that calls an external weather
Next, define your FastAgency application.

```python
{! docs_src/user_guide/external_rest_apis/main.py [ln:63] !}
{! docs_src/user_guide/external_rest_apis/main.py [ln:61] !}
```

## Complete Application Code

<details>
<summary>main.py</summary>
```python
{! docs_src/user_guide/external_rest_apis/main.py !}
```
</details>


## Run Application

You can run this chapter's FastAgency application using the following command:

```console
fastagency run docs/docs_src/user_guide/external_rest_apis/main.py
fastagency run
```

## Output
Expand Down
20 changes: 15 additions & 5 deletions docs/docs/en/user-guide/api/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ In this workflow, we create a Python client for the external REST API by passing
Additionally, we set the API key for the API using the `set_security_params` method:

```python hl_lines="2"
{! docs_src/user_guide/external_rest_apis/security.py [ln:33.5,34.5] !}
{! docs_src/user_guide/external_rest_apis/security.py [ln:26,27] !}
```

Here's a simple example of a workflow definition:

```python hl_lines="22"
{! docs_src/user_guide/external_rest_apis/security.py [ln:13-68] !}
```python hl_lines="15"
{! docs_src/user_guide/external_rest_apis/security.py [ln:13-66] !}
```

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.
Expand All @@ -45,15 +45,25 @@ This code snippet sets up a simple weather agent that calls an external weather
Next, define your FastAgency application.

```python
{! docs_src/user_guide/external_rest_apis/security.py [ln:71] !}
{! docs_src/user_guide/external_rest_apis/security.py [ln:68] !}
```

## Complete Application Code

<details>
<summary>main.py</summary>
```python
{! docs_src/user_guide/external_rest_apis/security.py !}
```
</details>


## Run Application

You can run this chapter's FastAgency application using the following command::

```console
fastagency run docs/docs_src/user_guide/external_rest_apis/security.py
fastagency run
```

## Output
Expand Down
15 changes: 12 additions & 3 deletions docs/docs/en/user-guide/runtime/autogen/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ In this example, we will create a simple weather chatbot using **AutoGen** in Fa
Before getting started, make sure you have installed FastAgency with support for the AutoGen runtime by running the following command:

```bash
pip install "fastagency[autogen]"
pip install "fastagency[autogen,openapi]"
```

This installation includes the AutoGen runtime, allowing you to build multi-agent workflows and integrate external APIs seamlessly.
Expand Down Expand Up @@ -73,11 +73,20 @@ Finally, we create the FastAgency application and launch it using the console in
{! docs_src/user_guide/runtime/autogen/main.py [ln:71-72] !}
```

## Complete Application Code

<details>
<summary>main.py</summary>
```python
{! docs_src/user_guide/runtime/autogen/main.py!}
```
</details>


### Running the Application

```bash
cd docs/docs_src/user_guide/runtime/autogen
fastagency run main.py
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.
Expand Down
6 changes: 4 additions & 2 deletions docs/docs/en/user-guide/runtime/autogen/interactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ We now register these functions with the workflow, linking the `student_agent` a
{! docs_src/user_guide/custom_user_interactions/main.py [ln: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,122.5,123.5] !}
```

## Define FastAgency Application
Finally, we'll define the entire application:
## Complete Application Code

<details>
<summary>main.py</summary>
```python
{! docs_src/user_guide/custom_user_interactions/main.py!}
```
</details>

## Run Application

Expand Down
14 changes: 12 additions & 2 deletions docs/docs/en/user-guide/ui/console/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,23 @@ Finally, we instantiate **[ConsoleUI](../../../../api/fastagency/ui/console/Cons

- **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.


## Complete Application Code

<details>
<summary>main.py</summary>
```python
{! docs_src/getting_started/main_console.py !}
```
</details>


### Running the Application

Once the workflow is set up, you can run the application using the **FastAgency CLI**. Navigate to the directory where the script is located and run the following command:

```bash
cd docs/docs_src/getting_started
fastagency run main_console.py
fastagency run
```

This will launch the console interface, allowing you to input messages as the student and observe how the teacher agent responds.
Expand Down
14 changes: 12 additions & 2 deletions docs/docs/en/user-guide/ui/mesop/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,23 @@ app = FastAgency(wf=wf, ui=MesopUI())

- **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.


## Complete Application Code

<details>
<summary>main.py</summary>
```python
{! docs_src/getting_started/main_mesop.py !}
```
</details>


### Running the Application

Once the workflow is set up, you can run the application using the **FastAgency CLI**. Navigate to the directory where the script is located and run the following command:

```bash
cd docs/docs_src/getting_started
fastagency run main_mesop.py
fastagency run
```

This will launch a local web server, and you will be able to access the MesopUI interface through your browser. The web interface will display the interaction between the student and teacher agents, allowing you to input questions and see the teacher’s responses.
Expand Down
4 changes: 1 addition & 3 deletions docs/docs_src/user_guide/external_rest_apis/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@
}

WEATHER_OPENAPI_URL = "https://weather.tools.fastagency.ai/openapi.json"
weather_api = OpenAPI.create(openapi_url=WEATHER_OPENAPI_URL)

wf = AutoGenWorkflows()


@wf.register(name="simple_weather", description="Weather chat")
def weather_workflow(wf: Workflows, ui: UI, initial_message: str, session_id: str) -> str:

weather_api = OpenAPI.create(openapi_url=WEATHER_OPENAPI_URL)

user_agent = UserProxyAgent(
name="User_Agent",
system_message="You are a user agent",
Expand Down
21 changes: 9 additions & 12 deletions docs/docs_src/user_guide/external_rest_apis/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,21 @@
}

WEATHER_OPENAPI_URL = "https://weather.tools.fastagency.ai/openapi.json"
weather_api = OpenAPI.create(openapi_url=WEATHER_OPENAPI_URL)

# Set global security params for all methods
weather_api.set_security_params(APIKeyHeader.Parameters(value="secure weather key"))
# Set security params for a specific method
# weather_api.set_security_params(
# APIKeyHeader.Parameters(value="secure weather key"),
# "get_daily_weather_daily_get",
# )

wf = AutoGenWorkflows()


@wf.register(name="simple_weather_with_security", description="Weather chat with security")
def weather_workflow_with_security(wf: Workflows, ui: UI, initial_message: str, session_id: str) -> str:

weather_api = OpenAPI.create(openapi_url=WEATHER_OPENAPI_URL)

# Set global security params for all methods
weather_api.set_security_params(APIKeyHeader.Parameters(value="secure weather key"))

# Set security params for a specific method
# weather_api.set_security_params(
# APIKeyHeader.Parameters(value="secure weather key"),
# "get_daily_weather_daily_get",
# )

user_agent = UserProxyAgent(
name="User_Agent",
system_message="You are a user agent",
Expand Down
2 changes: 1 addition & 1 deletion docs/docs_src/user_guide/runtime/autogen/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def weather_workflow(wf: AutoGenWorkflows, ui: UI, initial_message: str, session
"description": "Get the daily weather",
}
},
"get_daily_weather_weekly_get"
"get_hourly_weather_hourly_get"
]
)

Expand Down

0 comments on commit 6b632f8

Please sign in to comment.