Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/$%7Bsuccess?q=function&page=1718&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=function

Returns an array of strings in format "username" or "username/projectName"

Found 19431 results for "function"(2444ms)

discordClerkWebhookHandlerExamplemain.tsx1 match

@maxm•Updated 1 year ago
3// # New Val Town User (on Clerk) -> Val Town Discord notification
4// Translates one kind of webhook (Clerk) into another (Discord)
5export async function handleDiscordNewUser(req: Request) {
6 // check custom auth secret sent from clerk
7 if (req.headers.get("auth") !== Deno.env.get("clerkNonSensitive"))

gptTagmain.tsx4 matches

@vladimyr•Updated 1 year ago
1import type { ChatCompletion, ChatCompletionCreateParamsNonStreaming, Message } from "npm:@types/openai";
2
3async function getOpenAI() {
4 // if you don't have a key, use our std library version
5 if (Deno.env.get("OPENAI_API_KEY") === undefined) {
12}
13
14function startChat(chatOptions: Omit<ChatCompletionCreateParamsNonStreaming, "messages"> & { system: string } = {
15 max_tokens: 30,
16 model: "gpt-3.5-turbo",
19 const { system, ...options } = chatOptions;
20
21 return async function gpt(strings, ...values) {
22 const openai = await getOpenAI();
23
40}
41
42// Initialize the gpt function with the system message
43const gpt = startChat({ system: "You are New Yorker cartoonist", max_tokens: 200, model: "gpt-4" });
44const answer = await gpt`Draw me cartoon depicting https://www.val.town user in their fighting TypeScript a-ha moment`;

sqliteDumpmain.tsx2 matches

@nbbaier•Updated 1 year ago
2import { sqlite } from "https://esm.town/v/std/sqlite";
3
4function generateInsertStatements(
5 tableName: string,
6 columns: string[],
20}
21
22export async function sqliteDump(
23 tables?: string[],
24 callback?: (result: string) => string | void | Promise<void>,

chatmain.tsx3 matches

@andreterron•Updated 1 year ago
1import type { ChatCompletion, ChatCompletionCreateParamsNonStreaming, Message } from "npm:@types/openai";
2
3async function getOpenAI() {
4 // if you don't have a key, use our std library version
5 if (Deno.env.get("OPENAI_API_KEY") === undefined) {
14/**
15 * Initiates a chat conversation with OpenAI's GPT model and retrieves the content of the first response.
16 * This function can handle both single string inputs and arrays of message objects.
17 * It supports various GPT models, allowing for flexibility in choosing the model based on the application's needs.
18 *
21 * @returns {Promise<string>} A promise that resolves to the content of the first response from the completion.
22 */
23export async function chat(
24 input: string | Message[],
25 options: Omit<ChatCompletionCreateParamsNonStreaming, "messages"> = {

chatREADME.md1 match

@andreterron•Updated 1 year ago
1# OpenAI ChatGPT helper function
2
3This val uses your OpenAI token if you have one, and the @std/openai if not, so it provides limited OpenAI usage for free.

blob_admin_homemain.tsx1 match

@stevekrouse•Updated 1 year ago
3import { css } from "https://esm.town/v/stevekrouse/sqlite_admin_css";
4
5export async function blob_admin_home() {
6 let blobs = await blob.list();
7 return (

emailExamplemain.tsx1 match

@maxm•Updated 1 year ago
2import { email } from "https://esm.town/v/std/email";
3
4export async function testEmail2(e: {
5 from: string;
6 to: string[];

unawaitedAsyncExamplemain.tsx1 match

@maxm•Updated 1 year ago
1export async function handle() {
2 // Schedule work to do later
3 (async () => {

fetchNewPublicGitHubReposmain.tsx1 match

@stevekrouse•Updated 1 year ago
1export default async function fetchNewPublicGitHubRepos() {
2 // Generate today's date in YYYY-MM-DD format
3 const today = new Date().toISOString().split("T")[0];

setmain.tsx1 match

@pomdtr•Updated 1 year ago
3import process from "node:process";
4
5export async function set(key: string, value: any) {
6 let resp = await fetch(
7 `${API_URL}/v1/vals`,

getFileEmail4 file matches

@shouser•Updated 3 weeks ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 3 weeks ago
Simple functional CSS library for Val Town
lost1991
import { OpenAI } from "https://esm.town/v/std/openai"; export default async function(req: Request): Promise<Response> { if (req.method === "OPTIONS") { return new Response(null, { headers: { "Access-Control-Allow-Origin": "*",
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.