diff --git a/.secrets.baseline b/.secrets.baseline index bed90fa92..9ca325df9 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -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 } ], @@ -174,5 +174,5 @@ } ] }, - "generated_at": "2024-10-15T12:15:52Z" + "generated_at": "2024-10-15T13:23:39Z" } diff --git a/README.md b/README.md index cfc5ffbbb..f6cd42bf9 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 ``` diff --git a/docs/docs/en/getting-started/images/chat.png b/docs/docs/en/getting-started/images/chat.png index c588df8a3..5ff56fd74 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:2eb14bd85e87d0abacf927c4df988ae2ede3277412a4a97e426c453edb917af1 -size 92092 +oid sha256:fa5c3a3b8b59f7838e6e8dff078e0e1831cdbe99739b3a9c80ff9eb21a219b80 +size 90925 diff --git a/docs/docs/en/getting-started/index.md b/docs/docs/en/getting-started/index.md index 63d728a57..3d465fd8c 100644 --- a/docs/docs/en/getting-started/index.md +++ b/docs/docs/en/getting-started/index.md @@ -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 @@ -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 @@ -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 @@ -383,29 +383,39 @@ 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 @@ -413,23 +423,27 @@ Once everything is set up, you can run your FastAgency application using the fol === "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 diff --git a/docs/docs/en/user-guide/runtimes/autogen/index.md b/docs/docs/en/user-guide/runtimes/autogen/index.md index ca93c4626..b291451a0 100644 --- a/docs/docs/en/user-guide/runtimes/autogen/index.md +++ b/docs/docs/en/user-guide/runtimes/autogen/index.md @@ -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 diff --git a/docs/docs/en/user-guide/runtimes/autogen/interactions.md b/docs/docs/en/user-guide/runtimes/autogen/interactions.md index 4da29d4f6..fc7de9ee6 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: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 @@ -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: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 @@ -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: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 @@ -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 diff --git a/docs/docs/en/user-guide/runtimes/autogen/websurfer.md b/docs/docs/en/user-guide/runtimes/autogen/websurfer.md index ae63a0b1f..bc3a90eb9 100644 --- a/docs/docs/en/user-guide/runtimes/autogen/websurfer.md +++ b/docs/docs/en/user-guide/runtimes/autogen/websurfer.md @@ -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] !} ``` @@ -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. @@ -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" @@ -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 diff --git a/pyproject.toml b/pyproject.toml index c05d63b74..1bfcb585c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 @@ -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", ]