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/image-url.jpg%20%22Optional%20title%22?q=function&page=1806&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 18895 results for "function"(1711ms)

searchTweetsmain.tsx1 match

@andreterron•Updated 1 year ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export async function searchTweets({ accessToken, query, params }: {
4 accessToken: string;
5 query: string;

myApimain.tsx1 match

@triggatron•Updated 1 year ago
1export function myApi(name) {
2 return "hi " + name;
3}

analysisTransactionmain.tsx1 match

@j1ang•Updated 1 year ago
1export function analysisTransaction(req: express.Request, res: express.Response) {
2 console.log(req.body);
3 res.end("Handle Webhook Success");

postToMastodonmain.tsx1 match

@sebdd•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export function postToMastodon(mastodonApiUrl, mastodonAccessToken, status) {
4 return fetch(
5 `${mastodonApiUrl}/statuses?access_token=${mastodonAccessToken}`,

kaiterra_prometheusmain.tsx2 matches

@tehmantra•Updated 1 year ago
2
3// Fetches air quality sensor data from Kaiterra in prometheus line format
4export async function kaiterra_prometheus(
5 req: express.Request,
6 res: express.Response,
13 let prometheus_data = kiosk_data.indoor.flatMap((indoor_data) =>
14 indoor_data.data.flatMap((data) =>
15 data.points.flatMap(function (point) {
16 let timestamp = new Date(point.ts).getTime();
17 let param_name = data.param.replace("-", "_");

chatSampleFunctionSinglemain.tsx14 matches

@webup•Updated 1 year ago
2import { schemasWeather } from "https://esm.town/v/webup/schemasWeather";
3
4export const chatSampleFunctionSingle = (async () => {
5 // Example dummy function hard coded to return the same weather
6 // In production, this could be your backend API or an external API
7 const getCurrentWeather = (location, unit = "fahrenheit") => ({
11 forecast: ["sunny", "windy"],
12 });
13 // Step 1: send the conversation and available functions to GPT
14 const messages = [{
15 "role": "user",
17 "What's the weather like in Boston, and what's the weather in Huston?",
18 }];
19 const functions = [schemasWeather[0]];
20 const response = await chat(messages, {
21 functions,
22 function_call: "auto", // auto is default, but we'll be explicit
23 });
24 console.log(response);
25 // Step 2: Check if GPT wanted to call a function
26 if (typeof response !== "object")
27 return;
28 // Step 3: Call the function
29 // Note: The JSON response may not always be valid; be sure to handle errors
30 const { name } = response;
34 args?.unit,
35 );
36 if (!functions)
37 return;
38 // Step 4: Send the info on the function call and function response to GPT
39 // Extend conversation with assistant's reply
40 messages.push({
41 role: "assistant",
42 function_call: response,
43 content: "",
44 });
45 // Extend conversation with function response
46 messages.push({
47 role: "function",
48 name,
49 content: JSON.stringify(funcResponse),
50 });
51 // Get a new response from GPT where it can see the function response
52 return await chat(messages);
53})();

chatmain.tsx1 match

@steveb1313•Updated 1 year ago
22 });
23 const message = data.choices[0].message;
24 return message.function_call ? message.function_call : message.content;
25};

homemain.tsx1 match

@dedes•Updated 1 year ago
5import { getHome } from "https://esm.town/v/dedes/getHome";
6
7export async function home(req: express.Request, res: express.Response) {
8 try {
9 const currentPage = req.query.page || "home";

usgsSitemain.tsx1 match

@eczajk•Updated 1 year ago
1import { fetchXML } from "https://esm.town/v/stevekrouse/fetchXML?v=3";
2
3export async function usgsSite(site) {
4 const result = await fetchXML(
5 `http://waterservices.usgs.gov/nwis/iv/?site=${site}`

greetmain.tsx1 match

@mik639•Updated 1 year ago
1export function greet(name) {
2 return "hi " + name;
3}

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 2 weeks ago
Simple functional CSS library for Val Town
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",