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=109&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 1594 results for "openai"(1143ms)

VALLEREADME.md1 match

@eugenechantk•Updated 8 months ago
6* Fork this val to your own profile.
7* Make a folder for the temporary vals that get generated, take the ID from the URL, and put it in `tempValsParentFolderId`.
8* If you want to use OpenAI models you need to set the `OPENAI_API_KEY` [env var](https://www.val.town/settings/environment-variables).
9* If you want to use Anthropic models you need to set the `ANTHROPIC_API_KEY` [env var](https://www.val.town/settings/environment-variables).
10* Create a [Val Town API token](https://www.val.town/settings/api), open the browser preview of this val, and use the API token as the password to log in.

egoBoostermain.tsx7 matches

@stevekrouse•Updated 8 months ago
2 * This ego booster app takes a selfie, sends it to GPT-4o-mini for analysis,
3 * and streams funny, specific compliments about the user's appearance.
4 * We use the WebRTC API for camera access, the OpenAI API for image analysis,
5 * and server-sent events for real-time streaming of compliments.
6 */
186 }
187
188 const { OpenAI } = await import("https://esm.town/v/std/openai");
189 const openai = new OpenAI();
190
191 const stream = new ReadableStream({
196 const base64Image = btoa(String.fromCharCode(...new Uint8Array(arrayBuffer)));
197
198 console.log("Sending request to OpenAI");
199 const completion = await openai.chat.completions.create({
200 model: "gpt-4o-mini",
201 messages: [
216 });
217
218 console.log("Streaming response from OpenAI");
219 for await (const chunk of completion) {
220 const content = chunk.choices[0]?.delta?.content || '';
223 }
224 } catch (error) {
225 console.error('Error in OpenAI processing:', error);
226 controller.enqueue(new TextEncoder().encode("Oops! Our AI had a little hiccup. Maybe your beauty short-circuited it! 🤖💥"));
227 } finally {

VALLErunmain.tsx2 matches

@cofsana•Updated 8 months ago
9import { sleep } from "https://esm.town/v/stevekrouse/sleep?v=1";
10import { anthropic } from "npm:@ai-sdk/anthropic";
11import { openai } from "npm:@ai-sdk/openai";
12import ValTown from "npm:@valtown/sdk";
13import { StreamingTextResponse, streamText } from "npm:ai";
1104 let vercelModel;
1105 if (model.includes("gpt")) {
1106 vercelModel = openai(model);
1107 } else {
1108 vercelModel = anthropic(model);

DailyDaughterNotesmain.tsx4 matches

@heathergliffin•Updated 8 months ago
1/**
2 * This app generates cute daily notes for a daughter using OpenAI's GPT model.
3 * It stores the generated notes in SQLite for persistence and displays them on a simple web interface.
4 * The app uses React for the frontend and Deno's runtime environment in Val Town for the backend.
56
57async function server(request: Request): Promise<Response> {
58 const { OpenAI } = await import("https://esm.town/v/std/openai");
59 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
60 const KEY = "DailyDaughterNotes";
85 }
86 } else if (path === "/generate-note" && request.method === "POST") {
87 const openai = new OpenAI();
88 const completion = await openai.chat.completions.create({
89 messages: [
90 {

VALLEREADME.md1 match

@ttodosi•Updated 8 months ago
6* Fork this val to your own profile.
7* Make a folder for the temporary vals that get generated, take the ID from the URL, and put it in `tempValsParentFolderId`.
8* If you want to use OpenAI models you need to set the `OPENAI_API_KEY` [env var](https://www.val.town/settings/environment-variables).
9* If you want to use Anthropic models you need to set the `ANTHROPIC_API_KEY` [env var](https://www.val.town/settings/environment-variables).
10* Create a [Val Town API token](https://www.val.town/settings/api), open the browser preview of this val, and use the API token as the password to log in.

infiniteSVGGraphmain.tsx3 matches

@ttodosi•Updated 8 months ago
1import { sha256 } from "https://denopkg.com/chiefbiiko/sha256@v1.0.0/mod.ts";
2import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
3import { OpenAI } from "https://esm.town/v/std/openai?v=4";
4import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite?v=6";
5import { Hono } from "npm:hono@3";
392const app = new Hono();
393app.post("/remix/:id", async (c) => {
394 const openai = new OpenAI();
395 const { prompt } = await c.req.json();
396 let svg = await getSVG(c.req.param("id") as string);
397 if (svg === undefined) return c.text("Not found", 404);
398 const stream = await openai.chat.completions.create({
399 messages: [
400 { role: "user", content: "make me an svg image" },

githubcollabgenmain.tsx4 matches

@ejfox•Updated 8 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3const OPENAI_API_KEY = "your_openai_api_key"; // Replace with your actual OpenAI API key
4
5export default async function main(req: Request): Promise<Response> {
57 const user2Summary = summarizeActivity(user2Data);
58
59 const openai = new OpenAI(OPENAI_API_KEY);
60 const completion = await openai.chat.completions.create({
61 model: "gpt-3.5-turbo",
62 messages: [

githubactivitysummarizermain.tsx6 matches

@ejfox•Updated 8 months ago
1// This approach fetches GitHub activity for two users specified in the URL,
2// sends it to OpenAI for analysis, and returns collaboration suggestions.
3// It uses the GitHub API (which doesn't require authentication for public data)
4// and the OpenAI API (which does require an API key).
5// Tradeoff: We're using an inline API key for simplicity, which isn't ideal for security.
6// Note: This might hit rate limits for the GitHub API due to fetching a year of data.
7
8import { OpenAI } from "https://esm.town/v/std/openai";
9
10const OPENAI_API_KEY = "your_openai_api_key"; // Replace with your actual OpenAI API key
11
12export default async function main(req: Request): Promise<Response> {
54 const user2Summary = summarizeActivity(user2Data);
55
56 const openai = new OpenAI(OPENAI_API_KEY);
57 const completion = await openai.chat.completions.create({
58 model: "gpt-3.5-turbo",
59 messages: [

githubactivitysummarizerREADME.md3 matches

@ejfox•Updated 8 months ago
1# GitHub Activity Summarizer
2
3This val.town script fetches a user's recent GitHub activity and generates a summarized narrative overview using OpenAI's GPT model.
4
5## Features
6
7- Retrieves GitHub activity for a specified user from the past week
8- Summarizes activity using OpenAI's GPT-3.5-turbo model
9- Returns a concise, narrative summary of the user's GitHub contributions
10
22## Note
23
24Ensure you have necessary permissions and comply with GitHub's and OpenAI's terms of service when using this script.

relationshipgeneratormain.tsx5 matches

@ejfox•Updated 8 months ago
1// This val receives text input, sends it to OpenAI to generate relationships,
2// and returns a newline-delimited list of relationships.
3// It uses the OpenAI API to generate the relationships.
4// Tradeoff: This approach relies on an external API, which may have rate limits or costs.
5
7// curl -X POST -H "Content-Type: text/plain" -d "Your text here" https://your-val-url.web.val.run
8
9import { OpenAI } from "https://esm.town/v/std/openai";
10
11const openai = new OpenAI();
12
13export default async function main(req: Request): Promise<Response> {
18 const text = await req.text();
19
20 const completion = await openai.chat.completions.create({
21 model: "gpt-3.5-turbo",
22 messages: [

translateToEnglishWithOpenAI1 file match

@shlmt•Updated 17 hours ago

testOpenAI1 file match

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