diff --git a/docs/docs/en/getting-started/index.md b/docs/docs/en/getting-started/index.md index 1b33ebf96..a0247f009 100644 --- a/docs/docs/en/getting-started/index.md +++ b/docs/docs/en/getting-started/index.md @@ -120,14 +120,14 @@ Depending on the interface you choose, you'll need to import different modules. === "Console" ```python hl_lines="7" - {!> docs_src/getting_started/main_console.py [ln:1-8] !} + {!> docs_src/getting_started/main_console.py [ln:1-7] !} ``` 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-8] !} + {!> docs_src/getting_started/main_mesop.py [ln:1-7] !} ``` 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:10-43] !} +{! docs_src/getting_started/main_console.py [ln:10-45] !} ``` 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. diff --git a/docs/docs/en/user-guide/api/openapi/index.md b/docs/docs/en/user-guide/api/openapi/index.md index 2cf7f3504..d7b137830 100644 --- a/docs/docs/en/user-guide/api/openapi/index.md +++ b/docs/docs/en/user-guide/api/openapi/index.md @@ -21,7 +21,7 @@ pip install "fastagency[autogen,openapi]" These imports are similar to the imports section we have already covered, with the only difference being the additional imports of the `OpenAPI` Client and `UserProxyAgent`: ```python -{! docs_src/user_guide/external_rest_apis/main.py [ln:1-11] !} +{! docs_src/user_guide/external_rest_apis/main.py [ln:1-9] !} ``` ## Define Workflow @@ -29,7 +29,7 @@ These imports are similar to the imports section we have already covered, with t 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:12-60] !} +{! docs_src/user_guide/external_rest_apis/main.py [ln:11-57] !} ``` 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. @@ -39,7 +39,7 @@ 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:61] !} +{! docs_src/user_guide/external_rest_apis/main.py [ln:60] !} ``` ## Complete Application Code diff --git a/docs/docs/en/user-guide/api/security.md b/docs/docs/en/user-guide/api/security.md index 184de6d29..7e9cb97cc 100644 --- a/docs/docs/en/user-guide/api/security.md +++ b/docs/docs/en/user-guide/api/security.md @@ -19,7 +19,7 @@ pip install "fastagency[autogen,openapi]" 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" -{! docs_src/user_guide/external_rest_apis/security.py [ln:1-11] !} +{! docs_src/user_guide/external_rest_apis/security.py [ln:1-10] !} ``` ## Define Workflow @@ -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:26,27] !} +{! docs_src/user_guide/external_rest_apis/security.py [ln:25,26] !} ``` Here's a simple example of a workflow definition: ```python hl_lines="15" -{! docs_src/user_guide/external_rest_apis/security.py [ln:13-66] !} +{! docs_src/user_guide/external_rest_apis/security.py [ln:12-69] !} ``` 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. @@ -45,7 +45,7 @@ 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:68] !} +{! docs_src/user_guide/external_rest_apis/security.py [ln:72] !} ``` ## Complete Application Code diff --git a/docs/docs/en/user-guide/basics.md b/docs/docs/en/user-guide/basics.md index 2fe90588b..6afead954 100644 --- a/docs/docs/en/user-guide/basics.md +++ b/docs/docs/en/user-guide/basics.md @@ -113,7 +113,7 @@ Depending on the interface you choose, you'll need to import different modules. === "Console" ```python - {!> docs_src/getting_started/main_console.py [ln:1-8] !} + {!> docs_src/getting_started/main_console.py [ln:1-7] !} ``` For Console applications, import `ConsoleUI` to handle command-line input and output. @@ -138,7 +138,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:10-43] !} +{! docs_src/getting_started/main_console.py [ln:10-45] !} ``` 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. diff --git a/docs/docs/en/user-guide/runtime/autogen/index.md b/docs/docs/en/user-guide/runtime/autogen/index.md index 2a58fd104..834436e4e 100644 --- a/docs/docs/en/user-guide/runtime/autogen/index.md +++ b/docs/docs/en/user-guide/runtime/autogen/index.md @@ -22,21 +22,21 @@ 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-11] !} +{! docs_src/user_guide/runtime/autogen/main.py [ln:1-9] !} ``` #### 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:12-22] !} +{! docs_src/user_guide/runtime/autogen/main.py [ln:11-19] !} ``` #### 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:23-26] !} +{! docs_src/user_guide/runtime/autogen/main.py [ln:21-23] !} ``` #### 4. **Define the Workflow and Agents** @@ -49,28 +49,28 @@ In this step, we create two agents: The workflow is registered using **[AutoGenWorkflows](../../../api/fastagency/runtime/autogen/AutoGenWorkflows/)**. ```python -{! docs_src/user_guide/runtime/autogen/main.py [ln:27-45] !} +{! docs_src/user_guide/runtime/autogen/main.py [ln:28-43] !} ``` #### 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:46-60] !} +{! docs_src/user_guide/runtime/autogen/main.py [ln:45-58] !} ``` #### 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:61-69] !} +{! docs_src/user_guide/runtime/autogen/main.py [ln:60-67] !} ``` #### 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:71-72] !} +{! docs_src/user_guide/runtime/autogen/main.py [ln:70] !} ``` ## Complete Application Code diff --git a/docs/docs/en/user-guide/runtime/autogen/interactions.md b/docs/docs/en/user-guide/runtime/autogen/interactions.md index ac5e42de0..0319d699f 100644 --- a/docs/docs/en/user-guide/runtime/autogen/interactions.md +++ b/docs/docs/en/user-guide/runtime/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: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,69.5,70.5] !} +{! 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] !} ``` ### 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:72.5,73.5,74.5,75.5,76.5,77.5,78.5,79.5,80.5,81.5,82.5,83.5,84.5,85.5] !} +{! 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] !} ``` ### 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:87.5,88.5,89.5,90.5,91.5,92.5,93.5,94.5,96.5,97.5,98.5,99.5] !} +{! 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] !} ``` ### 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: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] !} +{! 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] !} ``` ## Complete Application Code diff --git a/docs/docs/en/user-guide/ui/console/basics.md b/docs/docs/en/user-guide/ui/console/basics.md index 94ef34497..c6ba0f9e4 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-8] !} +{! docs_src/getting_started/main_console.py [ln:1-7] !} ``` - **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:20-44] !} +{! docs_src/getting_started/main_console.py [ln:22-44] !} ``` - **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-48] !} +{! docs_src/getting_started/main_console.py [ln:47] !} ``` - **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 c12904f1d..d01bebee8 100644 --- a/docs/docs/en/user-guide/ui/mesop/basics.md +++ b/docs/docs/en/user-guide/ui/mesop/basics.md @@ -22,7 +22,7 @@ This example shows how to create a simple learning chat where a student agent in We begin by importing the necessary modules from **FastAgency** and **AutoGen**. These imports provide the essential building blocks for creating agents, workflows, and integrating MesopUI. ```python -{! docs_src/getting_started/main_mesop.py [ln:1-8] !} +{! docs_src/getting_started/main_mesop.py [ln:1-7] !} ``` - **ConversableAgent**: This class allows the creation of agents that can engage in conversational tasks. @@ -43,7 +43,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/getting_started/main_mesop.py [ln:20-44] !} +{! docs_src/getting_started/main_mesop.py [ln:22-44] !} ``` - **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. diff --git a/docs/docs_src/getting_started/main_console.py b/docs/docs_src/getting_started/main_console.py index 3482ec500..e7b8e8d5b 100644 --- a/docs/docs_src/getting_started/main_console.py +++ b/docs/docs_src/getting_started/main_console.py @@ -2,10 +2,9 @@ from autogen.agentchat import ConversableAgent -from fastagency import FastAgency, Workflows -from fastagency import UI -from fastagency.ui.console import ConsoleUI +from fastagency import UI, FastAgency, Workflows from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.ui.console import ConsoleUI llm_config = { "config_list": [ @@ -21,7 +20,9 @@ @wf.register(name="simple_learning", description="Student and teacher learning chat") -def simple_workflow(wf: Workflows, ui: UI, initial_message: str, session_id: str) -> str: +def simple_workflow( + wf: Workflows, ui: UI, initial_message: str, session_id: str +) -> str: student_agent = ConversableAgent( name="Student_Agent", system_message="You are a student willing to learn.", @@ -43,5 +44,4 @@ def simple_workflow(wf: Workflows, ui: UI, initial_message: str, session_id: str return chat_result.summary # type: ignore[no-any-return] - app = FastAgency(wf=wf, ui=ConsoleUI()) diff --git a/docs/docs_src/getting_started/main_mesop.py b/docs/docs_src/getting_started/main_mesop.py index 73757bee8..0b55de5ca 100644 --- a/docs/docs_src/getting_started/main_mesop.py +++ b/docs/docs_src/getting_started/main_mesop.py @@ -2,10 +2,9 @@ from autogen.agentchat import ConversableAgent -from fastagency import FastAgency, Workflows -from fastagency import UI -from fastagency.ui.mesop import MesopUI +from fastagency import UI, FastAgency, Workflows from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.ui.mesop import MesopUI llm_config = { "config_list": [ @@ -21,7 +20,9 @@ @wf.register(name="simple_learning", description="Student and teacher learning chat") -def simple_workflow(wf: Workflows, ui: UI, initial_message: str, session_id: str) -> str: +def simple_workflow( + wf: Workflows, ui: UI, initial_message: str, session_id: str +) -> str: student_agent = ConversableAgent( name="Student_Agent", system_message="You are a student willing to learn.", @@ -43,5 +44,4 @@ def simple_workflow(wf: Workflows, ui: UI, initial_message: str, session_id: str return chat_result.summary # type: ignore[no-any-return] - app = FastAgency(wf=wf, ui=MesopUI()) diff --git a/docs/docs_src/user_guide/custom_user_interactions/main.py b/docs/docs_src/user_guide/custom_user_interactions/main.py index e1e526682..622e47767 100644 --- a/docs/docs_src/user_guide/custom_user_interactions/main.py +++ b/docs/docs_src/user_guide/custom_user_interactions/main.py @@ -1,14 +1,13 @@ import os -from typing import Annotated, Any, Dict, Optional +from typing import Annotated, Any, Optional from autogen import register_function from autogen.agentchat import ConversableAgent -from fastagency import FastAgency, Workflows -from fastagency import UI +from fastagency import UI, FastAgency, Workflows from fastagency.base import MultipleChoice, SystemMessage, TextInput -from fastagency.ui.console import ConsoleUI from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.ui.console import ConsoleUI llm_config = { "config_list": [ @@ -25,7 +24,6 @@ @wf.register(name="exam_practice", description="Student and teacher chat") def exam_learning(wf: Workflows, ui: UI, initial_message: str, session_id: str) -> str: - def is_termination_msg(msg: dict[str, Any]) -> bool: return msg["content"] is not None and "TERMINATE" in msg["content"] @@ -50,7 +48,7 @@ def is_termination_msg(msg: dict[str, Any]) -> bool: ) def retrieve_exam_questions( - message: Annotated[str, "Message for examiner"] + message: Annotated[str, "Message for examiner"], ) -> Optional[str]: try: msg = TextInput( @@ -85,7 +83,7 @@ def write_final_answers(message: Annotated[str, "Message for examiner"]) -> str: return f"write_final_answers() FAILED! {e}" def get_final_grade( - message: Annotated[str, "Message for examiner"] + message: Annotated[str, "Message for examiner"], ) -> Optional[str]: try: msg = MultipleChoice( diff --git a/docs/docs_src/user_guide/custom_user_interactions/main_mesop.py b/docs/docs_src/user_guide/custom_user_interactions/main_mesop.py index d6099f974..a608ee0f0 100644 --- a/docs/docs_src/user_guide/custom_user_interactions/main_mesop.py +++ b/docs/docs_src/user_guide/custom_user_interactions/main_mesop.py @@ -1,14 +1,13 @@ import os -from typing import Annotated, Any, Dict, Optional +from typing import Annotated, Any, Optional from autogen import register_function from autogen.agentchat import ConversableAgent -from fastagency import FastAgency, Workflows -from fastagency import UI -from fastagency.base import MultipleChoice, SystemMessage, TextInput -from fastagency.ui.mesop import MesopUI +from fastagency import UI, FastAgency, Workflows +from fastagency.base import MultipleChoice, SystemMessage from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.ui.mesop import MesopUI llm_config = { "config_list": [ @@ -25,7 +24,6 @@ @wf.register(name="exam_practice", description="Student and teacher chat") def exam_learning(wf: Workflows, ui: UI, initial_message: str, session_id: str) -> str: - def is_termination_msg(msg: dict[str, Any]) -> bool: return msg["content"] is not None and "TERMINATE" in msg["content"] @@ -50,7 +48,7 @@ def is_termination_msg(msg: dict[str, Any]) -> bool: ) def retrieve_exam_questions( - message: Annotated[str, "Message for examiner"] + message: Annotated[str, "Message for examiner"], ) -> Optional[str]: try: msg = MultipleChoice( @@ -64,7 +62,7 @@ def retrieve_exam_questions( "4) The Last Supper", "5) Vitruvian Man", ], - default="1) Mona Lisa" + default="1) Mona Lisa", ) return ui.process_message(msg) except Exception as e: @@ -86,7 +84,7 @@ def write_final_answers(message: Annotated[str, "Message for examiner"]) -> str: return f"write_final_answers() FAILED! {e}" def get_final_grade( - message: Annotated[str, "Message for examiner"] + message: Annotated[str, "Message for examiner"], ) -> Optional[str]: try: msg = MultipleChoice( diff --git a/docs/docs_src/user_guide/external_rest_apis/main.py b/docs/docs_src/user_guide/external_rest_apis/main.py index 9e3c67d7a..b9588084b 100644 --- a/docs/docs_src/user_guide/external_rest_apis/main.py +++ b/docs/docs_src/user_guide/external_rest_apis/main.py @@ -3,13 +3,10 @@ from autogen import UserProxyAgent from autogen.agentchat import ConversableAgent -from fastagency import FastAgency, Workflows -from fastagency import UI -from fastagency.ui.console import ConsoleUI -from fastagency.runtime.autogen.base import AutoGenWorkflows - +from fastagency import UI, FastAgency, Workflows from fastagency.api.openapi import OpenAPI - +from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.ui.console import ConsoleUI llm_config = { "config_list": [ @@ -28,7 +25,9 @@ @wf.register(name="simple_weather", description="Weather chat") -def weather_workflow(wf: Workflows, ui: UI, initial_message: str, session_id: str) -> str: +def weather_workflow( + wf: Workflows, ui: UI, initial_message: str, session_id: str +) -> str: user_agent = UserProxyAgent( name="User_Agent", system_message="You are a user agent", diff --git a/docs/docs_src/user_guide/external_rest_apis/main_mesop.py b/docs/docs_src/user_guide/external_rest_apis/main_mesop.py index fc636f44c..5e75cee7b 100644 --- a/docs/docs_src/user_guide/external_rest_apis/main_mesop.py +++ b/docs/docs_src/user_guide/external_rest_apis/main_mesop.py @@ -3,13 +3,10 @@ from autogen import UserProxyAgent from autogen.agentchat import ConversableAgent -from fastagency import FastAgency, Workflows -from fastagency import UI -from fastagency.ui.mesop import MesopUI -from fastagency.runtime.autogen.base import AutoGenWorkflows - +from fastagency import UI, FastAgency, Workflows from fastagency.api.openapi import OpenAPI - +from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.ui.mesop import MesopUI llm_config = { "config_list": [ @@ -27,8 +24,9 @@ @wf.register(name="simple_weather", description="Weather chat") -def weather_workflow(wf: Workflows, ui: UI, initial_message: str, session_id: str) -> str: - +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( diff --git a/docs/docs_src/user_guide/external_rest_apis/security.py b/docs/docs_src/user_guide/external_rest_apis/security.py index ee54a19e2..5ccca1920 100644 --- a/docs/docs_src/user_guide/external_rest_apis/security.py +++ b/docs/docs_src/user_guide/external_rest_apis/security.py @@ -3,12 +3,11 @@ from autogen import UserProxyAgent from autogen.agentchat import ConversableAgent -from fastagency import FastAgency, Workflows -from fastagency import UI -from fastagency.ui.console import ConsoleUI -from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency import UI, FastAgency, Workflows from fastagency.api.openapi.client import OpenAPI from fastagency.api.openapi.security import APIKeyHeader +from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.ui.console import ConsoleUI llm_config = { "config_list": [ @@ -25,6 +24,7 @@ # 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"), @@ -34,8 +34,12 @@ 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: +@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: user_agent = UserProxyAgent( name="User_Agent", system_message="You are a user agent", diff --git a/docs/docs_src/user_guide/runtime/autogen/main.py b/docs/docs_src/user_guide/runtime/autogen/main.py index c83f2325a..02209e857 100644 --- a/docs/docs_src/user_guide/runtime/autogen/main.py +++ b/docs/docs_src/user_guide/runtime/autogen/main.py @@ -3,13 +3,10 @@ from autogen import UserProxyAgent from autogen.agentchat import ConversableAgent -from fastagency import FastAgency -from fastagency import UI -from fastagency.ui.console import ConsoleUI -from fastagency.runtime.autogen.base import AutoGenWorkflows - +from fastagency import UI, FastAgency from fastagency.api.openapi import OpenAPI - +from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.ui.console import ConsoleUI llm_config = { "config_list": [ @@ -21,15 +18,17 @@ "temperature": 0.0, } -openapi_url="https://weather.tools.fastagency.ai/openapi.json" +openapi_url = "https://weather.tools.fastagency.ai/openapi.json" weather_api = OpenAPI.create(openapi_url=openapi_url) wf = AutoGenWorkflows() -@wf.register(name="simple_weather", description="Weather chat") # type: ignore[type-var] -def weather_workflow(wf: AutoGenWorkflows, ui: UI, initial_message: str, session_id: str) -> str: +@wf.register(name="simple_weather", description="Weather chat") # type: ignore[type-var] +def weather_workflow( + wf: AutoGenWorkflows, ui: UI, initial_message: str, session_id: str +) -> str: user_agent = UserProxyAgent( name="User_Agent", system_message="You are a user agent", @@ -54,8 +53,8 @@ def weather_workflow(wf: AutoGenWorkflows, ui: UI, initial_message: str, session "description": "Get the daily weather", } }, - "get_hourly_weather_hourly_get" - ] + "get_hourly_weather_hourly_get", + ], ) chat_result = user_agent.initiate_chat(