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%22Image%20title%22?q=openai&page=120&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 1609 results for "openai"(570ms)

7import cosSimilarity from "npm:cos-similarity";
8import _ from "npm:lodash";
9import OpenAI from "npm:openai";
10
11export default async function blogPostEmbeddingsDimensionalityReduction() {
23 ];
24
25 const openai = new OpenAI();
26 async function getEmbedding(str) {
27 return (await openai.embeddings.create({
28 model: "text-embedding-3-large",
29 input: str,

compareEmbeddingsmain.tsx3 matches

@janpaul123•Updated 10 months ago
6import cosSimilarity from "npm:cos-similarity";
7import _ from "npm:lodash";
8import OpenAI from "npm:openai";
9
10const comparisons = [
20];
21
22const openai = new OpenAI();
23const cache = {};
24async function getEmbedding(str) {
25 cache[str] = cache[str] || (await openai.embeddings.create({
26 model: "text-embedding-3-large",
27 input: str,

indexValsBlobsmain.tsx4 matches

@janpaul123•Updated 10 months ago
4import { db as allValsDb } from "https://esm.town/v/sqlite/db?v=9";
5import { blob } from "https://esm.town/v/std/blob";
6import OpenAI from "npm:openai";
7import { truncateMessage } from "npm:openai-tokens";
8
9const dimensions = 1536;
39);
40
41const openai = new OpenAI();
42for (const newValsBatch of newValsBatches) {
43 const batchDataIndex = nextDataIndex;
47 const code = getValCode(val);
48
49 const embedding = await openai.embeddings.create({
50 model: "text-embedding-3-small",
51 input: truncateMessage(code, "text-embedding-3-small"),

semanticSearchNeonmain.tsx3 matches

@janpaul123•Updated 10 months ago
3import { db as allValsDb } from "https://esm.town/v/sqlite/db?v=9";
4import { blob } from "https://esm.town/v/std/blob";
5import OpenAI from "npm:openai";
6
7const dimensions = 1536;
11 await client.connect();
12
13 const openai = new OpenAI();
14 const queryEmbedding = (await openai.embeddings.create({
15 model: "text-embedding-3-small",
16 input: query,

indexValsNeonmain.tsx4 matches

@janpaul123•Updated 10 months ago
5import { db as allValsDb } from "https://esm.town/v/sqlite/db?v=9";
6import { blob } from "https://esm.town/v/std/blob";
7import OpenAI from "npm:openai";
8import { truncateMessage } from "npm:openai-tokens";
9
10// CREATE TABLE vals_embeddings (id TEXT PRIMARY KEY, embedding VECTOR(1536));
41 }
42
43 const openai = new OpenAI();
44 for (const newValsBatch of newValsBatches) {
45 await Promise.all([...Array(newValsBatch.length).keys()].map(async (valIndex) => {
47 const code = getValCode(val);
48
49 const embedding = await openai.embeddings.create({
50 model: "text-embedding-3-small",
51 input: truncateMessage(code, "text-embedding-3-small"),

caloriesmain.tsx1 match

@chriswmartin•Updated 10 months ago
2import { fileToDataURL } from "https://esm.town/v/stevekrouse/fileToDataURL";
3import { modifyImage } from "https://esm.town/v/stevekrouse/modifyImage";
4import { chat } from "https://esm.town/v/stevekrouse/openai";
5import { Hono } from "npm:hono@3";
6

convertResumemain.tsx1 match

@iamseeley•Updated 10 months ago
122 event.preventDefault();
123 const resumeContent = document.getElementById('resumeContent').value;
124 const apiKey = '${Deno.env.get("OPENAI_API_KEY")}';
125 const spinner = document.getElementById('spinner');
126 const jsonOutput = document.getElementById('jsonOutput');

weatherGPTmain.tsx3 matches

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

purpleKangarooREADME.md1 match

@willthereader•Updated 10 months ago
1# ChatGPT Implemented in Val Town
2
3Demonstrated how to use assistants and threads with the OpenAI SDK and how to stream the response with Server-Sent Events.
4
5<p align=center>

purpleKangaroomain.tsx8 matches

@willthereader•Updated 10 months ago
1/** @jsxImportSource https://esm.sh/react */
2import OpenAI from "npm:openai";
3import { renderToString } from "npm:react-dom/server";
4
5// This uses by personal API key, you'll need to provide your own if
6// you fork this. We'll be adding support to the std/openai lib soon!
7const openai = new OpenAI();
8import { Hono } from "npm:hono@3";
9
38 });
39
40 // Setup the SSE connection and stream back the response. OpenAI handles determining
41 // which message is the correct response based on what was last read from the
42 // thread. This is likely vulnerable to race conditions.
58const app = new Hono();
59app.get("/", async (c) => {
60 const thread = await openai.beta.threads.create();
61 const assistant = await openai.beta.assistants.create({
62 name: "",
63 instructions:
114app.post("/post-message", async (c) => {
115 let message = await c.req.text();
116 await openai.beta.threads.messages.create(
117 c.req.query("threadId"),
118 { role: "user", content: message },
132 ));
133 };
134 const run = openai.beta.threads.runs.stream(threadId, {
135 assistant_id: assistantId,
136 // Make sure we only display messages we haven't seen yet.

translateToEnglishWithOpenAI1 file match

@shlmt•Updated 2 days ago

testOpenAI1 file match

@stevekrouse•Updated 4 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": "*",