For Developers
Below is a guide for running the beta version of ChainForge directly from source, for people who want to modify, develop or extend it. Note that these steps may change in the future.
Install requirements
Before you can run ChainForge, you need to install dependencies. First, make sure you have Python 3.10+ installed. You can check your version by running python --version in the terminal. If you don't have Python installed, you can download it from python.org.
Clone the repository and cd into the chainforge dir. Then run:
pip install -r requirements.txt
to install requirements. (Ideally, you will run this in a virtualenv. See the installation instructions for examples of how to setup a virtual env in Python.)
Note
If pip fails or hangs, you have a few options:
- Try running
pip install --upgrade pipto upgrade pip, and then re-run the above command. - If you are using a Mac, try running
pip install --no-use-pep517to avoid the new PEP 517 build system. - Try the
--use-deprecated=legacy-resolverflag to use the old resolver, which is less strict about dependency conflicts. - If all else fails, the code may include a
requirements-lock.txtfile, which is a snapshot of working versions of dependencies at one point in time. You can try runningpip install -r requirements-lock.txtinstead ofrequirements.txt.
To install Node.js requirements, first make sure you have Node.js installed. Then cd into chainforge/react-server and run:
npm install
You might run into dependency conflicts. You can re-run with --force to force continued installation.
Serving ChainForge manually
To serve ChainForge manually, you have two options: 1. Run everything from a single Python script, which requires building the React app to static files, or 2. Serve the React front-end separately from the Flask back-end and take advantage of React hot reloading.
We recommend the former option for end-users, and the latter for developers.
Option 1: Build React app as static files (end-users)
cd into react-server directory and run:
npm run build
Wait a moment while it builds the React app to static files.
Option 2: Serve React front-end with hot reloading (developers)
cd into react-server directory and run the following to serve the React front-end:
npm run start
Serving the backend
Regardless of which option you chose, cd into the root ChainForge directory and run:
python -m chainforge.app serve
This script spins up a Flask server on port 8000. Note that most of the app logic is fully in the browser, but some calls (like loading API keys as environment variables, or querying Anthropic API) still go through the Flask server.
If you built the React app statically, go to localhost:8000 in a web browser to view the app (ideally in Google Chrome).
If you served the React app with hot reloading with npm run start, go to the server address you ran it on (usually localhost:3000).
Problems?
Open an Issue.
Contributing to ChainForge
If you want to contribute, welcome! Please fork this repository and submit a Pull Request with your changes.
If you have access to the main repository, we request that you add a branch dev/<your_first_name> and develop changes from there. When you are ready to push changes, say to address an open Issue, make a Pull Request on the experimental repository and assign the main developer (Ian Arawjo) to it.