Skip to content

Olshansk/langchain_explorations

Repository files navigation

Langchain Explorations

https://twitter.com/olshansky/status/1672827218563850240

Getting started

Prepare Your Secrets

  1. Get your OpenAI key from here; make sure you're logged in
  2. Get your PinconeAI key from here; make sure you're logged in
  3. Create an index called my-index or vitalik-index as showing here depending on which option you choose below
cp .streamlit/secrets.toml.template .streamlit/secrets.toml

Update the env vars appropriately.

Option 1: Vitalik Articles (default)

  1. Start the virtual environment and install the requirements:
$(make env_source)
make pip_install
  1. Download Vitalik's articles
make download_vitalik_articles
  1. Create the embeddings and upload them to Pinecone
make prepare_db
  1. Run it locally and ask a question:
make streamlit_app

Option 2: Your data (custom)

  1. Start the virtual environment and install the requirements:
$(make env_source)
make pip_install
  1. Get your pdfs and put them in ./data/my_data
    mv or cp or w/e floats your boat into `./data/my_data`

3.Prepare the database with your pdfs

# DATADIR and INDEX_NAME are customizable but you can start with the defaults if you don't know what you're doing yet
make prepare_db DATADIR=data/my_data INDEX_NAME=my-index
  1. Open up query_db.py and update prompt_template appropriately

  2. Run it locally and ask a question:

make streamlit_app

References & Resources

  1. Initial reference for this repo: https://blog.bytebytego.com/p/how-to-build-a-smart-chatbot-in-10
  2. Langchain docs: https://python.langchain.com/
  3. A full book I haven't read yet: https://www.pinecone.io/learn/langchain-intro/
  4. OpenAI API: https://beta.openai.com/docs/introduction

Startup Stack to easily productionize

Future Work / TODO / Improvements

  • Notion - Add support for pulling data from notion
  • Twitter - Use user tweet accounts to do this as well
  • OpenAI - Use the OpenAI Chat Completion API directly
  • Pinecone - Need to be able to update existing index

About

Olshansky exploring a long chain

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published