fastagency


Namefastagency JSON
Version 0.3.4 PyPI version JSON
download
home_pageNone
SummaryThe fastest way to bring multi-agent workflows to production
upload_time2024-11-12 15:33:52
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords ai llm autogen autonomous agents multi-agent
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![alt text](https://github.com/airtai/fastagency/blob/main/docs/docs/assets/img/FA-Secondary-LOGO.jpg?raw=true)


# FastAgency


<b>The fastest way to bring multi-agent workflows to production.</b>


---

<p align="center">
  <a href="https://github.com/airtai/fastagency/actions/workflows/pipeline.yaml" target="_blank">
    <img src="https://github.com/airtai/fastagency/actions/workflows/pipeline.yaml/badge.svg?branch=main" alt="Test Passing"/>
  </a>

  <a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/airtai/fastagency" target="_blank">
      <img src="https://coverage-badge.samuelcolvin.workers.dev/airtai/fastagency.svg" alt="Coverage">
  </a>

  <a href="https://www.pepy.tech/projects/fastagency" target="_blank">
    <img src="https://static.pepy.tech/personalized-badge/fastagency?period=month&units=international_system&left_color=grey&right_color=green&left_text=downloads/month" alt="Downloads"/>
  </a>

  <a href="https://pypi.org/project/fastagency" target="_blank">
    <img src="https://img.shields.io/pypi/v/fastagency?label=PyPI" alt="Package version">
  </a>

  <a href="https://pypi.org/project/fastagency" target="_blank">
    <img src="https://img.shields.io/pypi/pyversions/fastagency.svg" alt="Supported Python versions">
  </a>

  <br/>

  <a href="https://github.com/airtai/fastagency/actions/workflows/codeql.yml" target="_blank">
    <img src="https://github.com/airtai/fastagency/actions/workflows/codeql.yml/badge.svg" alt="CodeQL">
  </a>

  <a href="https://github.com/airtai/fastagency/actions/workflows/dependency-review.yaml" target="_blank">
    <img src="https://github.com/airtai/fastagency/actions/workflows/dependency-review.yaml/badge.svg" alt="Dependency Review">
  </a>

  <a href="https://github.com/airtai/fastagency/blob/main/LICENSE" target="_blank">
    <img src="https://img.shields.io/github/license/airtai/fastagency.png" alt="License">
  </a>

  <a href="https://github.com/airtai/fastagency/blob/main/CODE_OF_CONDUCT.md" target="_blank">
    <img src="https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg" alt="Code of Conduct">
  </a>

  <a href="https://discord.gg/kJjSGWrknU" target="_blank">
      <img alt="Discord" src="https://img.shields.io/discord/1247409549158121512?logo=discord">
  </a>
</p>

---

## What is FastAgency?

For start, FastAgency is not yet another agentic AI framework. There are many such
frameworks available today, the most popular open-source ones being [**AutoGen**](https://github.com/microsoft/autogen), [**CrewAI**](https://www.crewai.com/), [**Swarm**](https://github.com/openai/swarm) and [**LangGraph**](https://github.com/langchain-ai/langgraph). FastAgency provides you with a unified programming interface for deploying agentic workflows written in above agentic frameworks in both development and productional settings (current version supports [**AutoGen**](https://github.com/microsoft/autogen) only, but other frameworks will be supported very soon). With only a few lines of code, you can create a web chat application or REST API service interacting with agents of your choice. If you need to scale-up your workloads, FastAgency can help you deploy a fully distributed system using internal message brokers coordinating multiple machines in multiple datacenters with just a few lines of code changed from your local development setup.

**FastAgency** is an open-source framework designed to accelerate the transition from prototype to production for multi-agent AI workflows. For developers who use the AutoGen framework, FastAgency enables you to seamlessly scale Jupyter notebook prototypes into a fully functional, production-ready applications. With multi-framework support, a unified programming interface, and powerful API integration capabilities, FastAgency streamlines the deployment process, saving time and effort while maintaining flexibility and performance.

Whether you're orchestrating complex AI agents or integrating external APIs into workflows, FastAgency provides the tools necessary to quickly transition from concept to production, reducing development cycles and allowing you to focus on optimizing your multi-agent systems.

## Key Features

- [**Multi-Runtime Support**](user-guide/runtimes/index.md): FastAgency supports multiple agentic [runtimes](user-guide/runtimes/index.md) to provide maximum flexibility. Currently, it supports **AutoGen** and plans to extend support to [CrewAI](https://www.crewai.com/). 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**](user-guide/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**](user-guide/api/index.md): One of FastAgency's standout features is its ability to easily integrate external APIs into your agent workflows. With just a **few lines 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**](user-guide/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**](user-guide/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?

FastAgency bridges the gap between rapid prototyping and production-ready deployment, empowering developers to bring their multi-agent systems to life quickly and efficiently. By integrating familiar frameworks like AutoGen, providing powerful API integration, and offering robust CI testing tools, FastAgency reduces the complexity and overhead typically associated with deploying AI agents in real-world applications.

Whether you’re building interactive console tools, developing fully-featured web apps, or orchestrating large-scale multi-agent systems, FastAgency is built to help you deploy faster, more reliably, and with greater flexibility.

### Supported Runtimes

Currently, the only supported runtime is [**AutoGen**](https://github.com/microsoft/autogen), with support for [**CrewAI**](https://www.crewai.com/), [**Swarm**](https://github.com/openai/swarm) and [**LangGraph**](https://github.com/langchain-ai/langgraph) coming soon.

### Supported User 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**](https://google.github.io/mesop/): Utilize [**`MesopUI`**](../api/fastagency/ui/mesop/MesopUI.md) for web-based applications. This interface is suitable for creating web applications with a user-friendly interface.

### Supported Network Adapters

FastAgency can use chainable network adapters that can be used to easily create
scalable, production ready architectures for serving your workflows. Currently, we
support the following network adapters:

- [**REST API**](https://en.wikipedia.org/wiki/REST) via [**FastAPI**](https://fastapi.tiangolo.com/): Use the [**`FastAPIAdapter`**](../api/fastagency/adapters/fastapi/FastAPIAdapter.md) to serve your workflow using [**FastAPI**](https://fastapi.tiangolo.com/) server. This setup allows you to work your workflows in multiple workers and serve them using the highly extensible and stable ASGI server.

- [**NATS.io**](https://nats.io/) via [**FastStream**](https://github.com/airtai/faststream): Utilize the [**`NatsAdapter`**](../api/fastagency/adapters/nats/NatsAdapter.md) to use [**NATS.io MQ**](https://nats.io/) message broker for highly-scalable, production-ready setup. This interface is suitable for setups in VPN-s or, in combination with the [**`FastAPIAdapter`**](../api/fastagency/adapters/fastapi/FastAPIAdapter.md) to serve public workflows in an authenticated, secure manner.


## Quick Start

### Project setup

We **strongly recommend** using [**Cookiecutter**](../cookiecutter/index.md) for setting up a FastAgency project. It creates the project folder structure, default workflow, automatically installs all the necessary requirements, and creates a [devcontainer](https://code.visualstudio.com/docs/devcontainers/containers) that can be used with [Visual Studio Code](https://code.visualstudio.com/) for development.

1. Install Cookiecutter with the following command:
    ```console
    pip install cookiecutter
    ```

2. Run the `cookiecutter` command:
    ```console
    cookiecutter https://github.com/airtai/cookiecutter-fastagency.git
    ```

3. Assuming that you used the default values, you should get the following output:
    ```console
    [1/4] project_name (My FastAgency App):
    [2/4] project_slug (my_fastagency_app):
    [3/4] Select app_type
        1 - fastapi+mesop
        2 - mesop
        3 - nats+fastapi+mesop
        Choose from [1/2/3] (1): 1
    [4/4] Select python_version
        1 - 3.12
        2 - 3.11
        3 - 3.10
        Choose from [1/2/3] (1):
    [5/5] Select authentication
        1 - none
        2 - google
        Choose from [1/2] (1):
    ```

4. To run LLM-based applications, you need an API key for the LLM used. The most commonly used LLM is [OpenAI](https://platform.openai.com/docs/models). To use it, create an [OpenAI API Key](https://openai.com/index/openai-api/) and set it as an environment variable in the terminal using the following command:

    ```console
    export OPENAI_API_KEY=openai_api_key_here
    ```

5. Open the generated project in [Visual Studio Code](https://code.visualstudio.com/) with the following command:
    ```console
    code my_fastagency_app
    ```

6. Once the project is opened, you will get the following option to reopen it in a devcontainer:

    <img src="https://fastagency.ai/0.3/user-guide/getting-started/images/reopen-in-container.png" width="600" class="center">

7. After reopening the project in devcontainer, you can verify that the setup is correct by running the provided tests with the following command:

    ```console
    pytest -s
    ```

    You should get the following output if everything is correctly setup.
    ```console
    =================================== test session starts ===================================
    platform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0
    rootdir: /workspaces/my_fastagency_app
    configfile: pyproject.toml
    plugins: asyncio-0.24.0, anyio-4.6.2.post1
    asyncio: mode=Mode.STRICT, default_loop_scope=None
    collected 1 item

    tests/test_workflow.py .                                                            [100%]

    ==================================== 1 passed in 1.02s ====================================
    ```
-----

### Workflow Development

#### Define the 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 as it is generated by the cookie cutter under `my_fastagency_app/workflow.py`:

```python
import os
from typing import Any

from autogen.agentchat import ConversableAgent
from fastagency import UI
from fastagency.runtimes.autogen import AutoGenWorkflows

llm_config = {
    "config_list": [
        {
            "model": "gpt-4o-mini",
            "api_key": os.getenv("OPENAI_API_KEY"),
        }
    ],
    "temperature": 0.8,
}

wf = AutoGenWorkflows()


@wf.register(name="simple_learning", description="Student and teacher learning chat")  # type: ignore[misc]
def simple_workflow(ui: UI, params: dict[str, Any]) -> str:
    initial_message = ui.text_input(
        sender="Workflow",
        recipient="User",
        prompt="I can help you learn about mathematics. What subject you would like to explore?",
    )

    student_agent = ConversableAgent(
        name="Student_Agent",
        system_message="You are a student willing to learn.",
        llm_config=llm_config,
    )
    teacher_agent = ConversableAgent(
        name="Teacher_Agent",
        system_message="You are a math teacher.",
        llm_config=llm_config,
    )

    chat_result = student_agent.initiate_chat(
        teacher_agent,
        message=initial_message,
        summary_method="reflection_with_llm",
        max_turns=3,
    )

    return str(chat_result.summary)
```

This code snippet sets up a simple learning chat between a student and a teacher. It defines the agents and how they should interact and specify how the conversation should be summarized.

#### Run and Debug the Workflow

To ensure that the workflow we have defined is working properly, we can test it locally using MesopUI. The code below can be found under `my_fastagency_app/local/main_mesop.py` and imports the defined workflow and sets up MesopUI.

You can run the Mesop application locally with the following command on Linux and MacOS:

```console
gunicorn my_fastagency_app.local.main_mesop:app
```

On Windows, please use the following command:
```console
waitress-serve --listen=0.0.0.0:8000 my_fastagency_app.local.main_mesop:app
```

Open the MesopUI URL [http://localhost:8000](http://localhost:8000) in your browser. You can now use the graphical user interface to start, run, test and debug the autogen workflow manually.

![Initial message](https://fastagency.ai/latest/user-guide/getting-started/images/chat-init.png)


## Deployment

### Building the Docker Image

If you created the project using Cookiecutter, then building the Docker image is as simple as running the provided script, as shown below:

```console
./scripts/build_docker.sh
```

### Running the Docker Image

Similarly, running the Docker container is as simple as running the provided script, as shown below:

```console
./scripts/run_docker.sh
```

### Deploying to Fly.io

If you created the project using Cookiecutter, there is a built-in script to deploy your workflow to [**Fly.io**](https://fly.io/). Run it as shown below:

```console
./scripts/deploy_to_fly_io.sh
```

## Future Plans

We are actively working on expanding FastAgency’s capabilities. In addition to supporting AutoGen, we plan to integrate support for other frameworks, other network provider and other UI frameworks.

---

## ⭐⭐⭐ Stay in touch ⭐⭐⭐

Stay up to date with new features and integrations by following our documentation and community updates on our [**Discord server**](https://discord.gg/kJjSGWrknU). FastAgency is continually evolving to support new frameworks, APIs, and deployment strategies, ensuring you remain at the forefront of AI-driven development.

Last but not least, show us your support by giving a star to our [**GitHub repository**](https://github.com/airtai/fastagency/).


Your support helps us to stay in touch with you and encourages us to
continue developing and improving the framework. Thank you for your
support!

---

## Contributors

Thanks to all of these amazing people who made the project better!

<a href="https://github.com/airtai/fastagency/graphs/contributors" target="_blank">
  <img src="https://contrib.rocks/image?repo=airtai/fastagency"/>
</a>

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "fastagency",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "AI, LLM, autogen, autonomous agents, multi-agent",
    "author": null,
    "author_email": "airt <info@airt.ai>",
    "download_url": "https://files.pythonhosted.org/packages/8e/5b/4b6fa3ed3cd6ea8786feb43efce0bf83494469a4f1d66e334f7213facb44/fastagency-0.3.4.tar.gz",
    "platform": null,
    "description": "![alt text](https://github.com/airtai/fastagency/blob/main/docs/docs/assets/img/FA-Secondary-LOGO.jpg?raw=true)\n\n\n# FastAgency\n\n\n<b>The fastest way to bring multi-agent workflows to production.</b>\n\n\n---\n\n<p align=\"center\">\n  <a href=\"https://github.com/airtai/fastagency/actions/workflows/pipeline.yaml\" target=\"_blank\">\n    <img src=\"https://github.com/airtai/fastagency/actions/workflows/pipeline.yaml/badge.svg?branch=main\" alt=\"Test Passing\"/>\n  </a>\n\n  <a href=\"https://coverage-badge.samuelcolvin.workers.dev/redirect/airtai/fastagency\" target=\"_blank\">\n      <img src=\"https://coverage-badge.samuelcolvin.workers.dev/airtai/fastagency.svg\" alt=\"Coverage\">\n  </a>\n\n  <a href=\"https://www.pepy.tech/projects/fastagency\" target=\"_blank\">\n    <img src=\"https://static.pepy.tech/personalized-badge/fastagency?period=month&units=international_system&left_color=grey&right_color=green&left_text=downloads/month\" alt=\"Downloads\"/>\n  </a>\n\n  <a href=\"https://pypi.org/project/fastagency\" target=\"_blank\">\n    <img src=\"https://img.shields.io/pypi/v/fastagency?label=PyPI\" alt=\"Package version\">\n  </a>\n\n  <a href=\"https://pypi.org/project/fastagency\" target=\"_blank\">\n    <img src=\"https://img.shields.io/pypi/pyversions/fastagency.svg\" alt=\"Supported Python versions\">\n  </a>\n\n  <br/>\n\n  <a href=\"https://github.com/airtai/fastagency/actions/workflows/codeql.yml\" target=\"_blank\">\n    <img src=\"https://github.com/airtai/fastagency/actions/workflows/codeql.yml/badge.svg\" alt=\"CodeQL\">\n  </a>\n\n  <a href=\"https://github.com/airtai/fastagency/actions/workflows/dependency-review.yaml\" target=\"_blank\">\n    <img src=\"https://github.com/airtai/fastagency/actions/workflows/dependency-review.yaml/badge.svg\" alt=\"Dependency Review\">\n  </a>\n\n  <a href=\"https://github.com/airtai/fastagency/blob/main/LICENSE\" target=\"_blank\">\n    <img src=\"https://img.shields.io/github/license/airtai/fastagency.png\" alt=\"License\">\n  </a>\n\n  <a href=\"https://github.com/airtai/fastagency/blob/main/CODE_OF_CONDUCT.md\" target=\"_blank\">\n    <img src=\"https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg\" alt=\"Code of Conduct\">\n  </a>\n\n  <a href=\"https://discord.gg/kJjSGWrknU\" target=\"_blank\">\n      <img alt=\"Discord\" src=\"https://img.shields.io/discord/1247409549158121512?logo=discord\">\n  </a>\n</p>\n\n---\n\n## What is FastAgency?\n\nFor start, FastAgency is not yet another agentic AI framework. There are many such\nframeworks available today, the most popular open-source ones being [**AutoGen**](https://github.com/microsoft/autogen), [**CrewAI**](https://www.crewai.com/), [**Swarm**](https://github.com/openai/swarm) and [**LangGraph**](https://github.com/langchain-ai/langgraph). FastAgency provides you with a unified programming interface for deploying agentic workflows written in above agentic frameworks in both development and productional settings (current version supports [**AutoGen**](https://github.com/microsoft/autogen) only, but other frameworks will be supported very soon). With only a few lines of code, you can create a web chat application or REST API service interacting with agents of your choice. If you need to scale-up your workloads, FastAgency can help you deploy a fully distributed system using internal message brokers coordinating multiple machines in multiple datacenters with just a few lines of code changed from your local development setup.\n\n**FastAgency** is an open-source framework designed to accelerate the transition from prototype to production for multi-agent AI workflows. For developers who use the AutoGen framework, FastAgency enables you to seamlessly scale Jupyter notebook prototypes into a fully functional, production-ready applications. With multi-framework support, a unified programming interface, and powerful API integration capabilities, FastAgency streamlines the deployment process, saving time and effort while maintaining flexibility and performance.\n\nWhether you're orchestrating complex AI agents or integrating external APIs into workflows, FastAgency provides the tools necessary to quickly transition from concept to production, reducing development cycles and allowing you to focus on optimizing your multi-agent systems.\n\n## Key Features\n\n- [**Multi-Runtime Support**](user-guide/runtimes/index.md): FastAgency supports multiple agentic [runtimes](user-guide/runtimes/index.md) to provide maximum flexibility. Currently, it supports **AutoGen** and plans to extend support to [CrewAI](https://www.crewai.com/). 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.\n\n- [**Unified Programming Interface Across UIs**](user-guide/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.\n\n- [**Seamless External API Integration**](user-guide/api/index.md): One of FastAgency's standout features is its ability to easily integrate external APIs into your agent workflows. With just a **few lines 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.\n\n- [**Tester Class for Continuous Integration**](user-guide/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.\n\n- [**Command-Line Interface (CLI) for Orchestration**](user-guide/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.\n\n## Why FastAgency?\n\nFastAgency bridges the gap between rapid prototyping and production-ready deployment, empowering developers to bring their multi-agent systems to life quickly and efficiently. By integrating familiar frameworks like AutoGen, providing powerful API integration, and offering robust CI testing tools, FastAgency reduces the complexity and overhead typically associated with deploying AI agents in real-world applications.\n\nWhether you\u2019re building interactive console tools, developing fully-featured web apps, or orchestrating large-scale multi-agent systems, FastAgency is built to help you deploy faster, more reliably, and with greater flexibility.\n\n### Supported Runtimes\n\nCurrently, the only supported runtime is [**AutoGen**](https://github.com/microsoft/autogen), with support for [**CrewAI**](https://www.crewai.com/), [**Swarm**](https://github.com/openai/swarm) and [**LangGraph**](https://github.com/langchain-ai/langgraph) coming soon.\n\n### Supported User Interfaces\n\nFastAgency currently supports workflows defined using AutoGen and provides options for different types of applications:\n\n- **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.\n\n- [**Mesop**](https://google.github.io/mesop/): Utilize [**`MesopUI`**](../api/fastagency/ui/mesop/MesopUI.md) for web-based applications. This interface is suitable for creating web applications with a user-friendly interface.\n\n### Supported Network Adapters\n\nFastAgency can use chainable network adapters that can be used to easily create\nscalable, production ready architectures for serving your workflows. Currently, we\nsupport the following network adapters:\n\n- [**REST API**](https://en.wikipedia.org/wiki/REST) via [**FastAPI**](https://fastapi.tiangolo.com/): Use the [**`FastAPIAdapter`**](../api/fastagency/adapters/fastapi/FastAPIAdapter.md) to serve your workflow using [**FastAPI**](https://fastapi.tiangolo.com/) server. This setup allows you to work your workflows in multiple workers and serve them using the highly extensible and stable ASGI server.\n\n- [**NATS.io**](https://nats.io/) via [**FastStream**](https://github.com/airtai/faststream): Utilize the [**`NatsAdapter`**](../api/fastagency/adapters/nats/NatsAdapter.md) to use [**NATS.io MQ**](https://nats.io/) message broker for highly-scalable, production-ready setup. This interface is suitable for setups in VPN-s or, in combination with the [**`FastAPIAdapter`**](../api/fastagency/adapters/fastapi/FastAPIAdapter.md) to serve public workflows in an authenticated, secure manner.\n\n\n## Quick Start\n\n### Project setup\n\nWe **strongly recommend** using [**Cookiecutter**](../cookiecutter/index.md) for setting up a FastAgency project. It creates the project folder structure, default workflow, automatically installs all the necessary requirements, and creates a [devcontainer](https://code.visualstudio.com/docs/devcontainers/containers) that can be used with [Visual Studio Code](https://code.visualstudio.com/) for development.\n\n1. Install Cookiecutter with the following command:\n    ```console\n    pip install cookiecutter\n    ```\n\n2. Run the `cookiecutter` command:\n    ```console\n    cookiecutter https://github.com/airtai/cookiecutter-fastagency.git\n    ```\n\n3. Assuming that you used the default values, you should get the following output:\n    ```console\n    [1/4] project_name (My FastAgency App):\n    [2/4] project_slug (my_fastagency_app):\n    [3/4] Select app_type\n        1 - fastapi+mesop\n        2 - mesop\n        3 - nats+fastapi+mesop\n        Choose from [1/2/3] (1): 1\n    [4/4] Select python_version\n        1 - 3.12\n        2 - 3.11\n        3 - 3.10\n        Choose from [1/2/3] (1):\n    [5/5] Select authentication\n        1 - none\n        2 - google\n        Choose from [1/2] (1):\n    ```\n\n4. To run LLM-based applications, you need an API key for the LLM used. The most commonly used LLM is [OpenAI](https://platform.openai.com/docs/models). To use it, create an [OpenAI API Key](https://openai.com/index/openai-api/) and set it as an environment variable in the terminal using the following command:\n\n    ```console\n    export OPENAI_API_KEY=openai_api_key_here\n    ```\n\n5. Open the generated project in [Visual Studio Code](https://code.visualstudio.com/) with the following command:\n    ```console\n    code my_fastagency_app\n    ```\n\n6. Once the project is opened, you will get the following option to reopen it in a devcontainer:\n\n    <img src=\"https://fastagency.ai/0.3/user-guide/getting-started/images/reopen-in-container.png\" width=\"600\" class=\"center\">\n\n7. After reopening the project in devcontainer, you can verify that the setup is correct by running the provided tests with the following command:\n\n    ```console\n    pytest -s\n    ```\n\n    You should get the following output if everything is correctly setup.\n    ```console\n    =================================== test session starts ===================================\n    platform linux -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0\n    rootdir: /workspaces/my_fastagency_app\n    configfile: pyproject.toml\n    plugins: asyncio-0.24.0, anyio-4.6.2.post1\n    asyncio: mode=Mode.STRICT, default_loop_scope=None\n    collected 1 item\n\n    tests/test_workflow.py .                                                            [100%]\n\n    ==================================== 1 passed in 1.02s ====================================\n    ```\n-----\n\n### Workflow Development\n\n#### Define the Workflow\n\nYou 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 as it is generated by the cookie cutter under `my_fastagency_app/workflow.py`:\n\n```python\nimport os\nfrom typing import Any\n\nfrom autogen.agentchat import ConversableAgent\nfrom fastagency import UI\nfrom fastagency.runtimes.autogen import AutoGenWorkflows\n\nllm_config = {\n    \"config_list\": [\n        {\n            \"model\": \"gpt-4o-mini\",\n            \"api_key\": os.getenv(\"OPENAI_API_KEY\"),\n        }\n    ],\n    \"temperature\": 0.8,\n}\n\nwf = AutoGenWorkflows()\n\n\n@wf.register(name=\"simple_learning\", description=\"Student and teacher learning chat\")  # type: ignore[misc]\ndef simple_workflow(ui: UI, params: dict[str, Any]) -> str:\n    initial_message = ui.text_input(\n        sender=\"Workflow\",\n        recipient=\"User\",\n        prompt=\"I can help you learn about mathematics. What subject you would like to explore?\",\n    )\n\n    student_agent = ConversableAgent(\n        name=\"Student_Agent\",\n        system_message=\"You are a student willing to learn.\",\n        llm_config=llm_config,\n    )\n    teacher_agent = ConversableAgent(\n        name=\"Teacher_Agent\",\n        system_message=\"You are a math teacher.\",\n        llm_config=llm_config,\n    )\n\n    chat_result = student_agent.initiate_chat(\n        teacher_agent,\n        message=initial_message,\n        summary_method=\"reflection_with_llm\",\n        max_turns=3,\n    )\n\n    return str(chat_result.summary)\n```\n\nThis code snippet sets up a simple learning chat between a student and a teacher. It defines the agents and how they should interact and specify how the conversation should be summarized.\n\n#### Run and Debug the Workflow\n\nTo ensure that the workflow we have defined is working properly, we can test it locally using MesopUI. The code below can be found under `my_fastagency_app/local/main_mesop.py` and imports the defined workflow and sets up MesopUI.\n\nYou can run the Mesop application locally with the following command on Linux and MacOS:\n\n```console\ngunicorn my_fastagency_app.local.main_mesop:app\n```\n\nOn Windows, please use the following command:\n```console\nwaitress-serve --listen=0.0.0.0:8000 my_fastagency_app.local.main_mesop:app\n```\n\nOpen the MesopUI URL [http://localhost:8000](http://localhost:8000) in your browser. You can now use the graphical user interface to start, run, test and debug the autogen workflow manually.\n\n![Initial message](https://fastagency.ai/latest/user-guide/getting-started/images/chat-init.png)\n\n\n## Deployment\n\n### Building the Docker Image\n\nIf you created the project using Cookiecutter, then building the Docker image is as simple as running the provided script, as shown below:\n\n```console\n./scripts/build_docker.sh\n```\n\n### Running the Docker Image\n\nSimilarly, running the Docker container is as simple as running the provided script, as shown below:\n\n```console\n./scripts/run_docker.sh\n```\n\n### Deploying to Fly.io\n\nIf you created the project using Cookiecutter, there is a built-in script to deploy your workflow to [**Fly.io**](https://fly.io/). Run it as shown below:\n\n```console\n./scripts/deploy_to_fly_io.sh\n```\n\n## Future Plans\n\nWe are actively working on expanding FastAgency\u2019s capabilities. In addition to supporting AutoGen, we plan to integrate support for other frameworks, other network provider and other UI frameworks.\n\n---\n\n## \u2b50\u2b50\u2b50 Stay in touch \u2b50\u2b50\u2b50\n\nStay up to date with new features and integrations by following our documentation and community updates on our [**Discord server**](https://discord.gg/kJjSGWrknU). FastAgency is continually evolving to support new frameworks, APIs, and deployment strategies, ensuring you remain at the forefront of AI-driven development.\n\nLast but not least, show us your support by giving a star to our [**GitHub repository**](https://github.com/airtai/fastagency/).\n\n\nYour support helps us to stay in touch with you and encourages us to\ncontinue developing and improving the framework. Thank you for your\nsupport!\n\n---\n\n## Contributors\n\nThanks to all of these amazing people who made the project better!\n\n<a href=\"https://github.com/airtai/fastagency/graphs/contributors\" target=\"_blank\">\n  <img src=\"https://contrib.rocks/image?repo=airtai/fastagency\"/>\n</a>\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "The fastest way to bring multi-agent workflows to production",
    "version": "0.3.4",
    "project_urls": {
        "Discord": "https://discord.gg/kJjSGWrknU",
        "Documentation": "https://fastagency.ai/latest/",
        "Homepage": "https://github.com/airtai/fastagency",
        "Source": "https://github.com/airtai/fastagency",
        "Tracker": "https://github.com/airtai/fastagency/issues"
    },
    "split_keywords": [
        "ai",
        " llm",
        " autogen",
        " autonomous agents",
        " multi-agent"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dbc8f32e6ee457c2367793c6a317474ebdc52404e29c90ba4605d8d6c7f0bda1",
                "md5": "df09714b653ab276f11a7a79a4435545",
                "sha256": "965865c213df9631d3156a4734bbce454e7efb80a1c748f6cac5b1eb4f16c18b"
            },
            "downloads": -1,
            "filename": "fastagency-0.3.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "df09714b653ab276f11a7a79a4435545",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 90814,
            "upload_time": "2024-11-12T15:33:50",
            "upload_time_iso_8601": "2024-11-12T15:33:50.976138Z",
            "url": "https://files.pythonhosted.org/packages/db/c8/f32e6ee457c2367793c6a317474ebdc52404e29c90ba4605d8d6c7f0bda1/fastagency-0.3.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8e5b4b6fa3ed3cd6ea8786feb43efce0bf83494469a4f1d66e334f7213facb44",
                "md5": "e1b055d1d85e63b6cdd7184e830098e5",
                "sha256": "dfb06c5f5b9e34195a1e4de5b823091660bd7045ff5a6688c29af9a752ccc768"
            },
            "downloads": -1,
            "filename": "fastagency-0.3.4.tar.gz",
            "has_sig": false,
            "md5_digest": "e1b055d1d85e63b6cdd7184e830098e5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 107550,
            "upload_time": "2024-11-12T15:33:52",
            "upload_time_iso_8601": "2024-11-12T15:33:52.631551Z",
            "url": "https://files.pythonhosted.org/packages/8e/5b/4b6fa3ed3cd6ea8786feb43efce0bf83494469a4f1d66e334f7213facb44/fastagency-0.3.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-12 15:33:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "airtai",
    "github_project": "fastagency",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "fastagency"
}
        
Elapsed time: 0.76730s