Giter Club home page Giter Club logo

ai-getting-started's Introduction

AI Getting Started

Live Demo (deployed on fly.io)

Join our community Discord: AI Stack Devs

Screen Shot 2023-06-20 at 1 30 56 PM

Stack

Overview

Quickstart

The simplest way to try out this stack is to test it out locally and traverse through code files to understand how each component work. Here are the steps to get started.

1. Fork and Clone repo

Fork the repo to your Github account, then run the following command to clone the repo:

git clone [email protected]:[YOUR_GITHUB_ACCOUNT_NAME]/ai-getting-started.git

2. Install dependencies

cd ai-getting-started
npm install 

3. Fill out secrets

cp .env.local.example .env.local

a. Clerk Secrets

Go to https://dashboard.clerk.com/ -> "Add Application" -> Fill in Application name/select how your users should sign in -> Create Application Now you should see both NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and CLERK_SECRET_KEY on the screen clerk

b. OpenAI API key

Visit https://platform.openai.com/account/api-keys to get your OpenAI API key

c. Replicate API key

Visit https://replicate.com/account/api-tokens to get your Replicate API key

NOTE: By default, this template uses Pinecone as vector store, but you can turn on Supabase pgvector easily. This means you only need to fill out either Pinecone API key or Supabase API key.

d. Pinecone API key

  • Create a Pinecone index by visiting https://app.pinecone.io/ and click on "Create Index"
  • Give it an index name (this will be the environment variable PINECONE_INDEX)
  • Fill in Dimension as 1536
  • Once the index is successfully created, click on "API Keys" on the left side nav and create an API key: copy it to PINECONE_API_KEY

e. Supabase API key

  • Create a Supabase instance here; then go to Project Settings -> API
  • SUPABASE_URL is the URL value under "Project URL"
  • SUPABASE_PRIVATE_KEY is the key starts with ey under Project API Keys
  • Now, you should enable pgvector on Supabase and create a schema. You can do this easily by clicking on "SQL editor" on the left hand side on supabase UI and then clicking on "+New Query". Copy paste this code snippet in the SQL editor and click "Run".

f. Arcjet key

Visit https://app.arcjet.com to sign up for free and get your Arcjet key.

4. Generate embeddings

There are a few markdown files under /blogs directory as examples so you can do Q&A on them. To generate embeddings and store them in the vector database for future queries, you can run the following command:

If using Pinecone

Run the following command to generate embeddings and store them in Pinecone:

npm run generate-embeddings-pinecone

If using Supabase pgvector

In QAModel.tsx, replace /api/qa-pinecone with /api/qa-pg-vector. Then run the following command to generate embeddings and store them in Supabase pgvector:

npm run generate-embeddings-supabase

5. Run app locally

Now you are ready to test out the app locally! To do this, simply run npm run dev under the project root.

6. Deploy the app

Deploy to fly.io

  • Register an account on fly.io and then install flyctl
  • Run fly launch under project root -- this will generate a fly.toml that includes all the configurations you will need
  • Run fly deploy --ha=false to deploy the app -- the --ha flag makes sure fly only spins up one instance, which is included in the free plan. You also want to run fly scale memory 512 to scale up the fly vm memory for this app.
  • For any other non-localhost environment, the existing Clerk development instance should continue to work. You can upload the secrets to Fly by running cat .env.local | fly secrets import
  • If you are ready to deploy to production, you should create a prod environment under the current Clerk instance. For more details on deploying a production app with Clerk, check out their documentation here. Note that you will likely need to manage your own domain and do domain verification as part of the process.
  • Create a new file .env.prod locally and fill in all the production-environment secrets. Remember to update NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and CLERK_SECRET_KEY by copying secrets from Clerk's production instance -cat .env.prod | fly secrets import to upload secrets

Other deployment options

How to contribute to this repo

Code contribution workflow

You can fork this repo, make changes, and create a PR. Add @ykhli or @timqian as reviewers.

If you are new to contributing on github, here is a step-by-step guide:

  1. Clcik on Fork on the top right of this page
  2. Work on your change and push it to your forked repo. Now when you navigate to the forked repo's UI, you should see something like the following:
pr-preview
  1. Click on "Contribute" -> "Open Pull Request".
  2. Once you have a PR, you can add reviewers.

Other contributions

Feel free to open feature requests, bug reports etc under Issues.

Refs

ai-getting-started's People

Contributors

bendechrai avatar davidmytton avatar dependabot[bot] avatar fmhall avatar jenniferli23 avatar nirantk avatar peterp avatar rajko-rad avatar sragss avatar sumanth001 avatar timqian avatar ykhli avatar zeke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ai-getting-started's Issues

Errors when running "npm install"

Apologies if this is a very basic question (I am a JS noob) but any help would be appreciated. I get the following error when I run the "npm install" command. For reference, I am using node version 20.5.1. Any guidance would be appreciated.

