• iamseeley avatar
    tokenBucket
    @iamseeley
    An interactive, runnable TypeScript val by iamseeley
    Script
  • rlimit avatar
    ratelimit
    @rlimit
    rlimit.com - rate-limiting as a service This val abstracts rlimit.com service and allows val.town users to enjoy simple rate-limiting for their vals. Using @rlimit.ratelimit users can benefit out of a special free tier without signing up for rlimit.com account. If anyone require more than what free tier has to offer, they just sign up and pass their namespace ID created in the rlimit.com dashboard. Usage Following val example will limit calling val to 10 requests per 60s. let limitedVal = (async () => { const limit = await @rlimit.ratelimit("10/1m"); if (!limit.ok) { throw new Error("limit reached"); } console.log("limit ok", limit); // continue with expensive operation })(); A couple of examples link to val1 link to val2
    Script
  • stevekrouse avatar
    openai
    @stevekrouse
    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);
    Script
1
Next
May 27, 2024