Skip to content

Instantly share code, notes, and snippets.

View rowntreerob's full-sized avatar

robert rowntree rowntreerob

  • san francisco, ca.
View GitHub Profile
@rowntreerob
rowntreerob / getSrc.js
Last active March 22, 2024 20:17
NYT bookmark for audio.src
(function() {
const url = document.querySelector("audio").src
const url2="http://localhost:8501?url=" +url
if(confirm(url)) {
window.location.href = url2
}
})();
@rowntreerob
rowntreerob / transcribeMp3.py
Last active March 22, 2024 20:28
streamlit - mp3-to-transcription
import streamlit as st
from streamlit_extras.stylable_container import stylable_container
from dotenv import load_dotenv
from deepgram import (
DeepgramClient,
ClientOptionsFromEnv,
PrerecordedOptions,
)
import os
st.title('audioToText+🫶')
@rowntreerob
rowntreerob / httpProxy-openai.js
Created November 27, 2023 22:44
proxy openai-api.requests so a class has access without needing their own api keys
'use strict'
/*
* students / class post everything to this domain (including path intended for openai
* this acts as reverse proxy with proper open api token value applied
* responses flow back to original client
*/
import express from 'express'
var app = express();
import httpProxy from 'http-proxy'
var apiProxy = httpProxy.createProxyServer();
@rowntreerob
rowntreerob / install.md
Last active December 6, 2023 18:14
install hackathon project - where a proxy will hide/inject openai api key value

Interesting project from recent SF AI conference Hackathon implements internal GPTs along with media uploads, providing accessible AI / GPT code. Not a complex project and can be run on streamlit with some small mods to finesse the student access to secure openAI key issue. Proxy is used to swap an easily acquired proxy-token for much harder to get api key on openai.
A second project detailed below at the hosted proxy link makes it possible for students to sign up, getting a token that is used as a front-end call in place of native calls on the openai API. This is an example of a reverse proxy sitting in front of a protected resource, which openai API is until you have a working api key.
Get started by following instructions below:

create python virtual environment for this project & this app

conda creat
@rowntreerob
rowntreerob / myfile.md
Created June 9, 2023 14:59
cloudImages

List of images

Implement storage with URL for images to be referred to in Jupyter notebooks

@rowntreerob
rowntreerob / chat_js_fetch_resp_updt_dom.html
Created May 25, 2023 21:05
ask chat gpt to consume fetch.post.response w DOM updt based on data.fields in the response
<!DOCTYPE html><html class="light"><head> <meta charset="utf-8"/> <title>Chat GPT: </title> <meta name="generator" content="chatGPT Saving Bookmark"/><style>html.dark { background-color: rgb(32,33,35); color: rgb(236,236,241);}html.light { background-color: white; color: rgb(52,53,65);}body { font-size: 16px; font-family: sans-serif; line-height: 28px; margin: 0;}body > .w-full { padding: 30px;}.flex { display: flex; max-width: 100%;}.m-auto { margin: auto;}.text-base { max-width: 50rem;}.gap-1 { gap: 0.25rem;}/* model name */.justify-center { justify-content: center;}.items-center { align-items: center;}.w-4 { width: 1rem;}.h-4 { height: 1rem;}/* prompt */.dark body > .w-full:nth-of-type(2n+1) { background: rgb(52,53,65);}/* response */.dark body > .w-full:nth-of-type(2n+2) { background: rgb(68,70,84);}.light body > .w-full:nth-of-type(2n+2) { background: rgb(247,247,248);}.light body > .w-full { border-bottom: 1px solid rgba(0,0,0,.1);}a, a:visited { color: #7792cd;}pre { margin
@rowntreerob
rowntreerob / transformers-complex-neural-learning.html
Last active May 19, 2023 15:00
mml model vs algorithm debate on chatgpt training
<!DOCTYPE html><html class="light"><head> <meta charset="utf-8"/> <title>Chat GPT: Transformers: Complex Neural Learning</title> <meta name="generator" content="chatGPT Saving Bookmark"/><style>html.dark { background-color: rgb(32,33,35); color: rgb(236,236,241);}html.light { background-color: white; color: rgb(52,53,65);}body { font-size: 16px; font-family: sans-serif; line-height: 28px; margin: 0;}body > .w-full { padding: 30px;}.flex { display: flex; max-width: 100%;}.m-auto { margin: auto;}.text-base { max-width: 50rem;}.gap-1 { gap: 0.25rem;}/* model name */.justify-center { justify-content: center;}.items-center { align-items: center;}.w-4 { width: 1rem;}.h-4 { height: 1rem;}/* prompt */.dark body > .w-full:nth-of-type(2n+1) { background: rgb(52,53,65);}/* response */.dark body > .w-full:nth-of-type(2n+2) { background: rgb(68,70,84);}.light body > .w-full:nth-of-type(2n+2) { background: rgb(247,247,248);}.light body > .w-full { border-bottom: 1px solid rgba(0,0,0,.1);}a, a:vis
@rowntreerob
rowntreerob / gpt-debt-doom-loop-simulation.html
Created May 14, 2023 18:39
US govt debt - debate over sustainability
<!DOCTYPE html> <html class="light"> <head> <meta charset="utf-8"/> <title>Chat GPT: Debt Doom Loop Simulation.</title> <meta name="generator" content="chatGPT Saving Bookmark"/> <style> html.dark { background-color: rgb(32,33,35); color: rgb(236,236,241); } html.light { background-color: white; color: rgb(52,53,65); } body { font-size: 16px; font-family: sans-serif; line-height: 28px; margin: 0; } body > .w-full { padding: 30px; } .flex { display: flex; max-width: 100%; } .m-auto { margin: auto; } .text-base { max-width: 50rem; } /* prompt */ .dark body > .w-full:nth-child(2n+1) { background: rgb(52,53,65); } /* response */ .dark body > .w-full:nth-child(2n+2) { background: rgb(68,70,84); } .light body > .w-full:nth-child(2n+2) { background: rgb(247,247,248); } .light body > .w-full { border-bottom: 1px solid rgba(0,0,0,.1); } a, a:visited { color: #7792cd; } pre { margin: 0 0 1em 0; display: block; } pre code.hljs { margin-bottom: 1em; border-radius: 5px; }
/* once a bookmarklet has done the dom manipulation and created html to preserve the chatgpt,
the html can be posted to a separate service that implements the gist api for create
*/
app.use(express.raw({
inflate: true,
limit: '9mb',
type: 'text/html'}))
// type: 'application/octet-stream'}))
app.options('/chatgpt', cors());
app.post('/chatgpt/:fname',
//routes w streams MUST be above this !! content type application/octet-stream
// client side posted photo as http w binary request.body (no form, just the file)
// middleware pushes inbound http readstream to an obj in .body
app.use(express.raw({
inflate: true,
limit: '9mb',
type: 'application/octet-stream'}))
// path or route chosen by client upload is "labelai" && fileName of <img>
app.options('/labelai', cors());
app.post('/labelai/:fname',