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=2449&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 27947 results for "function"(6732ms)

openaimain.tsx3 matches

@willthereader•Updated 10 months 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">,

chatmain.tsx3 matches

@willthereader•Updated 10 months 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") === @std/openai) {
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

@willthereader•Updated 10 months 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.

jadeGophermain.tsx3 matches

@willthereader•Updated 10 months ago
10
11const clientCode = () => {
12 document.getElementById("input").addEventListener("submit", function(event) {
13 event.preventDefault();
14
34 + `&assistantId=${input.getAttribute("data-assistant-id")}`,
35 );
36 eventSource.onmessage = function(event) {
37 console.log(event);
38 responseDiv.innerText += JSON.parse(event.data);
39 };
40
41 eventSource.onerror = function() {
42 eventSource.close();
43 };

linkInBioTemplatemain.tsx1 match

@ghsaboias•Updated 10 months ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(

httpHandlerOKmain.tsx1 match

@kora•Updated 10 months ago
1export function handler(request: Request) {
2 return Response.json({ ok: true });
3}

quickstartWebsitemain.tsx1 match

@kora•Updated 10 months ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(

xkcdmain.tsx1 match

@loading•Updated 10 months ago
1import { parseFeed } from "jsr:@mikaelporttila/rss@*";
2
3export default async function(req: Request): Promise<Response> {
4 return new Response(
5 (await parseFeed(

gitReleaseNotesmain.tsx10 matches

@stevekrouse•Updated 10 months ago
16}
17
18// Function to fetch package info from NPM registry
19async function fetchPackageInfo(packageName: string) {
20 const url = `https://registry.npmjs.org/${packageName}`;
21 const response = await fetch(url);
26}
27
28// Function to extract GitHub repo URL from package info
29function extractGitHubRepoUrl(packageInfo: any): string | null {
30 const repository = packageInfo.repository;
31 if (repository && repository.url) {
38}
39
40// Function to get the GitHub repository path (owner/repo) from the URL
41function getGithubRepoPath(repoUrl: string): string | null {
42 const match = repoUrl.match(/github\.com\/([^\/]+\/[^\/]+)/);
43 return match ? match[1] : null;
44}
45
46async function getGithubReleases(repo: string): Promise<GithubRelease[]> {
47 const response = await fetch(`https://api.github.com/repos/${repo}/releases`);
48 if (!response.ok) {
52}
53
54function compareVersions(version1: string, version2: string): number {
55 const v1 = version1.replace(/^v/, "").split(".").map(Number);
56 const v2 = version2.replace(/^v/, "").split(".").map(Number);
63}
64
65async function getReleaseNotesBetweenVersions(repo: string, currentVersion: string): Promise<GithubRelease[]> {
66 const releases = await getGithubReleases(repo);
67
74}
75
76async function checkNpmUpdates(packageJsonUrl: string): Promise<string> {
77 try {
78 const response = await fetch(packageJsonUrl);

reacttldrawclientmain.tsx1 match

@janpaul123•Updated 10 months ago
20} = await import(ret.url + "?bundle-deps");
21
22export function App() {
23 return (
24 <>

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 month 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.