Build, evaluate and optimize your LLM pipelines to increase accuracy and reduce cost. Use with Superpipe or with your favorite LLM framework. Easily deploy it on your own infra.
Superpipe Studio is built with Next JS and can be run locally or deployed on Vercel. It requires a database and can optionally provide authentication via Clerk. It works with both SQLite and Postgres. When running locally we recommend using SQLite for simplicity, and in production via recommend using Postgres.
First, setup your environment checking out the repo, installing Node JS v18 or later, and running npm install
.
Create a .env.local
file in the project root directory by copying and renaming the .env
file.
npm run migrate-deploy:sqlite
npm run dev
- In
.env.local
setNEXT_PUBLIC_APP_DATABASE_PROVIDER=postgres
- Create a
.env
file insideprisma-postgres
folder - Add
POSTGRES_PRISMA_URL
andPOSTGRES_URL_NON_POOLING
with the URL of your postgres database npm run migrate-deploy:postgres
npm run dev:postgres
Studio can be used without any authentication (for local testing) or with Clerk authentication.
Authentication is disabled by default by setting NEXT_PUBLIC_AUTHENTICATION=disabled
in the .env
/.env.local
file.
To enable Clerk authentication while running locally:
- Create a Clerk organization and from the Clerk dashboard, grab your publishable key and secret key.
- Create a
.env.local
file in the project root by copying.env
and setNEXT_PUBLIC_AUTHENTICATION=enabled
- Add the
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
andCLERK_SECRET_KEY
variables with their respective Clerk values, to the.env.local
file npm run dev
ornpm run dev:postgres
- Download and install ngrok
- Open command line, run
ngrok http 3000
and copy URL - Navigate to Webhooks page in the Clerk dashboard, add the
<ngrok_url>/api/webhook/clerk/user
, with user filter - Navigate to Studio (default http://localhost:3000/) and log in
If you're looking to enable auth in a Vercel deployment, follow the Vercel deployment instructions below.
Once you've enabled authentication in Studio, any programmatic requests to the Studio API need to be authenticated with an API key. This includes requests made automatically by the Superpipe SDK.
To get your Studio API key:
- Login to your Studio instance
- In the account menu (top right corner), click "Manage Account"
- Grab your API key from the "API Management" section
If you're using Studio with the Superpipe SDK, set the SUPERPIPE_API_KEY
environment variable to your API key. If you're using Studio via REST API, set the x-api-key
header to your API key.
Studio integrates with Superpipe SDK, allowing you to log pipelines, create datasets and run experiments on them with minimal effort if you're already using Superpipe SDK to build your pipelines.
For details on how to use Studio with Superpipe SDK and advanced usage details, see the Superpipe Studio docs.
Logging
input = {
...
}
pipeline.run(data=input, enable_logging=True)
Datasets
from studio import Dataset
import pandas as pd
df = pd.DataFrame(...)
dataset = Dataset(data=df, name="furniture", ground_truths=["brand_name"])
Experiments
import pandas as pd
df = pd.DataFrame(...)
pipeline.run_experiment(data=df)
Studio is a Next JS app and can be easily deployed on Vercel or other hosting solutions compatible with Next JS. Hosting Studio on Vercel requires a Vercel account, a postgres database URL and optionally, a Clerk account for authentication.
A. Setup your Postgres database
You can use any Postgres provider as long as it provides you an authenticated database URL that is accessible from Vercel.
B. (Optional) Setup Clerk authentication
- Create a Clerk organization and from the Clerk dashboard, grab your publishable key and secret key.
- Navigate to Webhooks page in the Clerk dashboard, add the
<your_studio_url>/api/webhook/clerk/user
, with user filter
C. Deploy superpipe-studio to Vercel
- Create a new Vercel project
- Set env vars:
POSTGRES_PRISMA_URL
= your full DB urlPOSTGRES_URL_NON_POOLING
= your full DB urlCLERK_SECRET_KEY
(from your Clerk project)NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
(from your Clerk project)NEXT_PUBLIC_AUTHENTICATION
=enabled
NEXT_PUBLIC_APP_DATABASE_PROVIDER
=postgres
- Checkout or fork the repo & go through the standard Vercel deployment flow
- Once deployed, navigate to your Studio URL, login and grab your API key
The app is using Prisma with two different providers: SQLite and Postgres.
There are two different folders for each prisma_postgres
and prisma_sqlite
. Whenever you run an individual prisma command you have to specify which schema to use with --schema=./prisma_postgres/schema.prisma
or --schema=./prisma_sqlite/schema.prisma
Superpipe studio uses dynamically generated tables to store pipeline logs, datasets and experiments. When you make schema changes, Prisma will try to drop the dynamic tables. It is very important that you manually remove these drop statements from the generated migrations.
- Make the schema change in both folders.
npm run create-migration:postgres
andnpm run create-migration:sqlite
- Modify the generated migrations
- Remove SQL instructions to drop the dynamic tables
- Modify the rest of the instructions to try to avoid unnecessary table drops
npm run migrate-deploy:postgres
ornpm run migrate-deploy:sqlite
npm run dev
ornpm run dev:postgres
If the Migration deploy fails, a failed migration record will be generated in the _prisma_migrations
table. Re-running the deploy command will fail even if the migration error is fixed. In order to resolve this there are two options:
- Remove the record from the table and re-run the deploy command
- Run the following command which will mark the broken record as rolled-back and allow us to insert a new record with the same name. Don't forget to replace the name of the migration folder and the database provider accordingly
npx prisma migrate resolve --rolled-back ${MIGRATION_FOLDER_NAME} --schema=./prisma_${postgres or sqlite}/schema.prisma
To change log level set the LOG_LEVEL
environment variable to one of: error
, warn
, info
, debug
(default is error)