GithubHelp home page GithubHelp logo

fly-apps / hello-fly-langchain Goto Github PK

View Code? Open in Web Editor NEW
23.0 10.0 4.0 12 KB

A minimal example of how to deploy LangChain to Fly.io using Flask

Home Page: https://fly.io/blog/deploying-langchain-to-fly-io/

Procfile 1.70% Python 76.48% HTML 21.82%
deployment flask langchain flyio llms python

hello-fly-langchain's Introduction

LangChain Running on Fly.io

Illustration by Annie Ruygt Deploying a minimal Flask + LangChain application on Fly.io.

You can find the complete guide in this Blog Post.

App: Best places to eat

The application will give 3 options where to eat in <place>. The default value is Berlin.

Prompt: What are the 3 best places to eat in {place}?

You can define your own input variable (place) by calling:

https://<your-app-name>.fly.dev/<place>

Examples:

Country

  • Norway: https://<your-app-name>.fly.dev/norway

City

  • Prague: https://<your-app-name>.fly.dev/prague

Local Development ⚒️

Create and Activate a Virtual Environment

We'll be using venv, but you can choose any virtual environment to manage the dependencies (e.g. virtualenv).

# Unix/macOS
$ python3 -m venv venv
$ . venv/bin/activate

# Windows
$ py -3 -m venv venv
$ venv\Scripts\activate

Install Dependencies from requirements.txt

python -m pip install -r requirements.txt

Set Up .env file

The environment variables are stored in the .env file.

Rename the .env.dist file to .env. Update the OPENAI_API_KEY environment variable with your own secret key:

FLASK_APP=hello
OPENAI_API_KEY=<your-openai-api-secret-key>

The OpenAI API uses API keys for authentication. Visit your OpenAI API Key page to retrieve the API key you'll use in your requests.

Run the project

flask run

Deploying to Fly.io 🚀

flyctl is the command-line utility provided by Fly.io.

If not installed yet, follow these instructions, sign up and log in to Fly.io.

Launching Our App

fly launch will detect our Python (Flask) App.

fly launch

During the launch you will:

  • Choose an app name
  • Select Organization
  • Choose a region for deployment

The Procfile already exists in this project - a new one will be generated for you if your project doesn't have one.

More details on fly launch can be found here.

Set Environment Variables

Set the OPENAI_API_KEY environment variable:

fly secrets set OPENAI_API_KEY=<your-openai-api-secret-key>

Deploy to Fly.io

fly deploy

More details on fly deploy can be found here.

Visit Your App

fly open

For detailed documentation on how to deploy a Flask application on Fly.io, check Run a Python App.

hello-fly-langchain's People

Contributors

katiayn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.