Llama 3.1 ChatGPT
Introduction
Llama 3.1 ChatGPT is an AI chat application. You can choose which service runs the Llama 3.1 model - Groq, Replicate, or Azure. This documentation will guide you through the detailed step by step process to use and deploy the app.
Quickstart Guide
Installation
-
Clone the repository:
git clone https://github.com/1811-Labs-LLC/BuilderKit-Pro.git [YOUR_APP_NAME] cd [YOUR_APP_NAME] git checkout llamagpt git remote remove origin
Remove the origin remote
to ensure that you can work locally without pushing the changes back to the original repository.
git remote remove origin
However, note that after removing the remote, you won't be able to switch between the branches, so you'll need to clone the repository again if you want to work on another branch.
-
Install dependencies:
terminalnpm install
-
Environment Variables:
Copy the required variables from
.env.example
to.env.local
as mentioned and update the values.terminalcp .env.example .env.local
Or, manually create a
.env.local
file in the root directory with the following env variables (make sure to update the values with your actual keys):.env.local# Host NEXT_PUBLIC_APP_URL=<your-app-url> # Supabase NEXT_PUBLIC_SUPABASE_URL=<your-supabase-url> NEXT_PUBLIC_SUPABASE_ANON_KEY=<your-supabase-anon-key> NEXT_PUBLIC_SUPABASE_STORAGE_BUCKET_NAME=<your-supabase-storage-bucket-name> # Replicate REPLICATE_API_TOKEN=<your-replicate-api-key> # Groq GROQ_API_KEY=<your-groq-api-key> # Azure AZUREAI_ENDPOINT_URL=<your-azure-model-endpoint-url> AZUREAI_ENDPOINT_KEY=<your-model-endpoint-key> # Llama Service to be used # Available options: 'groq' | 'replicate' | 'azure' SERVICE_IN_USE=<service-to-be-used-for-llama-3.1> # Google Analytics NEXT_PUBLIC_GOOGLE_ANALYTICS_KEY=<your-google-analytics-key>
💡Note: To select the service for Llama 3.1, you just need to setup the SERVICE_IN_USE variable in env. Available options: groq | replicate | azure. If it is not set, by default "replicate" will be used.
Setup Supabase
If you have not setup the supabase yet, go through the detailed documentation to set up the supabase for BuilderKit.ai. Make sure that you are creating the user table as mentioned in the supabase setup doc as it is required for the tool.
-
Create Text to Speech Table in Supabase:
sql-- Create a table for LlamaGPT create table llamagpt ( id uuid not null default uuid_generate_v4 (), created_at timestamp with time zone not null default now(), user_id uuid null, title text null, chat_history jsonb null, constraint llamagpt_pkey primary key (id), constraint llamagpt_user_id_fkey foreign key (user_id) references users (id) ); -- Set up Row Level Security (RLS) alter table llamagpt enable row level security; create policy "Users can insert their own row." on llamagpt for insert with check (auth.uid() = user_id); create policy "Users can update own row" on llamagpt for update using (auth.uid() = user_id); create policy "Users can read own row" on llamagpt for select using (auth.uid() = user_id);
For all the tables, we enable the RLS policy by default with necessary permissions as mentioned in the script.
-
Sync Supabase Types:
To sync the supabase table schema with your project follow the steps here.
Running the Application
-
Run the development server:
terminalnpm run dev
This will start the development server on http://localhost:3000 (opens in a new tab).
-
Build for production:
terminalnpm run build
This command compiles the application for production usage.
-
Start the production server:
terminalnpm start
This will start the application in production mode.
Additional Scripts
-
Prepare Husky for Git hooks:
terminalnpm run prepare
-
Validate the code with Linting, Formatting & Typecheck:
terminalnpm run validate
Make the tool publicly accessible by removing the login process
-
Go to
src/app/(dashboard)/layout.tsx
and comment the following sectionfrom line:15 to line:20
as shown in the image below: -
Go to
src/app/api/chat/route.ts
and comment the following sectionfrom line:21 to line:26
as shown in the image below:
These sections reads the user data and checks if the user is signed in or not. By commenting this section it does not check the user validation.
Requirements
- Node.js: Download and install from here (opens in a new tab).
- Supabase: Create an account and a new project on Supabase (opens in a new tab). Obtain the
SUPABASE_URL
andSUPABASE_ANON_KEY
from your project settings. - Anthropic API Key: Sign up for an API key on Anthropic (opens in a new tab) and get free credits to start up.
- Replicate API Key: Create an account on Replicate (opens in a new tab) to get the api token.
- Azure: Login to Azure (opens in a new tab), deploy the model and get the required credentials.