This repository contains a FastAgency
application which uses FastAPI, and Mesop. Below, you'll find a guide on how to run the application.
To run this FastAgency
application, follow these steps:
-
To run the
FastAgency
application, you need an API key for any LLM. The most commonly used LLM is OpenAI. To use it, create an OpenAI API Key and set it as an environment variable in the terminal using the following command:export OPENAI_API_KEY=paste_openai_api_key_here
If you want to use a different LLM provider, follow this guide.
Alternatively, you can skip this step and set the LLM API key as an environment variable later in the devcontainer's terminal. If you open the project in
VSCode
using GUI, you will need to manually set the environment variable in the devcontainer's terminal.For GitHub Codespaces, you can set the LLM API key as a secret by following this guide, Or directly as an environment variable in the Codespaces' terminal.
-
Open this folder in VSCode using the following command:
code .
If you are using GUI to open the project in
VSCode
, you will need to manually set the environment variable in the devcontainer's terminal.Alternatively, you can open this repository in GitHub Codespaces.
-
Press
Ctrl+Shift+P
(for windows/linux) orCmd+Shift+P
(for mac) and select the optionDev Containers: Rebuild and Reopen in Container
. This will open the current repository in a devcontainer using Docker and will install all the requirements to run the example application. -
The
workflow.py
file defines the autogen workflows. It is imported and used in the files that define theUI
. -
The
main_1_fastapi.py
file defines theFastAPIAdapter
. In a devcontainer terminal(Terminal 1), run the following command:uvicorn mailchimp_api.deployment.main_1_fastapi:app --host 0.0.0.0 --port 8008 --reload
-
The
main_2_mesop.py
file defines theMesopUI
. In a new devcontainer terminal(Terminal 2), run the following command:gunicorn mailchimp_api.deployment.main_2_mesop:app -b 0.0.0.0:8888 --reload
-
Open the Mesop UI URL http://localhost:8888 in your browser. You can now use the graphical user interface to start and run the autogen workflow.
This FastAgency
project includes tests to test the autogen workflow. Run these tests with the following command:
pytest -s
This FastAgency
project includes a Dockerfile for building and running a Docker image. You can build and test-run the Docker image within the devcontainer, as docker-in-docker support is enabled. Follow these steps:
-
In the devcontainer terminal, run the following command to build the Docker image:
docker build -t deploy_fastagency -f docker/Dockerfile .
-
Once the Docker image is built, you can run it using the following command:
docker run --rm -d --name deploy_fastagency -e OPENAI_API_KEY=$OPENAI_API_KEY -p 8008:8008 -p 8888:8888 deploy_fastagency
This FastAgency
project includes a fly.toml
file for deployment to fly.io, allowing you to share this project with others using a single URL. If you prefer deploying to another hosting provider, you can use the provided Dockerfile. To deplooy to fly.io, follow these steps:
-
Login into fly.io:
fly auth login
-
Launch the fly.io app:
fly launch --config fly.toml --copy-config --yes
-
Set necessary LLM API key(for example, OPENAI_API_KEY) as a secret:
fly secrets set OPENAI_API_KEY=paste_openai_api_key_here
Once you’ve experimented with the default workflow in the workflow.py
file, modify the autogen workflow to define your own workflows and try them out.