Become an expert, build a following, and gain financial independence.
by Nathan Barry
Table of Contents
Become an expert, build a following, and gain financial independence.
by Nathan Barry
Table of Contents
This is a quick example showing how to use regexes to find tri-grams in Shakespeare...well, 570,872 of them, anyway, if we do some basic filtering of non-dialogue.
Though tokenization and n-grams should typically be done using a proper natural language processing framework, it's possible to do in a jiffy from the command-line, using standard Unix tools and ack, the better-than-grep utility.
#!/bin/bash | |
OPENAI_API_KEY="YOUR_API_KEY" | |
CONVERSATION="/tmp/$(cat /proc/sys/kernel/random/uuid)" | |
query_open_ai() { | |
curl -s https://api.openai.com/v1/chat/completions \ | |
-H "Content-Type: application/json" \ | |
-H "Authorization: Bearer $OPENAI_API_KEY" \ | |
-d "{ |