Skip to content

airtai/mailchimp-api

Repository files navigation

Mailchimp API

This repository contains a FastAgency application which uses FastAPI, and Mesop. Below, you'll find a guide on how to run the application.

Running FastAgency Application

To run this FastAgency application, follow these steps:

  1. 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.

  2. 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.

  3. Press Ctrl+Shift+P(for windows/linux) or Cmd+Shift+P(for mac) and select the option Dev 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.

  4. The workflow.py file defines the autogen workflows. It is imported and used in the files that define the UI.

  5. The main_1_fastapi.py file defines the FastAPIAdapter. 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
  6. The main_2_mesop.py file defines the MesopUI. 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
  7. 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.

Running tests

This FastAgency project includes tests to test the autogen workflow. Run these tests with the following command:

pytest -s

Docker

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:

  1. In the devcontainer terminal, run the following command to build the Docker image:

    docker build -t deploy_fastagency -f docker/Dockerfile .
  2. 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

Deploying with Docker

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:

  1. Login into fly.io:

    fly auth login
  2. Launch the fly.io app:

    fly launch --config fly.toml --copy-config --yes
  3. Set necessary LLM API key(for example, OPENAI_API_KEY) as a secret:

    fly secrets set OPENAI_API_KEY=paste_openai_api_key_here

What's Next?

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published