Momento Vector Index example for handson using Python, LangChain, OpenAI and Streamlit.
This repository is originally made for ServerlessDays Tokyo 2023 Momento Hands-on Workshop
- RAG(Retrieval Augmented Generation) web app.
- Getting embeddings(vector data) from local file using OpenAI Embeddings API.
- Hosted the vector data to Momento Vector Index and retrieve from it.
- Cached the Q&A histories to Momento Cache.
- Answer generated using OpenAI.
- UI was created using Streamlit.
- Copy
.env.template
to.env
. - Get and fill the API key to
MOMENTO_AUTH_TOKEN
andOPENAI_API_KEY
in.env
. - Change the source data in
data/sample.txt
. - Create virtual environment
curl https://pyenv.run | bash
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
exec "$SHELL"
pyenv --version
sudo yum remove -y openssl-devel
sudo yum install -y openssl11-devel bzip2-devel xz-devel
pyenv install 3.10
pyenv local 3.10
rm -rf .venv
python3 -m venv .venv
. .venv/bin/activate
- Install the libraries.
$ pip install -r requirements.txt
- Generate vector data
python insert.py
- Run streamlit, Access to
http://localhost:8051
and ask sometiong about your data
streamlit run app.py
- Delete vector data
python delete.py
You are welcome to discuss it on our discord.