From ba2e089295d8d01da3b50c33286990bb032ff359 Mon Sep 17 00:00:00 2001 From: rjambrecic <32619626+rjambrecic@users.noreply.github.com> Date: Wed, 23 Oct 2024 23:47:27 +0200 Subject: [PATCH] Add bing api key to websurfer and fix documentation warnings (#470) * wip * wip * Update links * Update links * Update lines * Update docs * polishing * polishing --------- Co-authored-by: Davor Runje --- docs/docs/SUMMARY.md | 6 +- .../WebSurferAnswer.md | 2 +- .../WebSurferTool.md | 2 +- docs/docs/en/getting-started/index.md | 4 +- docs/docs/en/tutorial/giphy/index.md | 16 +- docs/docs/en/tutorial/whatsapp/index.md | 32 +-- docs/docs/en/user-guide/adapters/index.md | 6 +- docs/docs/en/user-guide/api/index.md | 8 +- docs/docs/en/user-guide/basics.md | 229 ------------------ docs/docs/en/user-guide/cli/index.md | 2 +- docs/docs/en/user-guide/index.md | 10 +- .../en/user-guide/runtimes/autogen/index.md | 2 +- .../runtimes/autogen/interactions.md | 4 +- .../user-guide/runtimes/autogen/websurfer.md | 27 ++- docs/docs/en/user-guide/runtimes/index.md | 8 +- docs/docs/en/user-guide/ui/console/basics.md | 16 +- docs/docs/en/user-guide/ui/index.md | 12 +- docs/docs/en/user-guide/ui/mesop/basics.md | 22 +- docs/docs_src/tutorial/giphy/main.py | 1 + docs/docs_src/tutorial/whatsapp/main.py | 1 + .../user_guide/runtimes/autogen/websurfer.py | 1 + .../runtimes/autogen/websurfer_tool.py | 1 + fastagency/adapters/fastapi/base.py | 3 - .../runtimes/autogen/agents/websurfer.py | 5 +- fastagency/runtimes/autogen/tools/__init__.py | 2 +- .../tools/{web_surfer.py => websurfer.py} | 5 +- 26 files changed, 109 insertions(+), 318 deletions(-) rename docs/docs/en/api/fastagency/runtimes/autogen/tools/{web_surfer => websurfer}/WebSurferAnswer.md (62%) rename docs/docs/en/api/fastagency/runtimes/autogen/tools/{web_surfer => websurfer}/WebSurferTool.md (63%) delete mode 100644 docs/docs/en/user-guide/basics.md rename fastagency/runtimes/autogen/tools/{web_surfer.py => websurfer.py} (99%) diff --git a/docs/docs/SUMMARY.md b/docs/docs/SUMMARY.md index 8bfc563fd..ffa677c31 100644 --- a/docs/docs/SUMMARY.md +++ b/docs/docs/SUMMARY.md @@ -159,9 +159,9 @@ search: - [Toolable](api/fastagency/runtimes/autogen/autogen/Toolable.md) - tools - [WebSurferTool](api/fastagency/runtimes/autogen/tools/WebSurferTool.md) - - web_surfer - - [WebSurferAnswer](api/fastagency/runtimes/autogen/tools/web_surfer/WebSurferAnswer.md) - - [WebSurferTool](api/fastagency/runtimes/autogen/tools/web_surfer/WebSurferTool.md) + - websurfer + - [WebSurferAnswer](api/fastagency/runtimes/autogen/tools/websurfer/WebSurferAnswer.md) + - [WebSurferTool](api/fastagency/runtimes/autogen/tools/websurfer/WebSurferTool.md) - ui - console - [ConsoleUI](api/fastagency/ui/console/ConsoleUI.md) diff --git a/docs/docs/en/api/fastagency/runtimes/autogen/tools/web_surfer/WebSurferAnswer.md b/docs/docs/en/api/fastagency/runtimes/autogen/tools/websurfer/WebSurferAnswer.md similarity index 62% rename from docs/docs/en/api/fastagency/runtimes/autogen/tools/web_surfer/WebSurferAnswer.md rename to docs/docs/en/api/fastagency/runtimes/autogen/tools/websurfer/WebSurferAnswer.md index 636f139e9..462c2d673 100644 --- a/docs/docs/en/api/fastagency/runtimes/autogen/tools/web_surfer/WebSurferAnswer.md +++ b/docs/docs/en/api/fastagency/runtimes/autogen/tools/websurfer/WebSurferAnswer.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.runtimes.autogen.tools.web_surfer.WebSurferAnswer +::: fastagency.runtimes.autogen.tools.websurfer.WebSurferAnswer diff --git a/docs/docs/en/api/fastagency/runtimes/autogen/tools/web_surfer/WebSurferTool.md b/docs/docs/en/api/fastagency/runtimes/autogen/tools/websurfer/WebSurferTool.md similarity index 63% rename from docs/docs/en/api/fastagency/runtimes/autogen/tools/web_surfer/WebSurferTool.md rename to docs/docs/en/api/fastagency/runtimes/autogen/tools/websurfer/WebSurferTool.md index c0f498bf5..033562601 100644 --- a/docs/docs/en/api/fastagency/runtimes/autogen/tools/web_surfer/WebSurferTool.md +++ b/docs/docs/en/api/fastagency/runtimes/autogen/tools/websurfer/WebSurferTool.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.runtimes.autogen.tools.web_surfer.WebSurferTool +::: fastagency.runtimes.autogen.tools.websurfer.WebSurferTool diff --git a/docs/docs/en/getting-started/index.md b/docs/docs/en/getting-started/index.md index dcdb24560..65048205d 100644 --- a/docs/docs/en/getting-started/index.md +++ b/docs/docs/en/getting-started/index.md @@ -385,9 +385,9 @@ Once everything is set up, you can run your FastAgency application using the fol There are two options of running a Mesop application: - 1. Using [`fastagency`](../cli/cli/){target="_blank"} command line: + 1. Using [`fastagency`](../cli/cli.md){target="_blank"} command line: - !!! note "Terminal (using [fastagency](../cli/cli/){target="_blank"})" + !!! note "Terminal (using [fastagency](../cli/cli.md){target="_blank"})" ``` fastagency run ``` diff --git a/docs/docs/en/tutorial/giphy/index.md b/docs/docs/en/tutorial/giphy/index.md index e88985884..d80043797 100644 --- a/docs/docs/en/tutorial/giphy/index.md +++ b/docs/docs/en/tutorial/giphy/index.md @@ -98,7 +98,7 @@ Also, we configure the **Giphy API** with the __*GIPHY_API_KEY*__ using __*set_s {! docs_src/tutorial/giphy/main.py [ln:25-29] !} ``` -For more information, visit [**API Integration User Guide**](../../user-guide/api){target="_blank"}. +For more information, visit [**API Integration User Guide**](../../user-guide/api/index.md){target="_blank"}. ### Registering the Workflow @@ -118,10 +118,10 @@ This is a core function used by the **GiphyAgent** to either present the task re ### Creating the Giphy and WebSurfer Agents - **GiphyAgent**: A ***ConversableAgent*** is created with the name "Giphy_Agent". It uses the system message defined earlier and relies on the termination function to end the chat when needed. -- **WebSurferAgent**: The ***WebSurferAgent*** is responsible for scraping web content and passes the retrieved data to the **GiphyAgent**. It’s configured with a summarizer to condense web content, which is useful when presenting concise data to the user. For more information, visit [**WebSurfer User Guide**](../../user-guide/runtimes/autogen/websurfer){target="_blank"}. +- **WebSurferAgent**: The ***WebSurferAgent*** is responsible for scraping web content and passes the retrieved data to the **GiphyAgent**. It’s configured with a summarizer to condense web content, which is useful when presenting concise data to the user. For more information, visit [**WebSurfer User Guide**](../../user-guide/runtimes/autogen/websurfer.md){target="_blank"}. ```python -{! docs_src/tutorial/giphy/main.py [ln:77-91] !} +{! docs_src/tutorial/giphy/main.py [ln:77-92] !} ``` ### Registering Functions @@ -129,12 +129,12 @@ This is a core function used by the **GiphyAgent** to either present the task re The function ***present_completed_task_or_ask_question*** is registered to allow the **GiphyAgent** to ask questions or present completed tasks after receiving data from the **WebSurferAgent**. ```python -{! docs_src/tutorial/giphy/main.py [ln:93-100] !} +{! docs_src/tutorial/giphy/main.py [ln:94-101] !} ``` We specify which Giphy API functions can be used by the **GiphyAgent**: *random_gif*, *search_gifs*, and *trending_gifs*. These functions allow the agent to generate GIFs based on user input or trending content. ```python -{! docs_src/tutorial/giphy/main.py [ln:102-108] !} +{! docs_src/tutorial/giphy/main.py [ln:103-109] !} ``` ### Initiating the Chat @@ -144,7 +144,7 @@ We initiate the conversation between the user, **WebSurferAgent**, and **GiphyAg Once the conversation ends, the summary is returned to the user, wrapping up the session. ```python -{! docs_src/tutorial/giphy/main.py [ln:116-123] !} +{! docs_src/tutorial/giphy/main.py [ln:117-124] !} ``` ### Starting the Application @@ -152,10 +152,10 @@ Once the conversation ends, the summary is returned to the user, wrapping up the The FastAgency app is created, using the registered workflows (***wf***) and web-based user interface (***MesopUI***). This makes the conversation between agents and the user interactive. ```python -{! docs_src/tutorial/giphy/main.py [ln:126] !} +{! docs_src/tutorial/giphy/main.py [ln:127] !} ``` -For more information, visit [**Mesop User Guide**](../../user-guide/ui/mesop/basics){target="_blank"}. +For more information, visit [**Mesop User Guide**](../../user-guide/ui/mesop/basics.md){target="_blank"}. ## Running the Application diff --git a/docs/docs/en/tutorial/whatsapp/index.md b/docs/docs/en/tutorial/whatsapp/index.md index 06853075f..fd5fd1fe8 100644 --- a/docs/docs/en/tutorial/whatsapp/index.md +++ b/docs/docs/en/tutorial/whatsapp/index.md @@ -2,7 +2,7 @@ In this tutorial, we will explore how to leverage the **FastAgency** framework to create a dynamic and interactive chatbot that integrates two powerful agents: -1. [**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer/WebSurferAgent.md): A web-scraping agent capable of retrieving relevant content from webpages (learn more [here](../../user-guide/runtimes/autogen/websurfer)). +1. [**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer_agent/WebSurferAgent.md): A web-scraping agent capable of retrieving relevant content from webpages (learn more [here](../../user-guide/runtimes/autogen/websurfer.md)). 2. **WhatsApp agent** – An agent that interacts with the [Infobip WhatsApp API](https://www.infobip.com/docs/api/channels/whatsapp){target="_blank"} to send WhatsApp messages based on the user’s request. It will be created using the standard [**`ConversableAgent`**](https://microsoft.github.io/autogen/0.2/docs/reference/agentchat/conversable_agent/){target="_blank"} from [AutoGen](https://microsoft.github.io/autogen){target="_blank"} and the [**`OpenAPI`**](../../api/fastagency/api/openapi/OpenAPI.md) object instantiated with an OpenAPI [specification](https://raw.githubusercontent.com/airtai/fastagency/refs/heads/main/examples/openapi/whatsapp_openapi.json){target="_blank"} of Infobip's [REST API](https://www.infobip.com/docs/api/channels/whatsapp){target="_blank"}. @@ -13,7 +13,7 @@ The chat system will operate between these two agents and the user, allowing the By the end of this tutorial, you will understand how to: 1. Integrate external APIs like [Infobip WhatsApp API](https://www.infobip.com/docs/api/channels/whatsapp){target="_blank"} using [**`OpenAPI`**](../../api/fastagency/api/openapi/OpenAPI.md). -2. Build and register agents that autonomously scrape the web for relevant information using [**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer/WebSurferAgent.md). +2. Build and register agents that autonomously scrape the web for relevant information using [**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer_agent/WebSurferAgent.md). 3. Use [**`AutoGenWorkflows`**](../../api/fastagency/runtimes/autogen/AutoGenWorkflows.md) to manage agent interactions and user input. 4. Present scraped content to the user and offer sending that content via WhatsApp. 5. Handle secure API credentials and ensure safe communication between agents using [**`APIKeyHeader`**](../../api/fastagency/api/openapi/security/APIKeyHeader.md). @@ -36,7 +36,7 @@ pip install "fastagency[autogen,mesop,openapi]" ``` ### API Key Setup -[**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer/WebSurferAgent.md) requires an **Bing Web Search** API key and **WhatsAppAgent** requires an API key to interact with Infobip's WhatsApp service. Follow these steps to create your API keys: +[**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer_agent/WebSurferAgent.md) requires an **Bing Web Search** API key and **WhatsAppAgent** requires an API key to interact with Infobip's WhatsApp service. Follow these steps to create your API keys: #### Create Bing Web Search API Key To create [Bing Web Search](https://www.microsoft.com/en-us/bing/apis/pricing){target="_blank"} API key, follow the guide provided. @@ -101,7 +101,7 @@ You can set the API keys in your terminal as an environment variable: ## Code Walkthrough -Now we will go over each key part of the code, explaining its function and purpose within the FastAgency framework. Understanding these components is crucial for building a dynamic interaction between the user, the [**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer/WebSurferAgent.md), and the **WhatsAppAgent**. +Now we will go over each key part of the code, explaining its function and purpose within the FastAgency framework. Understanding these components is crucial for building a dynamic interaction between the user, the [**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer_agent/WebSurferAgent.md), and the **WhatsAppAgent**. ### Creating the WhatsApp API Instance The following lines shows hot to initializes the WhatsApp API by loading the OpenAPI specification from a URL. The OpenAPI spec defines how to interact with the WhatsApp API, including endpoints, parameters, and security details. @@ -111,7 +111,7 @@ Also, we configure the **WhatsApp API** with the __*WHATSAPP_API_KEY*__ using __ {! docs_src/tutorial/whatsapp/main.py [ln:24-31] !} ``` -For more information, visit [**API Integration User Guide**](../../user-guide/api){target="_blank"}. +For more information, visit [**API Integration User Guide**](../../user-guide/api/index.md){target="_blank"}. ### Registering the Workflow @@ -132,35 +132,35 @@ This is a core function used by the **WhatsAppAgent** to either present the task ### Creating the WhatsApp and WebSurfer Agents - **WhatsAppAgent**: A [**`ConversableAgent`**](https://microsoft.github.io/autogen/0.2/docs/reference/agentchat/conversable_agent/){target="_blank"} is created with the name "WhatsApp_Agent". It uses the system message defined earlier and relies on the termination function to end the chat when needed. -- [**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer/WebSurferAgent.md): The [**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer/WebSurferAgent.md) is responsible for scraping web content and passes the retrieved data to the **WhatsAppAgent**. It’s configured with a summarizer to condense web content, which is useful when presenting concise data to the user. For more information, visit [**WebSurfer User Guide**](../../user-guide/runtimes/autogen/websurfer). +- [**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer_agent/WebSurferAgent.md): The [**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer_agent/WebSurferAgent.md) is responsible for scraping web content and passes the retrieved data to the **WhatsAppAgent**. It’s configured with a summarizer to condense web content, which is useful when presenting concise data to the user. For more information, visit [**WebSurfer User Guide**](../../user-guide/runtimes/autogen/websurfer.md). ```python -{! docs_src/tutorial/whatsapp/main.py [ln:77-93] !} +{! docs_src/tutorial/whatsapp/main.py [ln:77-94] !} ``` ### Registering Functions -The function ***present_completed_task_or_ask_question*** is registered to allow the **WhatsAppAgent** to ask questions or present completed tasks after receiving data from the [**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer/WebSurferAgent.md). +The function ***present_completed_task_or_ask_question*** is registered to allow the **WhatsAppAgent** to ask questions or present completed tasks after receiving data from the [**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer_agent/WebSurferAgent.md). ```python -{! docs_src/tutorial/whatsapp/main.py [ln:94-102] !} +{! docs_src/tutorial/whatsapp/main.py [ln:95-103] !} ``` We register the WhatsApp API, which allows the **WhatsAppAgent** to handle tasks like suggesting messages that will be sent to the user. ```python -{! docs_src/tutorial/whatsapp/main.py [ln:104-108] !} +{! docs_src/tutorial/whatsapp/main.py [ln:105-109] !} ``` ### Initiating the Chat -We initiate the conversation between the user, [**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer/WebSurferAgent.md), and **WhatsAppAgent**. The user’s initial message is provided, and the system is configured to handle up to 10 turns of interaction. The conversation is summarized using the ***reflection_with_llm*** method, which uses a language model to summarize the chat. +We initiate the conversation between the user, [**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer_agent/WebSurferAgent.md), and **WhatsAppAgent**. The user’s initial message is provided, and the system is configured to handle up to 10 turns of interaction. The conversation is summarized using the ***reflection_with_llm*** method, which uses a language model to summarize the chat. Once the conversation ends, the summary is returned to the user, wrapping up the session. ```python -{! docs_src/tutorial/whatsapp/main.py [ln:116-123] !} +{! docs_src/tutorial/whatsapp/main.py [ln:117-124] !} ``` ### Starting the Application @@ -168,10 +168,10 @@ Once the conversation ends, the summary is returned to the user, wrapping up the The FastAgency app is created, using the registered workflows (**`wf`**) and web-based user interface ([**`MesopUI`**](../../api/fastagency/ui/mesop/MesopUI.md)). This makes the conversation between agents and the user interactive. ```python -{! docs_src/tutorial/whatsapp/main.py [ln:126] !} +{! docs_src/tutorial/whatsapp/main.py [ln:127] !} ``` -For more information, visit [**Mesop User Guide**](../../user-guide/ui/mesop/basics){target="_blank"}. +For more information, visit [**Mesop User Guide**](../../user-guide/ui/mesop/basics.md){target="_blank"}. ## Running the Application @@ -261,7 +261,7 @@ In this scenario, the user instructs the agents to scrape [BBC Sport](https://ww ![Initial message](./images/initial_message.png) -Upon receiving the request, [**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer/WebSurferAgent.md) initiates the process by scraping the webpage for relevant updates. +Upon receiving the request, [**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer_agent/WebSurferAgent.md) initiates the process by scraping the webpage for relevant updates. ![Scraping](./images/scraping.png) @@ -279,4 +279,4 @@ Finally, the results are delivered to the user through a WhatsApp message. ## Conclusion -In summary, connecting **FastAgency** with the **Infobip WhatsApp API** lets you create chat systems that can gather web data and send it straight to users on WhatsApp. By using two agents — [**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer/WebSurferAgent.md) to pull web content and **WhatsAppAgent** for messaging, you can build engaging experiences for users. This tutorial covered the essential steps to set up these agents, secure the API, and manage user interactions. With this setup, you can enhance your chatbot’s capabilities, providing real-time information and smooth communication across different platforms. +In summary, connecting **FastAgency** with the **Infobip WhatsApp API** lets you create chat systems that can gather web data and send it straight to users on WhatsApp. By using two agents — [**`WebSurferAgent`**](../../api/fastagency/runtimes/autogen/agents/websurfer_agent/WebSurferAgent.md) to pull web content and **WhatsAppAgent** for messaging, you can build engaging experiences for users. This tutorial covered the essential steps to set up these agents, secure the API, and manage user interactions. With this setup, you can enhance your chatbot’s capabilities, providing real-time information and smooth communication across different platforms. diff --git a/docs/docs/en/user-guide/adapters/index.md b/docs/docs/en/user-guide/adapters/index.md index 7d76db181..cf429ba57 100644 --- a/docs/docs/en/user-guide/adapters/index.md +++ b/docs/docs/en/user-guide/adapters/index.md @@ -24,7 +24,7 @@ Use the [**`FastAPIAdapter`**](../../api/fastagency/adapters/fastapi/FastAPIAdap - **Simplified Production Setup**: Choose this adapter if you need a **simple and easy-to-manage** production setup for deploying your FastAgency workflows as a REST API. -[Learn more about **FastAPI adapter** →](./fastapi/) +[Learn more about **FastAPI adapter** →](./fastapi/index.md) ### FastAPI + Nats.io @@ -36,7 +36,7 @@ The [**`FastAPIAdapter`**](../../api/fastagency/adapters/fastapi/FastAPIAdapter. - **High User Demand**: When your application needs to handle a large number of users or messages and requires high scalability, the FastAPI + NATS Adapter is an excellent choice. It is well-suited for building **scalable custom chat applications for larger companies or external customers**. - **Conversation Auditing**: If you need the ability to **audit conversations**, the NATS Adapter provides the necessary infrastructure to enable this feature. -[Learn more about **FastAPI + NATS.io adapter** →](./fastapi_nats/) +[Learn more about **FastAPI + NATS.io adapter** →](./fastapi_nats/index.md) ### Nats.io @@ -51,4 +51,4 @@ Utilize the [**`NatsAdapter`**](../../api/fastagency/adapters/nats/NatsAdapter.m - **Conversation Auditing**: If you need the ability to **audit conversations**, the NATS Adapter provides the necessary infrastructure to enable this feature. -[Learn more about **NATS.io adapter** →](./nats/) +[Learn more about **NATS.io adapter** →](./nats/index.md) diff --git a/docs/docs/en/user-guide/api/index.md b/docs/docs/en/user-guide/api/index.md index 637e0087f..98855afc1 100644 --- a/docs/docs/en/user-guide/api/index.md +++ b/docs/docs/en/user-guide/api/index.md @@ -6,15 +6,15 @@ Currently, FastAgency supports importing API functionality from [**OpenAPI**](ht ## API Features in FastAgency -### 1. **[OpenAPI Import](./openapi/)** +### 1. **[OpenAPI Import](./openapi/index.md)** FastAgency can automatically generate API functions from OpenAPI specifications, streamlining the process of connecting agents to external services. With just a few lines of code, you can import an API specification, and FastAgency will handle the function generation and LLM integration, making it simple for agents to call external APIs. -[Learn more about OpenAPI Import →](./openapi/) +[Learn more about OpenAPI Import →](./openapi/index.md) -### 2. **[API Security](./security/)** +### 2. **[API Security](./security.md)** FastAgency supports different types of security for REST APIs, including OAuth, API keys, and more. This ensures that your API integrations are secure and can handle sensitive data. Our API security mechanisms are flexible, allowing you to configure and manage secure communication between your agents and external APIs. -[Learn more about API Security →](./security/) +[Learn more about API Security →](./security.md) --- diff --git a/docs/docs/en/user-guide/basics.md b/docs/docs/en/user-guide/basics.md deleted file mode 100644 index c0f6a5e3a..000000000 --- a/docs/docs/en/user-guide/basics.md +++ /dev/null @@ -1,229 +0,0 @@ ---- -search: - boost: 10 ---- - - -# Getting Started with FastAgency - - -The fastest way to bring multi-agent workflows to production. - - ---- - -

- - Test Passing - - - - Coverage - - - - Downloads - - - - Package version - - - - Supported Python versions - - -
- - - CodeQL - - - - Dependency Review - - - - License - - - - Code of Conduct - - - - Discord - -

- ---- - -Welcome to FastAgency! This guide will walk you through the initial setup and usage of FastAgency, a powerful tool that leverages the AutoGen framework to quickly build applications. FastAgency is designed to be flexible and adaptable, and we plan to extend support to additional agentic frameworks such as [CrewAI](https://www.crewai.com/){target="_blank"} in the near future. This will provide even more options for defining workflows and integrating with various AI tools. - -With FastAgency, you can create interactive applications using various interfaces such as a console or Mesop. - -## Supported Interfaces - -FastAgency currently supports workflows defined using AutoGen and provides options for different types of applications: - -- **Console**: Use the [ConsoleUI](../api/fastagency/ui/console/ConsoleUI.md) interface for command-line based interaction. This is ideal for developing and testing workflows in a text-based environment. -- **Mesop**: Utilize [Mesop](https://google.github.io/mesop/){target="_blank"} with [MesopUI](../api/fastagency/ui/mesop/MesopUI.md) for web-based applications. This interface is suitable for creating web applications with a user-friendly interface. - -We are also working on adding support for other frameworks, such as [CrewAI](https://www.crewai.com/){target="_blank"}, to broaden the scope and capabilities of FastAgency. Stay tuned for updates on these integrations. - -## Quick start - -### Install - -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" - ```console - pip install "fastagency[autogen]" - ``` - - This command installs FastAgency with support for the Console interface and AutoGen framework. - -=== "Mesop" - ```console - pip install "fastagency[autogen,mesop]" - ``` - - This command installs FastAgency with support for both the Console and Mesop interfaces, providing a more comprehensive setup. - -!!! note "Using older AutoGen version 0.2.x" - - In case you want to use an older version of AutoGen (`pyautogen` instead of `autogen` package ), please use the following pip command: - - === "Console" - ```console - pip install "fastagency[pyautogen]" - ``` - - This command installs FastAgency with support for the Console interface and AutoGen framework. - - === "Mesop" - ```console - pip install "fastagency[pyautogen,mesop]" - ``` - - -### Imports -Depending on the interface you choose, you'll need to import different modules. These imports set up the necessary components for your application: - -=== "Console" - ```python - {!> docs_src/getting_started/main_console.py [ln:1-7] !} - ``` - - For Console applications, import `ConsoleUI` to handle command-line input and output. - -=== "Mesop" - ```python - import os - - from autogen.agentchat import ConversableAgent - - from fastagency import UI - from fastagency.runtimes.autogen import AutoGenWorkflows - from fastagency.ui.mesop import MesopUI - - from fastagency import FastAgency - ``` - - For Mesop applications, import `MesopUI` to integrate with the Mesop web interface. - -### Define Workflow - -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-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. - -### Define FastAgency Application - -Next, define your FastAgency application. This ties together your workflow and the interface you chose: - -=== "Console" - ```python - {!> docs_src/getting_started/main_console.py [ln:7,46,47] !} - ``` - - For Console applications, use `ConsoleUI` to handle user interaction via the command line. - -=== "Mesop" - ```python - from fastagency.ui.mesop import MesopUI - - app = FastAgency(wf=wf, io=MesopUI()) - ``` - - For Mesop applications, use `MesopUI` to enable web-based interactions. - -### Run Application - -Once everything is set up, you can run your FastAgency application using the following command: - -```console -fastagency run -``` - -### Output - -The output will vary based on the interface: - -=== "Console" - ```console - ╭─ Python module file ─╮ - │ │ - │ 🐍 main.py │ - │ │ - ╰──────────────────────╯ - - - ╭─ Importable FastAgency app ─╮ - │ │ - │ from main import app │ - │ │ - ╰─────────────────────────────╯ - - ╭─ FastAgency -> user [text_input] ────────────────────────────────────────────╮ - │ │ - │ Starting a new workflow 'simple_learning' with the following │ - │ description: │ - │ │ - │ Student and teacher learning chat │ - │ │ - │ Please enter an │ - │ initial message: │ - ╰──────────────────────────────────────────────────────────────────────────────╯ - ``` - - For Console applications, you will see a command-line prompt where you can enter the initial message and interact with your workflow. - -=== "Mesop" - ```console - ╭─ Python module file ─╮ - │ │ - │ 🐍 main_mesop.py │ - │ │ - ╰──────────────────────╯ - - - ╭─ Importable FastAgency app ──╮ - │ │ - │ from main_mesop import app │ - │ │ - ╰──────────────────────────────╯ - - Running with hot reload: - - Running server on: http://localhost:32123 - * Serving Flask app 'mesop.server.server' - * Debug mode: off - ``` - - For Mesop applications, the output will include a URL where you can access your web-based application. diff --git a/docs/docs/en/user-guide/cli/index.md b/docs/docs/en/user-guide/cli/index.md index 3bdf8a166..aa7bcfedf 100644 --- a/docs/docs/en/user-guide/cli/index.md +++ b/docs/docs/en/user-guide/cli/index.md @@ -26,4 +26,4 @@ fastagency run path/to/app.py --initial_message "Hello, let's start!" --- -For more information, visit the [**CLI documentation**](../../cli/cli/). +For more information, visit the [**CLI documentation**](../../cli/cli.md). diff --git a/docs/docs/en/user-guide/index.md b/docs/docs/en/user-guide/index.md index 07dc73a87..31a783808 100644 --- a/docs/docs/en/user-guide/index.md +++ b/docs/docs/en/user-guide/index.md @@ -6,15 +6,15 @@ Whether you're orchestrating complex AI agents or integrating external APIs into ## Key Features -- [**Multi-Runtime Support**](runtimes/): FastAgency supports multiple agentic [runtimes](runtimes/) to provide maximum flexibility. Currently, it supports **AutoGen** and plans to extend support to [CrewAI](https://www.crewai.com/){target="_blank"}. This ensures that as the AI ecosystem evolves, FastAgency remains a reliable and adaptable framework, capable of leveraging emerging agentic technologies. Developers can easily switch between frameworks, choosing the best one for their project's specific needs. +- [**Multi-Runtime Support**](runtimes/index.md): FastAgency supports multiple agentic [runtimes](runtimes/index.md) to provide maximum flexibility. Currently, it supports **AutoGen** and plans to extend support to [CrewAI](https://www.crewai.com/){target="_blank"}. This ensures that as the AI ecosystem evolves, FastAgency remains a reliable and adaptable framework, capable of leveraging emerging agentic technologies. Developers can easily switch between frameworks, choosing the best one for their project's specific needs. -- [**Unified Programming Interface Across UIs**](ui/): FastAgency features a **common programming interface** that enables you to develop your core workflows once and reuse them across various user interfaces without rewriting code. This includes support for both **console-based applications** via `ConsoleUI` and **web-based applications** via `MesopUI`. Whether you need a command-line tool or a fully interactive web app, FastAgency allows you to deploy the same underlying workflows across environments, saving development time and ensuring consistency. +- [**Unified Programming Interface Across UIs**](ui/index.md): FastAgency features a **common programming interface** that enables you to develop your core workflows once and reuse them across various user interfaces without rewriting code. This includes support for both **console-based applications** via `ConsoleUI` and **web-based applications** via `MesopUI`. Whether you need a command-line tool or a fully interactive web app, FastAgency allows you to deploy the same underlying workflows across environments, saving development time and ensuring consistency. -- [**Seamless External API Integration**](api/): One of FastAgency's standout features is its ability to easily integrate external APIs into your agent workflows. With just a **single line of code**, you can import an OpenAPI specification, and in only one more line, you can connect it to your agents. This dramatically simplifies the process of enhancing AI agents with real-time data, external processing, or third-party services. For example, you can easily integrate a weather API to provide dynamic, real-time weather updates to your users, making your application more interactive and useful with minimal effort. +- [**Seamless External API Integration**](api/index.md): One of FastAgency's standout features is its ability to easily integrate external APIs into your agent workflows. With just a **single line of code**, you can import an OpenAPI specification, and in only one more line, you can connect it to your agents. This dramatically simplifies the process of enhancing AI agents with real-time data, external processing, or third-party services. For example, you can easily integrate a weather API to provide dynamic, real-time weather updates to your users, making your application more interactive and useful with minimal effort. -- [**Tester Class for Continuous Integration**](testing/): FastAgency also provides a **Tester Class** that enables developers to write and execute tests for their multi-agent workflows. This feature is crucial for maintaining the reliability and robustness of your application, allowing you to automatically verify agent behavior and interactions. The Tester Class is designed to integrate smoothly with **continuous integration (CI)** pipelines, helping you catch bugs early and ensure that your workflows remain functional as they scale into production. +- [**Tester Class for Continuous Integration**](testing/index.md): FastAgency also provides a **Tester Class** that enables developers to write and execute tests for their multi-agent workflows. This feature is crucial for maintaining the reliability and robustness of your application, allowing you to automatically verify agent behavior and interactions. The Tester Class is designed to integrate smoothly with **continuous integration (CI)** pipelines, helping you catch bugs early and ensure that your workflows remain functional as they scale into production. -- [**Command-Line Interface (CLI) for Orchestration**](cli/): FastAgency includes a powerful **command-line interface (CLI)** for orchestrating and managing multi-agent applications directly from the terminal. The CLI allows developers to quickly run workflows, pass parameters, and monitor agent interactions without needing a full GUI. This is especially useful for automating deployments and integrating workflows into broader DevOps pipelines, enabling developers to maintain control and flexibility in how they manage AI-driven applications. +- [**Command-Line Interface (CLI) for Orchestration**](cli/index.md): FastAgency includes a powerful **command-line interface (CLI)** for orchestrating and managing multi-agent applications directly from the terminal. The CLI allows developers to quickly run workflows, pass parameters, and monitor agent interactions without needing a full GUI. This is especially useful for automating deployments and integrating workflows into broader DevOps pipelines, enabling developers to maintain control and flexibility in how they manage AI-driven applications. ## Why FastAgency? diff --git a/docs/docs/en/user-guide/runtimes/autogen/index.md b/docs/docs/en/user-guide/runtimes/autogen/index.md index 57e74d6f0..89e044372 100644 --- a/docs/docs/en/user-guide/runtimes/autogen/index.md +++ b/docs/docs/en/user-guide/runtimes/autogen/index.md @@ -82,7 +82,7 @@ In this step, we define two agents and specify the initial message that will be - [**`ConversableAgent`**](https://microsoft.github.io/autogen/0.2/docs/reference/agentchat/conversable_agent/#conversableagent){target="_blank"}: This agent acts as the weather agent, responsible for fetching weather data from the API. -The workflow is registered using **[AutoGenWorkflows](../../../api/fastagency/runtimes/autogen/AutoGenWorkflows/)**. +The workflow is registered using **[AutoGenWorkflows](../../../api/fastagency/runtimes/autogen/AutoGenWorkflows.md)**. ```python {! docs_src/user_guide/runtimes/autogen/mesop/main.py [ln:32-57] !} diff --git a/docs/docs/en/user-guide/runtimes/autogen/interactions.md b/docs/docs/en/user-guide/runtimes/autogen/interactions.md index fc7de9ee6..edcf39b0a 100644 --- a/docs/docs/en/user-guide/runtimes/autogen/interactions.md +++ b/docs/docs/en/user-guide/runtimes/autogen/interactions.md @@ -1,6 +1,6 @@ # Custom User Interactions -In this example, we'll demonstrate how to create custom interaction with the user using [`UI`](../../../../api/fastagency/UI/) protocol and its [`process_message`](../../../../api/fastagency/UI/#fastagency.UI.process_message) method. +In this example, we'll demonstrate how to create custom interaction with the user using [`UI`](../../../../api/fastagency/UI.md) protocol and its [`process_message`](../../../../api/fastagency/UI.md#fastagency.UI.process_message) method. ## Install @@ -44,7 +44,7 @@ Let's define three functions which will be available to the agents: ### Other Types of Messages -All supported messages are subclasses of the [IOMessage](../../../../api/fastagency/IOMessage/) base class. +All supported messages are subclasses of the [IOMessage](../../../../api/fastagency/IOMessage.md) base class. ## Registering the Functions We now register these functions with the workflow, linking the `student_agent` as the caller and the `teacher_agent` as the executor. diff --git a/docs/docs/en/user-guide/runtimes/autogen/websurfer.md b/docs/docs/en/user-guide/runtimes/autogen/websurfer.md index bc3a90eb9..22dea1c44 100644 --- a/docs/docs/en/user-guide/runtimes/autogen/websurfer.md +++ b/docs/docs/en/user-guide/runtimes/autogen/websurfer.md @@ -13,7 +13,7 @@ In this guide, we'll demonstrate both methods with a real-world example. We’ll We’ll build agents and assign them the task: “Search for information about Microsoft AutoGen and summarize the results” to showcase its ability to browse and gather real-time data in action. -## Installation +## Installation & Setup Before getting started, make sure you have installed FastAgency with support for the AutoGen runtime by running the following command: @@ -23,6 +23,25 @@ pip install "fastagency[autogen]" This command installs FastAgency with support for the Console interface and AutoGen framework. +### Create Bing Web Search API Key +To create [Bing Web Search](https://www.microsoft.com/en-us/bing/apis/pricing){target="_blank"} API key, follow the guide provided. + +!!! note + You will need to create **Microsoft Azure** Account. + +#### Set Up Your API Key in the Environment + +You can set the Binga API key in your terminal as an environment variable: + +=== "Linux/macOS" + ```bash + export BING_API_KEY="your_bing_api_key" + ``` +=== "Windows" + ```bash + set BING_API_KEY="your_bing_api_key" + ``` + ## Example: Search for information about Microsoft AutoGen and summarize the results ### Step-by-Step Breakdown @@ -80,8 +99,8 @@ 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 hl_lines="27-31" - {!> docs_src/user_guide/runtimes/autogen/websurfer_tool.py [ln:21-52] !} + ```python hl_lines="27-32" + {!> docs_src/user_guide/runtimes/autogen/websurfer_tool.py [ln:21-53] !} ``` 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. @@ -113,7 +132,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:56] !} +{! docs_src/user_guide/runtimes/autogen/websurfer.py [ln:57] !} ``` ### Complete Application Code diff --git a/docs/docs/en/user-guide/runtimes/index.md b/docs/docs/en/user-guide/runtimes/index.md index 4254d16b4..20d522b8c 100644 --- a/docs/docs/en/user-guide/runtimes/index.md +++ b/docs/docs/en/user-guide/runtimes/index.md @@ -2,19 +2,19 @@ **FastAgency** is a flexible, open-source framework designed to accelerate the transition from prototype to production for multi-agent AI workflows. If you're a developer working with agentic frameworks like **AutoGen**, FastAgency provides the tools to rapidly scale your projects into fully operational applications. A key feature of FastAgency is its support for multiple runtimes, allowing developers to switch between or combine various frameworks based on project needs. With multi-framework compatibility, FastAgency ensures that your workflows are not only optimized for today’s needs but also future-proofed as new frameworks emerge. -## [AutoGen](autogen/) +## [AutoGen](autogen/index.md) The **AutoGen** runtime is central to FastAgency’s architecture and provides a powerful foundation for multi-agent workflows. AutoGen allows developers to define workflows in Python, leveraging large language models (LLMs) such as GPT to handle communication and collaboration between agents. It enables rapid prototyping and deployment of workflows that involve tasks like decision-making, customer service, or research. FastAgency seamlessly integrates with AutoGen, helping you transition from development in Jupyter notebooks to fully deployed applications. Whether you're managing conversational agents or orchestrating task automation, the AutoGen runtime in FastAgency helps you streamline the path from prototype to production. -For more information on using AutoGen within FastAgency, visit the [AutoGen section](autogen/). +For more information on using AutoGen within FastAgency, visit the [AutoGen section](autogen/index.md). -## [CrewAI (coming soon)](crewai/basics/) +## [CrewAI (coming soon)](crewai/basics.md) The **CrewAI** runtime is an upcoming integration designed to further expand FastAgency’s capabilities. CrewAI offers a highly modular approach, providing greater flexibility for building more complex and dynamic workflows where agents need to collaborate autonomously. Its role-based design, combined with autonomous task delegation, makes CrewAI particularly suitable for projects involving a large number of specialized agents working in tandem. As the AI ecosystem continues to evolve, FastAgency’s support for CrewAI ensures that your workflows remain adaptable and ready for future innovations. This planned integration allows you to harness the advanced features of CrewAI, offering more options for scaling your multi-agent applications. -For future updates and documentation on CrewAI, please visit the [CrewAI section](crewai/basics/). +For future updates and documentation on CrewAI, please visit the [CrewAI section](crewai/basics.md). --- diff --git a/docs/docs/en/user-guide/ui/console/basics.md b/docs/docs/en/user-guide/ui/console/basics.md index f29659f36..87dd96882 100644 --- a/docs/docs/en/user-guide/ui/console/basics.md +++ b/docs/docs/en/user-guide/ui/console/basics.md @@ -1,8 +1,8 @@ # Console -**[ConsoleUI](../../../../api/fastagency/ui/console/ConsoleUI/)** in FastAgency provides a text-based interface for interacting with multi-agent workflows directly from the command line. This interface allows developers to quickly test and prototype workflows without needing to set up a graphical or web-based interface, making it an excellent tool for early-stage development and debugging. +**[ConsoleUI](../../../../api/fastagency/ui/console/ConsoleUI.md)** in FastAgency provides a text-based interface for interacting with multi-agent workflows directly from the command line. This interface allows developers to quickly test and prototype workflows without needing to set up a graphical or web-based interface, making it an excellent tool for early-stage development and debugging. -Below is an example that demonstrates how to set up a simple learning conversation between a student and a teacher using **[ConsoleUI](../../../../api/fastagency/ui/console/ConsoleUI/)**. +Below is an example that demonstrates how to set up a simple learning conversation between a student and a teacher using **[ConsoleUI](../../../../api/fastagency/ui/console/ConsoleUI.md)**. ## Installation @@ -16,7 +16,7 @@ This installation includes the AutoGen runtime, allowing you to build multi-agen ## Example: Student and Teacher Learning Chat -This example demonstrates how to create a workflow where a student agent interacts with a teacher agent. The student asks questions, and the teacher provides responses, simulating a learning environment. The interaction is facilitated through the console using **[ConsoleUI](../../../../api/fastagency/ui/console/ConsoleUI/)**. +This example demonstrates how to create a workflow where a student agent interacts with a teacher agent. The student asks questions, and the teacher provides responses, simulating a learning environment. The interaction is facilitated through the console using **[ConsoleUI](../../../../api/fastagency/ui/console/ConsoleUI.md)**. ### Step-by-Step Breakdown @@ -28,9 +28,9 @@ We begin by importing the necessary modules from **FastAgency** and **AutoGen**. ``` - **ConversableAgent**: This class allows the creation of agents that can engage in conversational tasks. -- **[FastAgency](../../../../api/fastagency/FastAgency/)**: The core class responsible for orchestrating workflows and connecting them with UIs. -- **[UI](../../../../api/fastagency/UI/)** and **[ConsoleUI](../../../../api/fastagency/ui/console/ConsoleUI/)**: These classes define the user interface for interaction, with ConsoleUI providing a text-based interface. -- **[AutoGenWorkflows](../../../../api/fastagency/runtimes/autogen/AutoGenWorkflows/)**: Manages the creation and execution of multi-agent workflows. +- **[FastAgency](../../../../api/fastagency/FastAgency.md)**: The core class responsible for orchestrating workflows and connecting them with UIs. +- **[UI](../../../../api/fastagency/UI.md)** and **[ConsoleUI](../../../../api/fastagency/ui/console/ConsoleUI.md)**: These classes define the user interface for interaction, with ConsoleUI providing a text-based interface. +- **[AutoGenWorkflows](../../../../api/fastagency/runtimes/autogen/AutoGenWorkflows.md)**: Manages the creation and execution of multi-agent workflows. #### 2. **Configure the Language Model (LLM)** Next, we configure the language model that will power the agents. In this case, we're using **gpt-4o-mini**, and the API key is retrieved from the environment. @@ -52,7 +52,7 @@ Here, we define a simple workflow where the **Student Agent** interacts with the - **Workflow Registration**: The workflow is registered under the name `simple_learning`. The **ConversableAgent** class is used to represent both the student and teacher agents, allowing them to communicate with each other up to 5 turns before summarizing the conversation using the `reflection_with_llm` method. #### 4. **Using ConsoleUI** -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. +Finally, we instantiate **[ConsoleUI](../../../../api/fastagency/ui/console/ConsoleUI.md)** 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:54] !} @@ -157,4 +157,4 @@ If you encounter issues running the application, ensure that: --- -By using **[ConsoleUI](../../../../api/fastagency/ui/console/ConsoleUI/)**, developers can rapidly test and deploy multi-agent workflows in a simple, text-based environment. The flexibility of this interface makes it ideal for prototyping agent interactions before scaling them into more complex applications. You can extend this workflow or modify the agents for various use cases, such as tutoring, customer support, or information retrieval. +By using **[ConsoleUI](../../../../api/fastagency/ui/console/ConsoleUI.md)**, developers can rapidly test and deploy multi-agent workflows in a simple, text-based environment. The flexibility of this interface makes it ideal for prototyping agent interactions before scaling them into more complex applications. You can extend this workflow or modify the agents for various use cases, such as tutoring, customer support, or information retrieval. diff --git a/docs/docs/en/user-guide/ui/index.md b/docs/docs/en/user-guide/ui/index.md index 183513fb6..9497d899b 100644 --- a/docs/docs/en/user-guide/ui/index.md +++ b/docs/docs/en/user-guide/ui/index.md @@ -6,20 +6,20 @@ Below is an overview of the supported UIs, with links to their respective pages ## Available User Interfaces -### 1. **[ConsoleUI](./console/basics/)** +### 1. **[ConsoleUI](./console/basics.md)** The **ConsoleUI** provides a command-line interface for interacting with FastAgency's agent workflows. It’s an ideal choice for developers who need to quickly test and prototype workflows directly in the terminal. -[Learn more about ConsoleUI →](./console/basics/) +[Learn more about ConsoleUI →](./console/basics.md) -### 2. **[MesopUI](./mesop/basics/)** +### 2. **[MesopUI](./mesop/basics.md)** The **MesopUI** is a web-based interface that enables users to interact with agents through a browser. This UI is designed for applications that need a more graphical and interactive experience for users. -[Learn more about MesopUI →](./mesop/basics/) +[Learn more about MesopUI →](./mesop/basics.md) -### 3. **[FastAPI UI (Coming Soon)](./fastapi/basics/)** +### 3. **[FastAPI UI (Coming Soon)](./fastapi/basics.md)** FastAgency will soon introduce **FastAPI UI** support, which will allow you to build multi-agent systems with a FastAPI backend. This will enable seamless integration with RESTful APIs for modern web applications. -[Learn more about FastAPI UI (Coming Soon) →](./fastapi/basics/) +[Learn more about FastAPI UI (Coming Soon) →](./fastapi/basics.md) --- diff --git a/docs/docs/en/user-guide/ui/mesop/basics.md b/docs/docs/en/user-guide/ui/mesop/basics.md index 47dbdf42d..eb6281b73 100644 --- a/docs/docs/en/user-guide/ui/mesop/basics.md +++ b/docs/docs/en/user-guide/ui/mesop/basics.md @@ -1,8 +1,8 @@ # Mesop -**[MesopUI](../../../../api/fastagency/ui/mesop/MesopUI/)** in FastAgency offers a web-based interface for interacting with multi-agent workflows. Unlike the **ConsoleUI**, which is text-based and runs in the command line, MesopUI provides a user-friendly browser interface, making it ideal for applications that need a more engaging, graphical interaction. MesopUI is perfect for building interactive web applications and enabling users to interact with agents in a more intuitive way. +**[MesopUI](../../../../api/fastagency/ui/mesop/MesopUI.md)** in FastAgency offers a web-based interface for interacting with multi-agent workflows. Unlike the **ConsoleUI**, which is text-based and runs in the command line, MesopUI provides a user-friendly browser interface, making it ideal for applications that need a more engaging, graphical interaction. MesopUI is perfect for building interactive web applications and enabling users to interact with agents in a more intuitive way. -Below, we’ll demonstrate how to set up a basic student-teacher conversation using **[MesopUI](../../../../api/fastagency/ui/mesop/MesopUI/)**. +Below, we’ll demonstrate how to set up a basic student-teacher conversation using **[MesopUI](../../../../api/fastagency/ui/mesop/MesopUI.md)**. ## Installation @@ -52,7 +52,7 @@ Please see the [Mesop documentation](https://google.github.io/mesop/api/page/#me ### Modifying styles -All [Styles](https://google.github.io/mesop/api/style/){target="_blank"} used in styling of Mesop components can be passed to the [`MesopUI`](../../../../api/fastagency/ui/mesop/MesopUI/)constructor and change the default behavior. They are specified in top-level styling class [`MesopHomePageStyles`](../../../../api/fastagency/ui/mesop/styles/MesopHomePageStyles/). +All [Styles](https://google.github.io/mesop/api/style/){target="_blank"} used in styling of Mesop components can be passed to the [`MesopUI`](../../../../api/fastagency/ui/mesop/MesopUI.md)constructor and change the default behavior. They are specified in top-level styling class [`MesopHomePageStyles`](../../../../api/fastagency/ui/mesop/styles/MesopHomePageStyles.md). ```python {! docs_src/user_guide/ui/mesop/main_mesop.py [ln:4] !} @@ -66,7 +66,7 @@ ui = MesopUI(styles=styles) ## Example: Student and Teacher Learning Chat -This example shows how to create a simple learning chat where a student agent interacts with a teacher agent. The student asks questions, and the teacher provides responses, simulating a learning environment. The conversation is facilitated through the web interface using **[MesopUI](../../../../api/fastagency/ui/mesop/MesopUI/)**. +This example shows how to create a simple learning chat where a student agent interacts with a teacher agent. The student asks questions, and the teacher provides responses, simulating a learning environment. The conversation is facilitated through the web interface using **[MesopUI](../../../../api/fastagency/ui/mesop/MesopUI.md)**. ### Step-by-Step Breakdown @@ -78,9 +78,9 @@ We begin by importing the necessary modules from **FastAgency** and **AutoGen**. ``` - **ConversableAgent**: This class allows the creation of agents that can engage in conversational tasks. -- **[FastAgency](../../../../api/fastagency/FastAgency/)**: The core class responsible for orchestrating workflows and connecting them with UIs. -- **[UI](../../../../api/fastagency/UI/)** and **[MesopUI](../../../../api/fastagency/ui/mesop/MesopUI/)**: These classes define the user interface for interaction, with **MesopUI** enabling a web-based interaction. -- **[AutoGenWorkflows](../../../../api/fastagency/runtimes/autogen/AutoGenWorkflows/)**: Manages the creation and execution of multi-agent workflows. +- **[FastAgency](../../../../api/fastagency/FastAgency.md)**: The core class responsible for orchestrating workflows and connecting them with UIs. +- **[UI](../../../../api/fastagency/UI.md)** and **[MesopUI](../../../../api/fastagency/ui/mesop/MesopUI.md)**: These classes define the user interface for interaction, with **MesopUI** enabling a web-based interaction. +- **[AutoGenWorkflows](../../../../api/fastagency/runtimes/autogen/AutoGenWorkflows.md)**: Manages the creation and execution of multi-agent workflows. #### 2. **Configure the Language Model (LLM)** Next, we configure the language model that powers the agents. In this case, we're using **GPT-4o**, and the API key is retrieved from the environment. @@ -102,7 +102,7 @@ Here, we define a simple workflow where the **Student Agent** interacts with the - **Workflow Registration**: The workflow is registered under the name `simple_learning`. The **ConversableAgent** class is used to represent both the student and teacher agents, allowing them to communicate with each other up to 5 turns before summarizing the conversation using the `reflection_with_llm` method. #### 4. **Using MesopUI** -Finally, we instantiate **[MesopUI](../../../../api/fastagency/ui/mesop/MesopUI/)** to link the workflow to a web-based interface. This allows the user to interact with the agents through a web browser. +Finally, we instantiate **[MesopUI](../../../../api/fastagency/ui/mesop/MesopUI.md)** to link the workflow to a web-based interface. This allows the user to interact with the agents through a web browser. ```python {! docs_src/user_guide/ui/mesop/main_mesop.py [ln:59-90] !} @@ -125,9 +125,9 @@ Finally, we instantiate **[MesopUI](../../../../api/fastagency/ui/mesop/MesopUI/ There are two options of running a Mesop application: -1. Using [`fastagency`](../../../../cli/cli/) command line: +1. Using [`fastagency`](../../../../cli/cli.md) command line: - !!! note "Terminal (using [fastagency](../../../../cli/cli/))" + !!! note "Terminal (using [fastagency](../../../../cli/cli.md))" ``` fastagency run ``` @@ -178,4 +178,4 @@ If you encounter issues running the application, ensure that: --- -By using **[MesopUI](../../../../api/fastagency/ui/mesop/MesopUI/)**, developers can create interactive, web-based multi-agent applications with ease. This interface is ideal for building user-friendly, browser-accessible systems, enabling users to interact with agents in a more engaging and visual environment. You can extend this workflow for more complex scenarios, such as tutoring systems, customer support, or real-time information retrieval. +By using **[MesopUI](../../../../api/fastagency/ui/mesop/MesopUI.md)**, developers can create interactive, web-based multi-agent applications with ease. This interface is ideal for building user-friendly, browser-accessible systems, enabling users to interact with agents in a more engaging and visual environment. You can extend this workflow for more complex scenarios, such as tutoring systems, customer support, or real-time information retrieval. diff --git a/docs/docs_src/tutorial/giphy/main.py b/docs/docs_src/tutorial/giphy/main.py index ec2d9cffb..0ecb7e4ea 100644 --- a/docs/docs_src/tutorial/giphy/main.py +++ b/docs/docs_src/tutorial/giphy/main.py @@ -88,6 +88,7 @@ def present_completed_task_or_ask_question( human_input_mode="NEVER", executor=giphy_agent, is_termination_msg=is_termination_msg, + bing_api_key=os.getenv("BING_API_KEY") ) register_function( diff --git a/docs/docs_src/tutorial/whatsapp/main.py b/docs/docs_src/tutorial/whatsapp/main.py index d8e5e55a6..b09a6c0b2 100644 --- a/docs/docs_src/tutorial/whatsapp/main.py +++ b/docs/docs_src/tutorial/whatsapp/main.py @@ -90,6 +90,7 @@ def present_completed_task_or_ask_question( human_input_mode="NEVER", executor=whatsapp_agent, is_termination_msg=is_termination_msg, + bing_api_key=os.getenv("BING_API_KEY") ) register_function( diff --git a/docs/docs_src/user_guide/runtimes/autogen/websurfer.py b/docs/docs_src/user_guide/runtimes/autogen/websurfer.py index 98bff04ae..f498fa406 100644 --- a/docs/docs_src/user_guide/runtimes/autogen/websurfer.py +++ b/docs/docs_src/user_guide/runtimes/autogen/websurfer.py @@ -41,6 +41,7 @@ def websurfer_workflow( summarizer_llm_config=llm_config, human_input_mode="NEVER", executor=user_agent, + bing_api_key=os.getenv("BING_API_KEY"), ) chat_result = user_agent.initiate_chat( diff --git a/docs/docs_src/user_guide/runtimes/autogen/websurfer_tool.py b/docs/docs_src/user_guide/runtimes/autogen/websurfer_tool.py index 734c87118..0d325eb76 100644 --- a/docs/docs_src/user_guide/runtimes/autogen/websurfer_tool.py +++ b/docs/docs_src/user_guide/runtimes/autogen/websurfer_tool.py @@ -49,6 +49,7 @@ def websurfer_workflow( name_prefix="Web_Surfer", llm_config=llm_config, summarizer_llm_config=llm_config, + bing_api_key=os.getenv("BING_API_KEY"), ) web_surfer.register( diff --git a/fastagency/adapters/fastapi/base.py b/fastagency/adapters/fastapi/base.py index e69074662..ed1e2c588 100644 --- a/fastagency/adapters/fastapi/base.py +++ b/fastagency/adapters/fastapi/base.py @@ -73,9 +73,6 @@ def __init__( Args: provider (ProviderProtocol): The provider. - user (Optional[str], optional): The user. Defaults to None. - password (Optional[str], optional): The password. Defaults to None. - super_conversation (Optional["FastAPIProvider"], optional): The super conversation. Defaults to None. initiate_workflow_path (str, optional): The initiate workflow path. Defaults to "/fastagency/initiate_workflow". discovery_path (str, optional): The discovery path. Defaults to "/fastagency/discovery". ws_path (str, optional): The websocket path. Defaults to "/fastagency/ws". diff --git a/fastagency/runtimes/autogen/agents/websurfer.py b/fastagency/runtimes/autogen/agents/websurfer.py index 4e3bbac8a..fe0d3d97a 100644 --- a/fastagency/runtimes/autogen/agents/websurfer.py +++ b/fastagency/runtimes/autogen/agents/websurfer.py @@ -1,4 +1,4 @@ -from typing import Any, Union +from typing import Any, Optional, Union from autogen import AssistantAgent, ConversableAgent @@ -14,6 +14,7 @@ def __init__( summarizer_llm_config: dict[str, Any], executor: Union[ConversableAgent, list[ConversableAgent]], system_message: str = "You are a web surfer", + bing_api_key: Optional[str] = None, **kwargs: Any, ): """Initialize the WebSurferAgent. @@ -25,6 +26,7 @@ def __init__( summarizer_llm_config (dict[str, Any]): The summarizer LLM configuration. executor (Union[ConversableAgent, list[ConversableAgent]]): The executor agent(s). system_message (str): The system message. + bing_api_key (Optional[str]): The Bing API key **kwargs (Any): The keyword arguments. """ super().__init__( @@ -38,5 +40,6 @@ def __init__( name_prefix="Web_Surfer", llm_config=llm_config, summarizer_llm_config=summarizer_llm_config, + bing_api_key=bing_api_key, ) self.web_surfer_tool.register(caller=self, executor=executor) diff --git a/fastagency/runtimes/autogen/tools/__init__.py b/fastagency/runtimes/autogen/tools/__init__.py index 20bfe6aa1..85e176794 100644 --- a/fastagency/runtimes/autogen/tools/__init__.py +++ b/fastagency/runtimes/autogen/tools/__init__.py @@ -1,3 +1,3 @@ -from .web_surfer import WebSurferTool +from .websurfer import WebSurferTool __all__ = ["WebSurferTool"] diff --git a/fastagency/runtimes/autogen/tools/web_surfer.py b/fastagency/runtimes/autogen/tools/websurfer.py similarity index 99% rename from fastagency/runtimes/autogen/tools/web_surfer.py rename to fastagency/runtimes/autogen/tools/websurfer.py index 4c0520fba..253ddfb4d 100644 --- a/fastagency/runtimes/autogen/tools/web_surfer.py +++ b/fastagency/runtimes/autogen/tools/websurfer.py @@ -1,4 +1,3 @@ -import os from typing import Annotated, Any, Optional, Union from autogen.agentchat import AssistantAgent as AutoGenAssistantAgent @@ -81,9 +80,7 @@ def __init__( self.llm_config = llm_config self.summarizer_llm_config = summarizer_llm_config self.viewport_size = viewport_size - self.bing_api_key = ( - bing_api_key if bing_api_key is not None else os.getenv("BING_API_KEY") - ) + self.bing_api_key = bing_api_key self.max_consecutive_auto_reply = max_consecutive_auto_reply self.max_links_to_click = max_links_to_click self.websurfer_kwargs = websurfer_kwargs