npm ERR! code 1
npm ERR! path /home/dougj892/ai-getting-started/node_modules/hnswlib-node
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info find Python using Python version 3.10.12 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/dougj892/ai-getting-started/node_modules/hnswlib-node/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/dougj892/.cache/node-gyp/20.5.1/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/home/dougj892/.cache/node-gyp/20.5.1',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/home/dougj892/.cache/node-gyp/20.5.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/dougj892/ai-getting-started/node_modules/hnswlib-node',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: not found: make
npm ERR! gyp ERR! stack at getNotFoundError (/home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp/node_modules/which/which.js:10:17)
npm ERR! gyp ERR! stack at /home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp/node_modules/which/which.js:57:18
npm ERR! gyp ERR! stack at new Promise ()
npm ERR! gyp ERR! stack at step (/home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp/node_modules/which/which.js:54:21)
npm ERR! gyp ERR! stack at /home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp/node_modules/which/which.js:71:22
npm ERR! gyp ERR! stack at new Promise ()
npm ERR! gyp ERR! stack at subStep (/home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp/node_modules/which/which.js:69:33)
npm ERR! gyp ERR! stack at /home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp/node_modules/which/which.js:80:22
npm ERR! gyp ERR! stack at /home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/isexe/index.js:42:5
npm ERR! gyp ERR! stack at /home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/isexe/mode.js:8:5
npm ERR! gyp ERR! System Linux 5.15.90.1-microsoft-standard-WSL2
npm ERR! gyp ERR! command "/home/dougj892/.nvm/versions/node/v20.5.1/bin/node" "/home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /home/dougj892/ai-getting-started/node_modules/hnswlib-node
npm ERR! gyp ERR! node -v v20.5.1
npm ERR! gyp ERR! node-gyp -v v9.4.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: /home/dougj892/.npm/_logs/2023-08-09T20_41_56_897Z-debug-0.log
dougj892@DESKTOP-5O6RCRB:~/ai-getting-started$ npm install
npm ERR! code 1
npm ERR! path /home/dougj892/ai-getting-started/node_modules/hnswlib-node
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info find Python using Python version 3.10.12 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/dougj892/ai-getting-started/node_modules/hnswlib-node/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/dougj892/.cache/node-gyp/20.5.1/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/home/dougj892/.cache/node-gyp/20.5.1',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/home/dougj892/.cache/node-gyp/20.5.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/dougj892/ai-getting-started/node_modules/hnswlib-node',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: not found: make
npm ERR! gyp ERR! stack at getNotFoundError (/home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp/node_modules/which/which.js:10:17)
npm ERR! gyp ERR! stack at /home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp/node_modules/which/which.js:57:18
npm ERR! gyp ERR! stack at new Promise ()
npm ERR! gyp ERR! stack at step (/home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp/node_modules/which/which.js:54:21)
npm ERR! gyp ERR! stack at /home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp/node_modules/which/which.js:71:22
npm ERR! gyp ERR! stack at new Promise ()
npm ERR! gyp ERR! stack at subStep (/home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp/node_modules/which/which.js:69:33)
npm ERR! gyp ERR! stack at /home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp/node_modules/which/which.js:80:22
npm ERR! gyp ERR! stack at /home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/isexe/index.js:42:5
npm ERR! gyp ERR! stack at /home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/isexe/mode.js:8:5
npm ERR! gyp ERR! System Linux 5.15.90.1-microsoft-standard-WSL2
npm ERR! gyp ERR! command "/home/dougj892/.nvm/versions/node/v20.5.1/bin/node" "/home/dougj892/.nvm/versions/node/v20.5.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /home/dougj892/ai-getting-started/node_modules/hnswlib-node
npm ERR! gyp ERR! node -v v20.5.1
npm ERR! gyp ERR! node-gyp -v v9.4.0
npm ERR! gyp ERR! not ok

Beginner Help

Hi! I am new to this. I followed the instructions provided carefully. I just wanted to try out the basic QandA on the pre-provided blogs in the boilerplate. Everything runs on localhost:3000 and I can authenticate with Clerk. However, when I go to ask questions on the document, it just circles and hangs. There seems to be no response, and no errors thrown. I tried on Firefox and Chrome. Any ideas?

PineconeClient: Error calling upsert

Hi there @ykhli and @jenniferli23 ๐Ÿ‘‹๐Ÿผ

I'm an engineer at @replicatehq. I'm really excited about this project. Good idea to give people a starting point for building AI-powered apps. ๐Ÿ‘๐Ÿผ

I ran into the following issue while getting set up:

$ npm run generate-embeddings-pinecone

> [email protected] generate-embeddings-pinecone
> node src/scripts/indexBlogs.mjs

node:internal/process/esm_loader:97
    internalBinding('errors').triggerUncaughtException(
                              ^

[PineconeError: PineconeClient: Error calling upsert: PineconeError: PineconeClient: Error calling upsertRaw: FetchError: The request failed and the interceptors did not return an alternative response]

Node.js v18.13.0

I followed the README closely and I believe I have my env set up properly:

$ cat .env.local | grep PINECONE
PINECONE_API_KEY=772fXXXXXXXXXXXXXXXXXX
PINECONE_ENVIRONMENT=us-west1-gcp-free
PINECONE_INDEX=a16z-ai-getting-started

Did I miss something? ๐Ÿค”

Application Monitoring

Is there interest in adding an application monitoring solution such as Sentry (which can be self-hosted if you don't want to pay for Saas)? If so I can, spend some time adding it in.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.