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/$%7Bart_info.art.src%7D?q=openai&page=124&format=json

For typeahead suggestions, use the /typeahead endpoint:

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

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

Found 1576 results for "openai"(2130ms)

gpt4o_imagesmain.tsx3 matches

@jdan•Updated 11 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3const openai = new OpenAI();
4const completion = await openai.chat.completions.create({
5 "messages": [
6 {

weatherGPTmain.tsx3 matches

@developersdigest•Updated 11 months ago
1import { email } from "https://esm.town/v/std/email?v=11";
2import { OpenAI } from "npm:openai";
3
4let location = "toronto on";
8).then(r => r.json());
9
10const openai = new OpenAI();
11let chatCompletion = await openai.chat.completions.create({
12 messages: [{
13 role: "user",

semanticSearchBlobsmain.tsx3 matches

@janpaul123•Updated 11 months ago
6import cosSimilarity from "npm:cos-similarity";
7import _ from "npm:lodash";
8import OpenAI from "npm:openai";
9
10const dimensions = 1536;
27 await Promise.all(allBatchDataIndexesPromises);
28
29 const openai = new OpenAI();
30 const queryEmbedding = (await openai.embeddings.create({
31 model: "text-embedding-3-small",
32 input: query,

semanticSearchTursomain.tsx3 matches

@janpaul123•Updated 11 months ago
3import { sqlToJSON } from "https://esm.town/v/nbbaier/sqliteExportHelpers?v=22";
4import { db as allValsDb } from "https://esm.town/v/sqlite/db?v=9";
5import OpenAI from "npm:openai";
6
7export default async function semanticSearchPublicVals(query) {
11 });
12
13 const openai = new OpenAI();
14
15 const embedding = await openai.embeddings.create({
16 model: "text-embedding-3-small",
17 input: query,

semanticSearchNeonREADME.md1 match

@janpaul123•Updated 11 months ago
3Uses [Neon](https://neon.tech/) to search embeddings of all vals, using the [pg_vector](https://neon.tech/docs/extensions/pgvector) extension.
4
5- Call OpenAI to generate an embedding for the search query.
6- Query the `vals_embeddings` table in Neon using the cosine similarity operator.
7 - The `vals_embeddings` table gets refreshed every 10 minutes by [janpaul123/indexValsNeon](https://www.val.town/v/janpaul123/indexValsNeon).

indexValsNeonREADME.md2 matches

@janpaul123•Updated 11 months ago
1*Part of [Val Town Semantic Search](https://www.val.town/v/janpaul123/valtownsemanticsearch).*
2
3Generates OpenAI embeddings for all public vals, and stores them in [Neon](https://neon.tech/), using the [pg_vector](https://neon.tech/docs/extensions/pgvector) extension.
4
5- Create the `vals_embeddings` table in Neon if it doesn't already exist.
6- Get all val names from the [database of public vals](https://www.val.town/v/sqlite/db), made by [Achille Lacoin](https://www.val.town/u/pomdtr).
7- Get all val names from the `vals_embeddings` table and compute the difference (which ones are missing).
8- Iterate through all missing vals, get their code, get embeddings from OpenAI, and store the result in Neon.
9- Can now be searched using [janpaul123/semanticSearchNeon](https://www.val.town/v/janpaul123/semanticSearchNeon).
10

debugValEmbeddingsmain.tsx5 matches

@janpaul123•Updated 11 months ago
6import cosSimilarity from "npm:cos-similarity";
7import _ from "npm:lodash";
8import OpenAI from "npm:openai";
9
10const openai = new OpenAI();
11const queryEmbedding = (await openai.embeddings.create({
12 model: "text-embedding-3-small",
13 input: "check dynamicland website for changes and email me",
16console.log(queryEmbedding.slice(0, 4));
17
18const embedding = await openai.embeddings.create({
19 model: "text-embedding-3-small",
20 input: "check dynamicland website for changes and email me",
41}`;
42
43const queryEmbeddingVal = (await openai.embeddings.create({
44 model: "text-embedding-3-small",
45 input: valCode,

semanticSearchBlobsREADME.md1 match

@janpaul123•Updated 11 months ago
6 - The blobs have been generated by [janpaul123/indexValsBlobs](https://www.val.town/v/janpaul123/indexValsBlobs). It is not run automatically.
7- Get all blobs with embeddings pointed to by the metadata, e.g. `allValsBlob1536EmbeddingsData_0` for `batchDataIndex` 0.
8- Call OpenAI to generate an embedding for the search query.
9- Go through all embeddings and compute cosine similarity with the embedding for the search query.
10- Return list sorted by similarity.

jadeMacawmain.tsx3 matches

@janpaul123•Updated 11 months ago
6import { VectorDB } from "npm:imvectordb";
7import _ from "npm:lodash";
8import OpenAI from "npm:openai";
9
10export default async function semanticSearchPublicVals(query) {
34 }
35
36 const openai = new OpenAI();
37 const embedding = await openai.embeddings.create({
38 model: "text-embedding-3-small",
39 input: query,

indexValsBlobsREADME.md2 matches

@janpaul123•Updated 11 months ago
1*Part of [Val Town Semantic Search](https://www.val.town/v/janpaul123/valtownsemanticsearch).*
2
3Generates OpenAI embeddings for all public vals, and stores them in Val Town's [blob storage](https://docs.val.town/std/blob/).
4
5- Create a new metadata object. Also has support for getting the previous metadata and only adding new vals, but that's currently disabled.
6- Get all val names from the [database of public vals](https://www.val.town/v/sqlite/db), made by [Achille Lacoin](https://www.val.town/u/pomdtr).
7- Put val names in batches. Vals in the same batch will have their embeddings stored in the same blob, at different offsets.
8- Iterate through all each batch, get code for all the vals, get embeddings from OpenAI, and store the result in a blob.
9- When finished, save the metadata JSON to its own blob.
10- Can now be searched using [janpaul123/semanticSearchBlobs](https://www.val.town/v/janpaul123/semanticSearchBlobs).

testOpenAI1 file match

@stevekrouse•Updated 22 hours ago

testOpenAI1 file match

@shouser•Updated 3 days ago
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": "*",