stevekrouse
mayor of val town
Public vals
779
stevekrouse
openai
Script
OpenAI ChatGPT helper function This val uses your OpenAI token if you have one, and the @std/openai if not, so it provides limited OpenAI usage for free. import { chat } from "https://esm.town/v/stevekrouse/openai";
const { content } = await chat("Hello, GPT!");
console.log(content); import { chat } from "https://esm.town/v/stevekrouse/openai";
const { content } = await chat(
[
{ role: "system", content: "You are Alan Kay" },
{ role: "user", content: "What is the real computer revolution?"}
],
{ max_tokens: 50, model: "gpt-4o" }
);
console.log(content);
1
stevekrouse
devNull
Script
Dev Null A JS function and API inspired by /dev/null that will throw away whatever you send it and return null . Function usage @stevekrouse.devNull("useless data") API Usage https://api.val.town/v1/run/stevekrouse.devNull?args=[%22useless%20data%22] Why? Honestly I don't know why you'd use this function. I just made it as a joke to link to it from @stevekrouse.dm . I guess you could also use it a joke to send data you want to call attention to the fact that you very much don't care about it, ie I really don't care about the price of bitcoin: @stevekrouse.devNull(await @stevekrouse.currency("usd", "btc"))
0
stevekrouse
dm
Script
DM Me! Ever wanted to message someone about their val but you couldn't find their contact info? Want to allow folks on Val Town to contact you without exposing your email address? Boy do I have the over-engineered solution for you! This is a userspace, authenticated protocol for Val Town direct messages. Protocol Expose a dm function on your namespace that that accepts messages and some authentication data (described below). The easiest way to accomplish this is to fork this val. What you choose to do with direct messages is totally up to you. At the moment, I email myself your message and save it to a private array val. You could forward it along to yourself some other way, batch up messages to get a daily summary email if you're Mr. Popular, or send them to /dev/null if you're Mr. Antisocial. Authentication This protocol uses my Val Town public key auth scheme , so you'll need to follow the first two steps of that blog post – (1) generate a keypair and (2) publish your public key – to authenticate to this function. Usage You can call this function via the @stevekrouse.runValAPIAuth helper: @stevekrouse.runValAPIAuth({
val: "@stevekrouse.dm",
args: ["hi steve!"],
keys: @me.exportedKeys,
}); Example: https://www.val.town/v/stevekrouseTest.untitled_tealMinnow
0