Search

Results include substring matches and semantically similar vals. Learn more
andrewgao avatar
imgGenUrl
@andrewgao
URL to AI Image Source code credit: @maxm on val.town
HTTP
import { generateImage } from "https://esm.town/v/isidentical/falImageGen?v=11";
import { blob } from "https://esm.town/v/std/blob?v=12";
const genKey = (key: string): string => {
saolsen avatar
sqlite
@saolsen
This is a wrapper of the val town std sqlite library that adds tracing via https://www.val.town/v/saolsen/tracing.
Script
import { SpanStatusCode } from "https://cdn.skypack.dev/@opentelemetry/api";
import { type ResultSet, type TransactionMode } from "npm:@libsql/client";
import { InStatement, sqlite as std_sqlite } from "https://esm.town/v/std/sqlite?v=4";
import { get_tracer } from "https://esm.town/v/saolsen/tracing?v=136";
liamdanielduffy avatar
REACT_DOM_MINIFIED_PT2
@liamdanielduffy
// set by liamdanielduffy.buildReactDomMinified at 2023-06-01T12:04:43.610Z
Script
// set by liamdanielduffy.buildReactDomMinified at 2023-06-01T12:04:43.610Z
export let REACT_DOM_MINIFIED_PT2 = "}else\"/$\"===c&&b++}a=a.previousSibling}return null}function pb(a){var b=a[Da];\nif(b)r
vince avatar
isAchatOrVente
@vince
An interactive, runnable TypeScript val by vince
Script
type Side = "credit" | "debit";
type Result = "achat" | "vente" | "unknown";
filename: string;
side: Side;
const filename = payload.filename;
const side = payload.side;
let result: Result;
if (side === "credit") {
if (/^FA\d+\.pdf$/.test(filename)) {
result = "achat";
else if (side === "debit") {
if (/^AV\d+\.pdf$/.test(filename)) {
nbbaier avatar
draftReadme
@nbbaier
Code Documentation Assistant The Code Documentation Assistant is an AI-powered tool that helps generate documentation for code. It uses the OpenAI GPT-3.5 Turbo model to generate readme files in GitHub-flavored markdown based on the provided code. Usage Importing the Code Documentation Assistant import { draftReadme, writeReadme } from "code-doc-assistant"; Function: draftReadme async function draftReadme(options: WriterOptions): Promise<string> The draftReadme function generates a readme file based on the provided options. Parameters options (required): An object containing the following properties: username (string): The username of the code owner. valName (string): The name of the Val containing the code. model (optional, default: "gpt-3.5-turbo"): The OpenAI model to use for generating the readme. userPrompt (optional): Additional prompt to include in the documentation. Return Value A promise that resolves to a string representing the generated readme file. Function: writeReadme async function writeReadme(options: WriterOptions): Promise<string> The writeReadme function generates a readme file and updates the readme of the corresponding Val with the generated content. Parameters options (required): An object containing the following properties: username (string): The username of the code owner. valName (string): The name of the Val containing the code. model (optional, default: "gpt-3.5-turbo"): The OpenAI model to use for generating the readme. userPrompt (optional): Additional prompt to include in the documentation. Return Value A promise that resolves to a string indicating the success of the readme update. Example import { draftReadme, writeReadme } from "code-doc-assistant"; const options = { username: "your-username", valName: "your-val-name", }; const generatedReadme = await draftReadme(options); console.log(generatedReadme); const successMessage = await writeReadme(options); console.log(successMessage); License This project is licensed under the MIT License .
Script
import { fetch } from "https://esm.town/v/std/fetch?v=4";
import OpenAI, { type ClientOptions } from "npm:openai";
export interface WriterOptions extends ClientOptions {
username: string;
throw new Error("Error getting val code: " + error.message);
async function performOpenAICall(prompt: string, model: string, openaiOptions: ClientOptions) {
const openai = new OpenAI(openaiOptions);
rlesser avatar
sqliteTableExportUtils
@rlesser
SQLite Table Export Utils This allows for a val.town-hosted SQLite table to be exported as: JSON ( Record<string, unknown>[] ) Arrow IPC ( Uint8Array ) TODO: Others? This can then be used by a HTTP endpoint, like so: import { exportSQLiteTable, SQLiteTableExportFormat } from "https://esm.town/v/rlesser/sqliteTableExportUtils"; export default async function(req: Request): Promise<Response> { const tableName = new URL(req.url).searchParams.get("table"); if (!tableName) { return new Response("Table name is required", { status: 400 }); } const format = (new URL(req.url).searchParams.get("format") || "arrowIPC") as SQLiteTableExportFormat; const data = await exportSQLiteTable(tableName, format); if (data instanceof Uint8Array) { return new Response(data, { headers: { "Content-Type": "application/octet-stream" }, }); } else { return Response.json(data); } } TODO Specify limit and offset of export, for pagination Smart assessment of if the export is going to be over the val.town limit of 10MB, adjust to paginated of so. Support other export formats. PRs welcome!
Script
import { sqlite } from "https://esm.town/v/std/sqlite";
import { type ResultSet } from "npm:@libsql/client";
import { DataType, Float64, Int32, Table, tableToIPC, Utf8, vectorFromArray } from "npm:apache-arrow";
import { zip } from "npm:lodash-es@4.17.21";
nbbaier avatar
submitPR
@nbbaier
Submit a PR from Val Town This val provides a (very) thin wrapper around the GH rest API methods for creating a pull request. It handles the creation of a Octokit client for you. Usage import { submitPR } from "https://esm.town/v/nbbaier/submitPR"; await submitPR(Deno.env.get("GH_REPO_TOKEN"), { owner: "nbbaier", repo: "test-ground", head: "branch_2", base: "main", title: "trying another PR", body: "cool stuff, take a look", }); Parameters The function takes two parameters: your gh access token and an object that's identical to the object submitted to the gh API. See GH's documentation for more info!
Script
# Submit a PR from Val Town
PI methods for creating a pull request. It handles the creation of a Octokit client for you.
## Usage
jonbo avatar
dynamicSleep
@jonbo
Ever needed to fake a serverside delay? https://jonbo-dynamicsleep.web.val.run will return after 1 second. https://jonbo-dynamicsleep.web.val.run?seconds=5 will return after 5 seconds.
HTTP
Ever needed to fake a serverside delay?
https://jonbo-dynamicsleep.web.val.run will return after 1 second.
sboesen avatar
o1EmailHandler
@sboesen
Email AI Assistant Chat with your favorite AI via email (with PDF attachment support) What It Does This script allows you to: Send emails to OpenAI. The text will be treated as the prompt Parse PDF attachments and include their contents in the AI's analysis. Get response directly to your inbox. Setup guide Copy this Val and save it as an Email Val (choose Val type in top-right corner of editor) Add your OpenAI API key to line 8 (or use an environment variable: https://docs.val.town/reference/environment-variables/) Copy the email address of the Val (click 3 dots in top-right > Copy > Copy email address) Write your email, include any attachments, and send it to the Val email address. The AI will respond after a few seconds.
Email
prompt += `The email also includes the following PDF attachments:
${pdfTexts.map((pdf) => `Filename: ${pdf.filename}\nContent: ${pdf.text}`).join("\n\n")}
Please consider the content of these PDFs in your response if relevant.
prompt += `Now, write a response to ${senderName} that directly addresses their email. Be concise, friendly, and to the poi
return prompt;
pomdtr avatar
libsqlstudio_driver
@pomdtr
An interactive, runnable TypeScript val by pomdtr
Script
import { InStatement, ResultSet } from "https://esm.sh/@libsql/client";
import {
convertSqliteType,
robsimmons avatar
solution_getter_yes
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
import { Dusa } from "https://unpkg.com/dusa@0.1.6/lib/client.js";
const dusa = new Dusa(`
edge "a" "b".
campsite avatar
email_channel
@campsite
Email a Campsite channel This val creates an email address that posts forwarded emails to a Campsite channel. It uses GPT-4 to extract a readable version of the forwarded email from the raw body. If you don't want to use GPT-4, omit the OPENAI_API_KEY and the raw body will be included in the post. Other providers are available via Vercel's AI SDK . For help with creating integrations, check out the Campsite API docs . You'll need to create an integration and get an API key.
Email
import { createOpenAI } from "npm:@ai-sdk/openai";
import { generateObject } from "npm:ai";
import Campsite from "npm:campsite-client";
import { z } from "npm:zod";
// Required environment variables
maxm avatar
imgGenUrl
@maxm
Image generated from a path name powered by fal.ai https://maxm-imggenurl.web.val.run/firefly.jpg https://maxm-imggenurl.web.val.run/retro-computer-hacking.jpg https://maxm-imggenurl.web.val.run/100-yoyos-at-once.jpg
HTTP
import { generateImage } from "https://esm.town/v/isidentical/falImageGen?v=11";
import { blob } from "https://esm.town/v/std/blob?v=12";
const genKey = (key: string): string => {
stevekrouse avatar
populateTwitterDB
@stevekrouse
Poll Twitter & Populate SQlite database The twitter API (or in this case someone else's wrapper over the twitter API) is finicky, so we just try to get one handle per minute, and shove whatever we get into our database, which could be an error message (this is why handles don't have a unique index).
Script
export const populateTwitterDB = async () => {
let client = await turso({
url: process.env.tursoURL,
authToken: process.env.tursoToken,
let data = await client.execute(
"select twitter_id from twitter_users where twitter_handle is null limit 1",
console.log(handle);
return client.execute({
sql:
vtdocs avatar
supabaseSDKSelectMyFirstTable
@vtdocs
Selecting from a Supabase table using the SDK. Part of the Supabase guide on docs.val.town .
Script
import process from "node:process";
export const supabaseSDKSelectMyFirstTable = (async () => {
const { createClient } = await import(
"https://esm.sh/@supabase/supabase-js@2"
const supabase = createClient(
process.env.supabaseURL,
process.env.supabaseKey,