Go to file
2023-05-22 15:03:51 -06:00
components init 2023-05-20 16:29:17 -06:00
hooks init 2023-05-20 16:29:17 -06:00
pages update ui 2023-05-22 15:03:51 -06:00
scripts update ui 2023-05-22 15:03:51 -06:00
types init 2023-05-20 16:29:17 -06:00
utils adjusted code to work with pinecone 2023-05-20 18:57:40 -06:00
.env.example updated .env 2023-05-21 13:39:25 -06:00
.gitignore init 2023-05-20 16:29:17 -06:00
next.config.js init 2023-05-20 16:29:17 -06:00
package-lock.json added dotenv 2023-05-21 13:27:15 -06:00
package.json added dotenv 2023-05-21 13:27:15 -06:00
README.md improved docs and code 2023-05-20 20:02:26 -06:00
tsconfig.json init 2023-05-20 16:29:17 -06:00

Research Project Creating AI Ravikant

This is a weekend project where I learned how to use open ai chatbot, langchain-js, elevenlabs, prompt engineering & using extra information like books to improve the experience when talking to chatbot.

I used the book, "ALMANACK OF NAVAL RAVIKANT" to create a vector database and index the data.

This project is not related to real Naval Ravikant and is a research project only

The way this app works is when the user asks a question, we look through the vector database and provide 4 most relevant context snippets from the book that are each 2,000 characters long and send it to open ai as additional context so that it can provide a better response

For more content, you can follow me on twitter here

Setup

  1. Grab an openai api key from here and add it to your .env file that you will want to create in root folder
  2. Grab an ElevenLabs api key from here and add it to your .env file
  3. Clone a voice with ElevenLabs and add the model id to your .env file
  4. Hit npm install to grab the necessary packages
  5. Go to pinecone and create an index with these parameters:
  • euclidian algo
  • 1536 dimensions

When you finish that, you need to add vars with those values PINECONE_ENVIRONMENT=, PINECONE_API_KEY= and PINECONE_INDEX={name of index you created}

  1. If you don't have ts-node or pdf-parse installed, please install globally so you can run script to add indexing to pinecone

npm install -g ts-node pdf-parse

  1. I ran the script to add indexing to pinecone ts-node scripts/createIndex.ts. Feel free to adjust it for your needs. You can use all kinds of file types including txt, pdf, etc.

  2. Run npm run dev to start your server on http://localhost:3000

Deploy to the world

  1. Push all your changes to Github (or another git provider)
  2. Head to vercel.app, import your repo, and hit deploy
  3. Go to settings of the deployment, add your .env, and rebuild

Other Useful Notes

  1. Langchain docs: https://js.langchain.com/docs/
  • great documentation for interacting with pinecone
  1. When setting up eleven labs, you need to configure voices to get the proper ELEVENLABS_VOICE_ID
  1. Open AI has rate limits. This repo is using open ai 3.5. if you have access to 4.0, you can switch the model!

To properly configure open ai for best experience, refer to deep learning course. Specifically I used chapter 8

  1. Open AI does a fairly good job with translating but it's not perfect. Here is another provider for more precise translation:

More docs

To Do

  • update voice
  • rename api