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/?q=function&page=1544&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 17976 results for "function"(2102ms)

react_httpmain.tsx2 matches

@tfayyaz•Updated 12 months ago
1export default (component: Function, url: string) =>
2 function(req: Request) {
3 return new Response(
4 `<html>

Which_Jacketmain.tsx1 match

@emilycoe•Updated 12 months ago
2import { getWeather } from "https://esm.town/v/stevekrouse/getWeather?v=2";
3
4export default async function(interval: Interval) {
5 let weather = await getWeather("Brooklyn, NY");
6 let temperature = weather.current_condition[0].FeelsLikeF;

cors_examplemain.tsx2 matches

@neverstew•Updated 1 year ago
5const BASE_URL = "https://stevekrouse-cors_example_backend.web.val.run";
6
7export function App() {
8 const [logs, setLogs] = useState([]);
9 async function request(url, options) {
10 try {
11 const response = await fetch(url, options);

ask_aimain.tsx18 matches

@pomdtr•Updated 1 year ago
3import { OpenAI } from "https://esm.town/v/std/OpenAI";
4
5async function getValByAlias({ author, name }: { author: string; name: string }) {
6 const { id, code, readme } = await api(`/v1/alias/${author}/${name}`, {
7 authenticated: true,
11}
12
13async function updateValCode({ id, code }: { id: string; code: string }) {
14 console.log({ id, code });
15 await api(`/v1/vals/${id}/versions`, {
25}
26
27async function sendEmail({ subject, text }: { subject: string; text: string }) {
28 await email({
29 subject,
66
67Do not communicate with the user directly.
68Instead, use the provided functions to accomplish your task on the behalf of the user.
69
70For example, if you need to modify the code of a val, use the updateValCode function.
71`;
72
73type Tool = {
74 type: "function";
75 function: {
76 function: (...args: any[]) => any;
77 description: string;
78 parse: (...args: any[]) => any;
87};
88
89export function askAI(content: string) {
90 const client = new OpenAI();
91 const runner = client.beta.chat.completions.runTools({
96 }],
97 tools: [{
98 type: "function",
99 function: {
100 function: getValByAlias,
101 description: "Get val info (id, code) from it's alias",
102 parse: JSON.parse,
115 },
116 }, {
117 type: "function",
118 function: {
119 function: updateValCode,
120 description: "update the javascript code of a val",
121 parse: JSON.parse,
134 },
135 }, {
136 type: "function",
137 function: {
138 function: sendEmail,
139 description: "send an email",
140 parse: JSON.parse,

github_cmdk_extensionmain.tsx1 match

@pomdtr•Updated 1 year ago
1import { Hono } from "npm:hono";
2
3export function githubExtension({
4 token: string,
5}) {

grayWildfowlmain.tsx4 matches

@jdan•Updated 1 year ago
3const openai = new OpenAI();
4
5async function runConversation() {
6 const inputWord = "almond latte";
7
24 // if (message.tool_calls) {
25 // for (let i = 0; i < message.tool_calls.length; i++) {
26 // console.log("[CALLING]", message.tool_calls[i].function);
27 // const tool = toolbox[message.tool_calls[i].function.name];
28 // if (tool) {
29 // const result = await tool.call(JSON.parse(message.tool_calls[i].function.arguments));
30 // console.log("[RESULT]", truncate(result));
31 // transcript.push({

grayWildfowlREADME.md1 match

@jdan•Updated 1 year ago
1Migrated from folder: openai_function_calling/grayWildfowl

sampleVanSSRmain.tsx3 matches

@reosablo•Updated 1 year ago
3
4/** load client HTML */
5async function loadClientHtml() {
6 // import VanJS framework and App component
7 const [{ default: van }, { default: App }] = await Promise.all([
28
29/** load client script for App component hydration */
30async function loadClientScript() {
31 // import esbuild and plugins
32 const [{ build }, { denoPlugins }] = await Promise.all([
49}
50
51export default async function fetch(req: Request) {
52 try {
53 const { pathname } = new URL(req.url);

uuidGeneratorStreammain.tsx1 match

@reosablo•Updated 1 year ago
1export default async function fetch(req: Request) {
2 const countParam = new URL(req.url).searchParams.get("count");
3 if (countParam === null) {

sampleVanIslandmain.tsx1 match

@reosablo•Updated 1 year ago
9const appId = "3753aa97-a7cf-41d0-bcf4-0ed59d25cd26";
10
11export default function App(props: { van: VanObj }) {
12 const { van } = props;
13 const {

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 week 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": "*",