In this presentation we'll create some poems about Star Wars characters. For the final act, we'll build a vector database from a Wookieepedia site dump, and then query it with RAG.
- AWS account with Bedrock and some models enabled
- AWS SSO (if you don't have this, use regular old AWS CLI auth. See the docs for help.)
- node 20 / npm
- 7zip
npm install
- Create a dotenv file:
touch .env && echo AWS_PROFILE={your AWS profile name} >>.env && echo AWS_DEFAULT_REGION={your AWS region} >>.env
- Log in to your preferred AWS account:
aws sso login
- Create the Wookieepedia vector database:
mkdir data
- download into /data from https://starwars.fandom.com/wiki/Special:Statistics (database dumps)
- Unzip with 7zip
- Extract with https://github.com/attardi/wikiextractor
node act3-preload.mjs
You'll need to comment out the kill switch first. This takes several hours, and you'll spend about $6 on Bedrock embeddings. You could also run Ollama or similar locally instead of using Bedrock.
There are usage examples at the top of each act*.mjs
script. The /refs
dir contains reference copies of several of the act*.mjs
scripts with extra stuff commented out, so you can easily copy/paste it in during your demo.
node act1.mjs
- Change Yoda to Darth Vader
- Change haiku to sonnet -> see maxTokens gotcha! (Then add maxTokens prop.)
- Change temperature
- Change model (copy/paste from refs/act1.mjs)
- Demo debugging with
LANGCHAIN_VERBOSE=true
env var
node act2.mjs "Yoda"
- Play around with different voices
- Demo LangChain step debugging (copy/paste from refs/act2.mjs)
- Show alternate output parser:
node act2-1.mjs "Yoda"
- Uncomment parser instructions to see what gets passed to the prompt
node act3.mjs "What color is Yoda?"
- Change model
- Show the more detailed version of the chain (copy/paste from refs/act3.mjs)
- Final question: "Who shot first?"