Repository: homanp/vercel-langchain Branch: main Commit: 9025bf531a8a Files: 5 Total size: 1.6 KB Directory structure: gitextract_9eoj8xvl/ ├── .gitignore ├── README.md ├── api/ │ └── index.py ├── requirements.txt └── vercel.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ .vercel *.log *.pyc __pycache__ # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ ================================================ FILE: README.md ================================================ [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fhomanp%2Fvercel-langchain) # LangChain running on Vercel A minimal example on how to run LangChain on Vercel using Flask. ## Installation #### 1. Virtualenv Create and activate `virtualenv`. ```bash virtualenv MY_ENV source MY_ENV/bin/activate ``` #### 2. Install requirements ```bash pip install requirements.txt ``` #### 3. Start development server ```bash vercel dev ``` #### 4. Example API route ```bash GET http://localhost:3000 ``` ## Environment Variables To run this project, you will need to add the following environment variables to your .env file `OPENAI_API_KEY` ## One-Click Deploy [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fhomanp%2Fvercel-langchain) ## Further reading Learn more about how to use LangChain by visiting the offical documentation or repo: https://langchain.readthedocs.io/en/latest/ https://github.com/hwchase17/langchain ================================================ FILE: api/index.py ================================================ import os from flask import Flask from langchain.llms import OpenAI app = Flask(__name__) @app.route('/') def home(): llm = OpenAI(temperature=0.9) text = "What would be a good company name a company that makes colorful socks?" return llm(text) ================================================ FILE: requirements.txt ================================================ Flask==2.2.2 langchain==0.0.113 openai==0.26.4 ================================================ FILE: vercel.json ================================================ { "builds": [ { "src": "api/index.py", "use": "@vercel/python" } ], "routes": [ { "src": "/(.*)", "dest": "api/index.py" } ] }