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=126&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 1606 results for "openai"(560ms)

tanLadybugmain.tsx1 match

@stevekrouse•Updated 11 months ago
107 // checkManualProfanityList is optional and defaults to false; it checks for the words in lang.ts (if under 50 words) before hitting the AI model. Note that this affects performance.
108 checkManualProfanityList: false,
109 // provider defaults to "google-perspective-api" (Google's Perspective API); it can also be "openai" (OpenAI Moderation API) or "google-natural-language-api" (Google's Natural Language API)
110 provider: "google-perspective-api",
111 };

embeddingsSearchExamplemain.tsx3 matches

@yawnxyz•Updated 11 months ago
1import { embed, embedMany } from "npm:ai";
2import { openai } from "npm:@ai-sdk/openai";
3import lunr from "https://cdn.skypack.dev/lunr";
4
8 console.log(`Getting embedding for: ${text}`);
9 const { embedding } = await embed({
10 model: openai.embedding('text-embedding-3-small'),
11 value: text,
12 });
19 console.log(`Getting embeddings for texts: ${texts}`);
20 const { embeddings } = await embedMany({
21 model: openai.embedding('text-embedding-3-small'),
22 values: texts,
23 });

semanticSearchREADME.md1 match

@yawnxyz•Updated 11 months ago
1In-memory semantic search; load it up with valtown KV.
2
3This is a "dumb" version of vector search, for prototyping RAG responses and UIs — with both regular search (w/ Lunr) and vector search (with OpenAI embeddings + cosine similarity)
4
5Usage:

embeddingsSearchExampleREADME.md1 match

@yawnxyz•Updated 11 months ago
1This is an example of in-memory search, using a combination of lunr, OpenAI embeddings, and cosine similarity
2
3Migrated from folder: Libraries/SemanticSearch/embeddingsSearchExample

nighthawksmain.tsx2 matches

@yawnxyz•Updated 11 months ago
57 const characterModel = new ModelProvider({
58 id: `${characterName}`,
59 // for web search / tool use, use openai
60 provider: 'openai',
61 model: 'gpt-4o',
62

booksmain.tsx3 matches

@laidlaw•Updated 11 months ago
3import { modifyImage } from "https://esm.town/v/stevekrouse/modifyImage";
4import { Hono } from "npm:hono@3";
5import { OpenAI } from "npm:openai";
6
7const openai = new OpenAI();
8
9function esmTown(url) {
95 const dataURL = await fileToDataURL(file);
96 try {
97 const response = await openai.chat.completions.create({
98 messages: [
99 {

key_safe_linkREADME.md2 matches

@stevekrouse•Updated 11 months ago
6
7```
8<a href="https://www.val.town/settings/environment-variables?name=OpenAI&value=sk-123...">
9 Add OpenAI key to Val Town
10</a>
11```

weatherGPTmain.tsx4 matches

@jcoleman•Updated 11 months ago
1import { email } from "https://esm.town/v/std/email?v=11";
2import { OpenAI } from "npm:openai";
3import { createHeaders, PORTKEY_GATEWAY_URL } from "npm:portkey-ai";
4
9).then(r => r.json());
10
11const openai = new OpenAI({
12 baseURL: PORTKEY_GATEWAY_URL,
13 defaultHeaders: createHeaders({
14 apiKey: Deno.env.get("PORTKEY_API_KEY"),
15 virtualKey: Deno.env.get("PORTKEY_OPENAI_VIRTUAL_KEY"),
16 }),
17});
18let chatCompletion = await openai.chat.completions.create({
19 messages: [{
20 role: "user",

aiImageExamplemain.tsx2 matches

@yawnxyz•Updated 11 months ago
2import { z } from "npm:zod";
3
4// Function to handle image and text input using OpenAI's GPT-4-turbo
5async function handleImageChat() {
6 const initialMessages = [
13 const response = await modelProvider.gen({
14 model: "gpt-4-turbo",
15 provider: "openai",
16 messages: [
17 ...initialMessages,

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 {

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": "*",