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/$%7Bsuccess?q=openai&page=100&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 1610 results for "openai"(597ms)

OpenAIUsagemain.tsx6 matches

@std•Updated 6 months ago
17 COUNT(*) AS count
18 FROM
19 openai_usage,
20 params
21 WHERE
38};
39
40export class OpenAIUsage {
41 constructor() {}
42 async migrate() {
43 await sqlite.batch([`CREATE TABLE IF NOT EXISTS openai_usage (
44 id INTEGER PRIMARY KEY,
45 user_id TEXT NOT NULL,
52 }
53 async drop() {
54 await sqlite.batch([`DROP TABLE IF EXISTS openai_usage`]);
55 }
56 async writeUsage(ur: UsageRow) {
57 sqlite.execute({
58 sql: "INSERT INTO openai_usage (user_id, handle, tier, tokens, model) VALUES (?, ?, ?, ?, ?)",
59 args: [ur.userId, ur.handle, ur.tier, ur.tokens, ur.model],
60 });
78 let resp = await sqlite.execute({
79 sql: `SELECT count(*)
80FROM openai_usage
81WHERE (
82 (model LIKE 'gpt-4%' AND model NOT LIKE '%mini%')

curiousTurquoiseDormousemain.tsx3 matches

@CoachCompanion•Updated 6 months ago
670 }
671
672 const { OpenAI } = await import("https://esm.town/v/std/openai");
673 const regenerateKey = request.headers.get("Regenerate-Key") || "0";
674 const openai = new OpenAI();
675
676 const { sport, skillLevel, ageGroup, groupSize, selectedTopics, sessionDuration } = await request.json();
707 Ensure that the conclusion ties together all the main concepts covered in the training, reinforces the learning objectives, and provides clear takeaways for both participants and coaches. The questions in the conclusion should prompt critical thinking about the skills practiced and their application in the sport.`;
708
709 const completion = await openai.chat.completions.create({
710 messages: [{ role: "user", content: prompt + `\n\nRegenerate key: ${regenerateKey}` }],
711 model: "gpt-4o-mini",

efficientAmberUnicornmain.tsx2 matches

@CoachCompanion•Updated 6 months ago
14 }
15
16 const { OpenAI } = await import("https://esm.town/v/std/openai");
17 const regenerateKey = request.headers.get("Regenerate-Key") || "0";
18 const openai = new OpenAI();
19
20 const { sport, skillLevel, ageGroup, groupSize, selectedTopics, sessionDuration } = await request.json();

pageshotmain.tsx1 match

@all•Updated 6 months ago
30 "settings": {
31 "model": "gpt-4o-mini",
32 "provider": "openai",
33 "system": "please summarize the following article in a 2-4 sentences, describing it from a 3rd person point of view",
34 "prompt": "{jina.content}"

podcastmain.tsx3 matches

@all•Updated 6 months ago
317
318 if (url.searchParams.has("nextMessage")) {
319 const { OpenAI } = await import("https://esm.town/v/std/openai");
320 const openai = new OpenAI();
321
322 const { personality1, personality2, topic, conversation, currentSpeaker } = await req.json();
328
329 const currentPersonality = currentSpeaker === 1 ? personality1 : personality2;
330 const response = await openai.chat.completions.create({
331 messages: [
332 {

findSlamArticlesmain.tsx3 matches

@dupontgu•Updated 6 months ago
1import cheerio from "https://esm.sh/cheerio@1.0.0-rc.12";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { blob } from "https://esm.town/v/std/blob";
4
5const openai = new OpenAI();
6export const BLOB_PREFIX = "SLAM_HEADLINE_"
7export const POST_PREFIX = "SLAM_POST_"
44
45export async function feedToChatGPT(newsItems: Headline[]): Promise<Slam[] | undefined > {
46 const completion = await openai.chat.completions.create({
47 messages: [
48 { role: "user", content: "Following is a list of headlines with the urls. For each headline, please determine the person or thing that is doing the slamming, and the person or thing that is being slammed. If you cannot determine this for a headline, skip it. Please return a list of JSON objects, each with a 'slammer' and 'slammed' key. Keep the values as short as possible, we don't need details about the subjects. Also include all the key/value pairs from the original object. Use as few words as possible to describe each, and don't use any words that are not included in the headline. Respond with only the JSON, no additional text or markdown.\n" + JSON.stringify(newsItems) },

aigreetingmain.tsx3 matches

@victorli•Updated 6 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(req: Request): Promise<Response> {
4 const openai = new OpenAI();
5
6 const completion = await openai.chat.completions.create({
7 messages: [
8 { role: "user", content: "Say hello in a creative way" },

email_channelmain.tsx5 matches

@campsite•Updated 6 months ago
1import { email } from "https://esm.town/v/std/email";
2import { createOpenAI } from "npm:@ai-sdk/openai";
3import { generateObject } from "npm:ai";
4import Campsite from "npm:campsite-client";
15// Other providers are available via Vercel's AI SDK:
16// https://sdk.vercel.ai/docs/introduction#model-providers
17const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY");
18
19const campsite = new Campsite({ apiKey: CAMPSITE_API_KEY });
29 let subject = payload.subject || "Forwarded email (no subject)";
30
31 if (OPENAI_API_KEY) {
32 const openai = createOpenAI({ apiKey: OPENAI_API_KEY });
33
34 // Extract name and email from the forwarded message
35 const { object: { name, email, subject, message } } = await generateObject({
36 model: openai("gpt-4-turbo"),
37 schema: z.object({
38 name: z.string(),

flutteringVioletBirdmain.tsx1 match

@stevekrouse•Updated 6 months ago
12 setIsLoading(true);
13 try {
14 const response = await fetch("https://esm.town/v/stevekrouse/openai", {
15 method: "POST",
16 headers: { "Content-Type": "application/json" },

flutteringVioletBirdREADME.md1 match

@stevekrouse•Updated 6 months ago
8* Hono JSX
9* HTMX (probably overcomplicates things; should remove)
10* @stevekrouse/openai, which is a light wrapper around @std/openai
11
12I'm finding HTMX a bit overpowered for this, so I have two experimental forks without it:

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