Coder Social home page Coder Social logo

chatbot's Introduction

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

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.