I’ll be posting guides to my projects here. If you’ve any particular request, feel free to DM me on twitter.
1. Readwise Filter Generator
Made using GPT-3, Streamlit. Streamlit is great if you don’t want to waste time making the frontend for your demo/project.
I am posting the code and the prompt (which you can paste in the GPT-3 playground to generate filters on your own).
Code
import openai
import urllib.parse
import streamlit.components.v1 as components
import streamlit as st
openai.api_key = st.secrets["OPENAI_API_KEY"]
col1, col2, col3 = st.columns([1,5,1])
with col2:
st.subheader('🦾 Readwise Filter Generator')
rules= '''this was long, I posted it below separately '''
# @st.cache
def prompt_builder(prompt):
response = openai.Completion.create(
model="text-davinci-003",
prompt = prompt,
temperature=0.7,
max_tokens=120,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
return response
form = st.form(key='my_form')
# @st.cache
query = form.text_input(label='What do you want to read? (see examples below)')
submit_button = form.form_submit_button(label='Generate Filter')
if submit_button:
prompt = rules + query + "\nFilter Query:"
prompt_response = prompt_builder(prompt)
filter_string = prompt_response["choices"][0]["text"].lstrip()
url = "https://read.readwise.io/filter/" + urllib.parse.quote(prompt_response["choices"][0]["text"].lstrip())
st.code(filter_string)
st.markdown(f''' <a href={url}><button style="background-color:black;color:white;border-radius:5px">
📖 Open in Readwise Reader</button></a>''', unsafe_allow_html=True)
Prompt
This is the text for the “rules” string mentioned above. You can paste this in OpenAI playground, write your command after “Command:”
These are the rules for making Filters in a Reading app:
Date Parameters
- last_status
- saved
- last_opened
- published
- You can use both absolute and relative dates eg 2022-03-20 or "1 year ago"
String Parameters
- tag
- domain
- category or type
- rss_source
- author
- location or in
- title
- saved_using (eg instapaper or pocket)
Binary Parameters
- feed
- seen (eg seen:true)
- unseen
Numerical Parameters
- words
- progress
- highlights or has:highlights or has:tags or has:notes
- minutes
- progress
- saved_count
Operators
- You add these double underscore operators to other parameters above to modify them
- By default, a : will fuzzy search
- __gt (greater than)
- __lt (less than)
- __gte (greater than or equal to)
- __lte (less than or equal to)
- __contains
- __exact
- __before
- __after
- __not
Some examples Filter Queries based on above filtering rules:
Command: Show me all documents tagged shortlist and not already archived
Filter: tag:shortlist AND (in:inbox OR in:later)
Command: Show me all documents shorter than 10 minutes and in Later
Filter: minutes__lt:10 AND in:later
Command: Show me all the new, unseen documents from my favorite RSS feeds
Filter: feed:true AND opened:false AND (domain:"poppingtins" OR domain:"constructionphysics" OR domain:"eugenewei" OR OR domain:"ribbonfarm" OR domain:"perell" OR domain:"sirupsen" OR domain:"florentcrivello" OR domain:"cdixon" OR domain:"fortelabs" OR domain:"kwokchain" OR domain:"zackkanter" OR domain:"andrewchen" OR domain:"notboring")
Command: Show me all documents that I’ve started reading in the past week but haven’t archived
Filter: progress__gt:5 AND last_opened__after:"1 week ago" AND in__not:archive
Command: show all docs longer than 1000 words
Filter: words__gt:1000
Command: Show me all documents from my Instapaper account that I haven’t read yet
Filter: saved_using:instapaper AND opened:false
Command: Show me all documents from the last month that are longer than 5 mins and have highlights
Filter: last_opened__after:"1 month ago" AND minutes__gt:5 AND has:highlights
Command: Show me all docs with the category news that I have not read yet and are from the last year
Filter: type:news AND opened:false AND last_opened__after:"1 year ago"
Command: All stuff saved in past 8 days
Filter: saved__after:"8 days"
Command: substack articles about AI from past 5 months in shortlist
Filter: domain:substack AND published__after:"35 days ago" AND title__contains:AI
Command: articles by Paul Graham in last 4 months
Filter: author:Paul Graham AND published__after:"4 months ago"
Command:
2. Substack Recommendations System
Coming soon…