How to Set Up and Use OpenPipe Locally

Jan 20, 2021 | Educational

OpenPipe is an open-source fine-tuning and model-hosting platform that helps you harness powerful language models to suit your unique needs. Recently, OpenPipe development has temporarily paused on the open-source version to incorporate proprietary third-party code. However, once development resumes, we anticipate making non-proprietary parts available again. In this guide, we will walk you through running OpenPipe locally, along with troubleshooting tips to help you troubleshoot any issues that may arise.

Prerequisites

Before you dive into the setup process, ensure you have the following tools and resources ready:

  • [PostgreSQL](https://www.postgresql.org/download)
  • [NodeJS 20](https://nodejs.org/en/download/current) (earlier versions might work but are not tested)
  • pnpm (Node package manager)

Step-by-Step Guide to Running OpenPipe Locally

1. Install PostgreSQL

Begin by installing PostgreSQL on your local machine. Visit the [PostgreSQL download page](https://www.postgresql.org/download) to get started.

2. Install NodeJS 20

Download and install NodeJS 20 from [Node.js official site](https://nodejs.org/en/download/current).

3. Install pnpm

Open your terminal and run the following command to install pnpm:

npm i -g pnpm

4. Clone the OpenPipe Repository

Clone the OpenPipe GitHub repository using this command:

git clone https://github.com/openpipe/openpipe

5. Install Dependencies

Navigate into the OpenPipe directory and install the necessary dependencies:

cd openpipe
pnpm install

6. Configure Environment Variables

Create a .env file by copying the example and enter your OPENAI_API_KEY:

cd app
cp .env.example .env

7. Set Up PostgreSQL

Run the following commands to set up your PostgreSQL instance:

sh
psql postgres
CREATE ROLE postgres WITH LOGIN PASSWORD 'postgres';
ALTER ROLE postgres SUPERUSER;

8. Update Database URL

If necessary, update the DATABASE_URL to point to your PostgreSQL instance. Then run the database migration:

pnpm prisma migrate dev

9. Create a GitHub OAuth App

Follow the instructions to [create a GitHub OAuth App](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app). Set the callback URL to your local instance, e.g., http://localhost:3000/api/auth/callback/github.

10. Update OAuth Credentials

Replace the GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET values from your GitHub OAuth app in your .env file.

11. Start the Application

Navigate to the app directory and run the application:

pnpm dev

12. Access OpenPipe in Your Browser

Open your web browser and go to http://localhost:3000 to see OpenPipe in action!

Using OpenPipe Locally

Once you’ve set everything up, here’s how you can use OpenPipe:


import os
from openpipe import OpenAI

client = OpenAI(
    api_key='Your API Key',
    openpipe={
        'api_key': 'Your OpenPipe API Key',
        'base_url': 'http://localhost:3000/api/v1',  # Local OpenPipe instance
    }
)

completion = client.chat.completions.create(
    model='gpt-3.5-turbo',
    messages=[{'role': 'system', 'content': 'count to 10'}],
    openpipe={
        'tags': {'prompt_id': 'counting'},
        'log_request': True
    },
)

In this example, you are using the OpenPipe API to send a request to a model, asking it to count from 1 to 10.

Troubleshooting Tips

If you encounter any issues during the setup or usage, here are a few troubleshooting ideas:

  • Ensure your PostgreSQL service is running and accessible.
  • Confirm that all environment variables in your .env file are correctly set.
  • Make sure your GitHub OAuth App settings are correctly configured.
  • For API issues, check if your API keys are properly entered and have the required permissions.
  • If you have difficulty deploying, consult the [OpenPipe documentation](https://docs.openpipe.ai/introduction) for additional guidance.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox