Search

Results include substring matches and semantically similar vals. Learn more
petermillspaugh avatar
retrievalPractice
@petermillspaugh
@jsxImportSource https://esm.sh/react
Script
/** @jsxImportSource https://esm.sh/react */
import { generateLessonHtml } from "https://esm.town/v/petermillspaugh/lessonTemplate";
import { renderToString } from "npm:react-dom/server";
* Work-in-progress! πŸ‘·β€β™‚οΈ
const TITLE = "Retrieval practice";
pomdtr avatar
OpenAI
@pomdtr
OpenAI Get started using OpenAI's chat completion without the need to set your own API keys. Usage Here's a quick example to get you started with the Val Town OpenAI wrapper: import { OpenAI } from "https://esm.town/v/std/openai"; const openai = new OpenAI(); const functionExpression = await openai.chat.completions.create({ "messages": [ { "role": "user", "content": "Say hello in a creative way" }, ], model: "gpt-4", max_tokens: 30, }); console.log(functionExpression.choices[0].message.content);
Script
import { type ClientOptions, OpenAI as RawOpenAI } from "npm:openai";
* API Client for interfacing with the OpenAI API. Uses Val Town credentials.
private rawOpenAIClient: RawOpenAI;
* API Client for interfacing with the OpenAI API. Uses Val Town credentials.
[opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing ou
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as i
constructor(options: Omit<ClientOptions, "baseURL" | "apiKey" | "organization"> = {}) {
this.rawOpenAIClient = new RawOpenAI({
return this.rawOpenAIClient.chat;
boucher avatar
pwa
@boucher
Add a pwa manifest to an http val (to open in as an app in iOS). See https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps for available fields. Usage import handler from "https://esm.town/v/maxm/staticChess"; import { pwa } from "https://esm.town/v/pomdtr/pwa"; export default pwa(handler, { name: "Static Chess", display: "standalone", background_color: "#ffffff", start_url: "/", });
Script
launch_handler?: {
client_mode: LaunchHandlerClientMode | LaunchHandlerClientMode[]
learn.microsoft.com/en-us/microsoft-edge/progressive-web-apps-chromium/how-to/sidebar#enable-sidebar-support-in-your-pwa
edge_side_panel?: {
preferred_width?: number
* @see https://developer.mozilla.org/en-US/docs/Web/Manifest/launch_handler#launch_handler_item_values
export type LaunchHandlerClientMode = 'auto' | 'focus-existing' | 'navigate-existing' | 'navigate-new'
export type Display = 'fullscreen' | 'standalone' | 'minimal-ui' | 'browser'
pvh avatar
watcher
@pvh
set up Automerge's internal wasm guts manually
Cron
import { discordWebhook } from "https://esm.town/v/pvh/discordWebhook";
import { BrowserWebSocketClientAdapter } from "npm:@automerge/automerge-repo-network-websocket";
import { isValidAutomergeUrl, Repo } from "npm:@automerge/automerge-repo/slim";
/* set up Automerge's internal wasm guts manually */
await automerge.next.initializeBase64Wasm(automergeWasmBase64);
export default async function() {
const repo = new Repo({ network: [new BrowserWebSocketClientAdapter("wss://sync.automerge.org")] });
const listHandle = repo.find("3NUkYztG95r7cc8uvmyGgW7KkK9j");
const listDoc = await listHandle.doc();
wangqiao1234 avatar
OpenAI
@wangqiao1234
OpenAI - Docs β†— Use OpenAI's chat completion API with std/openai . This integration enables access to OpenAI's language models without needing to acquire API keys. For free Val Town users, all calls are sent to gpt-3.5-turbo . Streaming is not yet supported. Upvote the HTTP response streaming feature request if you need it! Usage import { OpenAI } from "https://esm.town/v/std/openai"; const openai = new OpenAI(); const completion = await openai.chat.completions.create({ messages: [ { role: "user", content: "Say hello in a creative way" }, ], model: "gpt-4", max_tokens: 30, }); console.log(completion.choices[0].message.content); Limits While our wrapper simplifies the integration of OpenAI, there are a few limitations to keep in mind: Usage Quota : We limit each user to 10 requests per minute. Features : Chat completions is the only endpoint available. If these limits are too low, let us know! You can also get around the limitation by using your own keys: Create your own API key on OpenAI's website Create an environment variable named OPENAI_API_KEY Use the OpenAI client from npm:openai : import { OpenAI } from "npm:openai"; const openai = new OpenAI(); πŸ“ Edit docs
Script
3. Use the `OpenAI` client from `npm:openai`:
import { type ClientOptions, OpenAI as RawOpenAI } from "npm:openai";
* API Client for interfacing with the OpenAI API. Uses Val Town credentials.
private rawOpenAIClient: RawOpenAI;
* API Client for interfacing with the OpenAI API. Uses Val Town credentials.
[opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing ou
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as i
constructor(options: Omit<ClientOptions, "baseURL" | "apiKey" | "organization"> = {}) {
this.rawOpenAIClient = new RawOpenAI({
return this.rawOpenAIClient.chat;
nbbaier avatar
saveToTana
@nbbaier
Save To Tana This val provides a function saveToTana allows the creation of nodes in Tana via their Input API . The parameters are as follows: Token: to access the Tana Input API, you must pass an API token to the function. Obtain an API token from the Tana app and save it as a secret in Val Town. Node: the node that is created within Tana is passed as the second argument and must conform to the shape of an Input API node (see the documentation on github for details. Target node: optionally, you can specify a specific target node by passing a node ID to the function as it's third argument. Example Usage One way to use this val is with a web endpoint that you can send data to to have parsed and submitted to Tana as a specific type of node. For example, this val import { saveToTana } from "https://esm.town/v/nbbaier/saveToTana"; import { APIPlainNode } from "https://esm.town/v/nbbaier/tanaTypes"; import { Hono } from "npm:hono"; const token = Deno.env.get("tanaInputAPI"); export const honoTanaEndpoint = async (req: Request) => { const app = new Hono(); app.get("/", async c => { let { text, url } = c.req.query(); const payload: APIPlainNode = { name: text, children: [ { type: "field", attributeId: "cwi23sOzRSh8", children: [ { dataType: "url", name: url, }, ], }, ], supertags: [], }; const newNode = await saveToTana(token, payload); return c.json({ newNode }); }); return app.fetch(req); }; Combined with a Chrome extension like Rich URL , the above val allows one to send selected text on a page along with that pages URL to Tana via the val's public GET endpoint.
Script
node: APIPlainNode,
targetNodeId: string = tanaConstants.inboxNodeId,
const client = new TanaAPIHelper(token);
const createdNode = await client.createNode(node, targetNodeId);
return createdNode;
pattysi avatar
OpenAI
@pattysi
OpenAI - Docs β†— Use OpenAI's chat completion API with std/openai . This integration enables access to OpenAI's language models without needing to acquire API keys. Streaming is not yet supported. Upvote the HTTP response streaming feature request if you need it! Usage import { OpenAI } from "https://esm.town/v/std/openai"; const openai = new OpenAI(); const completion = await openai.chat.completions.create({ messages: [ { role: "user", content: "Say hello in a creative way" }, ], model: "gpt-4", max_tokens: 30, }); console.log(completion.choices[0].message.content); Limits While our wrapper simplifies the integration of OpenAI, there are a few limitations to keep in mind: Usage Quota : We limit each user to 10 requests per minute. Features : Chat completions is the only endpoint available. If these limits are too low, let us know! You can also get around the limitation by using your own keys: Create your own API key on OpenAI's website Create an environment variable named OPENAI_API_KEY Use the OpenAI client from npm:openai : import { OpenAI } from "npm:openai"; const openai = new OpenAI(); πŸ“ Edit docs
Script
3. Use the `OpenAI` client from `npm:openai`:
import { type ClientOptions, OpenAI as RawOpenAI } from "npm:openai";
* API Client for interfacing with the OpenAI API. Uses Val Town credentials.
private rawOpenAIClient: RawOpenAI;
* API Client for interfacing with the OpenAI API. Uses Val Town credentials.
[opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing ou
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as i
constructor(options: Omit<ClientOptions, "baseURL" | "apiKey" | "organization"> = {}) {
this.rawOpenAIClient = new RawOpenAI({
return this.rawOpenAIClient.chat;
byrneml avatar
unsplashF
@byrneml
An interactive, runnable TypeScript val by byrneml
Script
`https://api.unsplash.com/photos`,
headers: {
"Authorization": `Client-ID ${unsplashAccessToken}`,
nerdymomocat avatar
add_to_notion_from_todoist
@nerdymomocat
Use todoist for quick notes to add to notion. Uses project to decide which project to fetch to add stuff to notion. Can add to page or database based on config below. Demarkation using sections in the todoist project. Extracts date for page blocks that are added as callouts.
Cron
import process from "node:process";
import { TodoistApi } from "npm:@doist/todoist-api-typescript";
import { Client } from "npm:@notionhq/client";
const TODOIST_API_KEY = process.env.TODOIST_API_KEY;
const todoistapi = new TodoistApi(TODOIST_API_KEY);
const NOTION_API_KEY = process.env.NOTION_API_KEY;
const notion = new Client({
auth: NOTION_API_KEY,
var add_to_notion_todoist_project_id = "PROJECT_ID_HERE";
inkpotmonkey avatar
instructorExample
@inkpotmonkey
Example copied https://instructor-ai.github.io/instructor-js/#usage into val.town You will need to fork this and properly set the apiKey and organisation for it to work.
Script
const oai = new OpenAI(openAISecrets);
const client = Instructor({
client: oai,
mode: "FUNCTIONS",
// User will be of type z.infer<typeof UserSchema>
const user = await client.chat.completions.create({
messages: [{ role: "user", content: "Jason Liu is 30 years old" }],
mattx avatar
faunadb_test
@mattx
An interactive, runnable TypeScript val by mattx
Script
export const faunadb_test = (async () => {
const { faunadb } = await import("npm:faunadb");
const client = new faunadb.Client({
secret: process.env.fauna_key,
const { Get, Ref, Collection } = faunadb.query;
// from included sample data
const result = await client.query(Get(Ref(Collection("products"), "202")));
return result;
std avatar
sqlite
@std
SQLite - Docs β†— SQLite is a lightweight, standard database. Every Val Town account comes with its own private SQLite database that is accessible from any of your vals via std/sqlite . Val Town SQLite is powered by Turso . Usage Migrations ORMs You may find these admin viewers helpful managing your database: SQLite Explorer (built in Val Town) LibSQL Studio Limits You can store 10mb on the free plan and up to 1gb on the paid plan. Contact us if you need more space. πŸ“ Edit docs
Script
import { API_URL } from "https://esm.town/v/std/API_URL";
import { LibsqlError, type TransactionMode } from "npm:@libsql/client";
import { z } from "npm:zod";
* Every Val Town account comes with its own private
pps avatar
sqlitePublic
@pps
An interactive, runnable TypeScript val by pps
HTTP (deprecated)
import { createSqlite } from "https://esm.town/v/postpostscript/sqliteWasm";
import type { InStatement } from "https://esm.town/v/std/sqlite";
import { type ResultSet } from "npm:@libsql/client";
import { Hono } from "npm:hono";
const dumped = {};
apppeak avatar
notionRecurringTasks
@apppeak
An interactive, runnable TypeScript val by apppeak
Cron
import process from "node:process";
import { Client } from "npm:@notionhq/client";
import dayjs from "npm:dayjs";
const DATABASE_ID = "519446a0d3ed47038fffd669b9ece770";
const notion = new Client({ auth: process.env.NOTION_API_KEY });
const intervalMapping = {
"Weekly": (date) => dayjs(date).add(1, "week"),
jacoblee93 avatar
chatAgentWithCustomPrompt
@jacoblee93
An interactive, runnable TypeScript val by jacoblee93
Script
new Calculator(),
const executor = await initializeAgentExecutorWithOptions(tools, model, {
agentType: "chat-zero-shot-react-description",
verbose: true,
agentArgs: {