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/$%7Burl%7D?q=openai&page=27&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 1904 results for "openai"(917ms)

Towniesystem_prompt.txt4 matches

@devdoshi•Updated 2 weeks ago
88Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
89
90### OpenAI
91
92```ts
93import { OpenAI } from "https://esm.town/v/std/openai";
94const openai = new OpenAI();
95const completion = await openai.chat.completions.create({
96 messages: [
97 { role: "user", content: "Say hello in a creative way" },

reelMitrajsREADME.md2 matches

@Omyadav•Updated 2 weeks ago
2 const prompt = `Generate a short 15-second Instagram reel script and 5 viral hashtags for the topic: "${topic}". Make the script engaging and desi style.`;
3
4 const res = await fetch("https://api.openai.com/v1/chat/completions", {
5 method: "POST",
6 headers: {
7 "Authorization": `Bearer ${Deno.env.get("OPENAI_API_KEY")}`,
8 "Content-Type": "application/json",
9 },

untitled-509README.md2 matches

@Omyadav•Updated 2 weeks ago
2 const prompt = `Generate a short 15-second Instagram reel script and 5 viral hashtags for the topic: "${topic}". Make the script engaging and desi style.`;
3
4 const res = await fetch("https://api.openai.com/v1/chat/completions", {
5 method: "POST",
6 headers: {
7 "Authorization": `Bearer ${Deno.env.get("OPENAI_API_KEY")}`,
8 "Content-Type": "application/json",
9 },

audbotmain.ts4 matches

@lou•Updated 2 weeks ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2import { sqlite } from "https://esm.town/v/std/sqlite";
3import nlp from "npm:compromise";
10}
11
12const openai = new OpenAI();
13const app = express();
14app.use(express.json());
119 // 1. Parse intent + slots
120 // const prompt = buildIntentPrompt(text);
121 // const completion = await openai.chat.completions.create({
122 // messages: [
123 // { role: "system", content: prompt },
147 const rows = transformRows<Item>(result);
148 const prompt = buildKnowledgePrompt(text, rows);
149 const completion = await openai.chat.completions.create({
150 messages: [
151 { role: "system", content: prompt },

resume-parserresumeSchemas.ts9 matches

@prashamtrivedi•Updated 2 weeks ago
3
4/**
5 * Transforms a Zod schema into a format suitable for OpenAI by:
6 * - Adding additionalProperties: false to all objects
7 * - Making all fields required
8 * - Removing validation constraints that OpenAI might struggle with
9 *
10 * Specifically removes:
17 * @returns A new Zod schema with modified properties
18 */
19export function transformSchemaForOpenAI<T extends ZodType>(schema: T): T {
20 // Helper to process each schema type
21 function processSchema(schema: ZodTypeAny): ZodTypeAny {
104 // For unions, just convert to the first type for simplicity
105 // This is a simplification that might lose some information
106 // but ensures OpenAI has a concrete type to work with
107 return processSchema(schema._def.options[0])
108 }
277 standardization: z.string().describe("If the value has confidence > 0.8 keep pass the original value as is, Otherwise pass in following format, suitable for tooltip: UpdatedStandardValue=ReasonBehindUpdation")
278 })
279// Create a simplified schema for OpenAI with fewer parameters
280// This addresses the 100 parameter limit in OpenAI's response_format
281export const SimplifiedResumeSchema = z.object({
282 personalInfo: z.object({
345})
346
347// Example of how to use the transformSchemaForOpenAI function:
348// This creates a version of SimplifiedResumeSchema that's suitable for OpenAI
349export const OpenAICompatibleResumeSchema = transformSchemaForOpenAI(SimplifiedResumeSchema)
350

untitled-1162new-file-7114.tsx3 matches

@sdfsd•Updated 2 weeks ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(req: Request): Promise<Response> {
11 });
12 }
13 const openai = new OpenAI();
14
15 try {
28 }
29
30 const stream = await openai.chat.completions.create(body);
31
32 if (!body.stream) {

rosey.cursorrules4 matches

@avni•Updated 2 weeks ago
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101
102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107 messages: [
108 { role: "user", content: "Say hello in a creative way" },

stevensDemo.cursorrules4 matches

@avni•Updated 2 weeks ago
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101
102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107 messages: [
108 { role: "user", content: "Say hello in a creative way" },

resume-parseropenai.ts33 matches

@prashamtrivedi•Updated 2 weeks ago
1import {OpenAI} from "npm:openai"
2import {ParsedResume, ResumeParserOptions, ConfidenceField, DateRange} from "../types/resume.ts"
3import {generatePrompt} from "../prompts/resumePrompts.ts"
4import {OpenAICompatibleResumeSchema, ParsedResumeSchema} from "../schemas/resumeSchemas.ts"
5import {z} from "npm:@hono/zod-openapi"
6import {zodResponseFormat} from "npm:openai/helpers/zod"
7
8/**
9 * Parse resume text using OpenAI and return structured data
10 *
11 * @param resumeText The plain text of the resume to parse
23 }
24
25 // Initialize OpenAI client (uses API key from environment in ValTown)
26 const openai = new OpenAI()
27
28 // Get extraction prompt
59${extractionFocus}${extractLanguages}${extractSummary}`
60
61 console.log("Calling OpenAI API for initial extraction...")
62
63
64 // Call OpenAI API with enhanced system prompt and structured output schema
65 const completion = await openai.beta.chat.completions.parse({
66 model: "gpt-4o",
67 messages: [
69 {role: "user", content: extractPrompt + "\n\nResume Text:\n" + resumeText}
70 ],
71 response_format: zodResponseFormat(OpenAICompatibleResumeSchema, 'parsedResume')
72 })
73
77
78 if (!responseContent) {
79 throw new Error("Empty response from OpenAI")
80 }
81
85
86 console.error("JSON parsing error:", error)
87 throw new Error("Failed to parse OpenAI response as valid JSON")
88 }
89 } catch (error) {
90 console.error("OpenAI parsing error:", error)
91 // Provide specific error message based on the error type
92 if ((error as Error).message.includes("429")) {
93 throw new Error("OpenAI rate limit exceeded. Please try again later.")
94 } else if ((error as Error).message.includes("401") || (error as Error).message.includes("403")) {
95 throw new Error("Authentication error with OpenAI API. Check your API key.")
96 } else {
97 throw new Error("Failed to parse resume with OpenAI: " + (error as Error).message)
98 }
99 }
101
102/**
103 * Validate extracted data using OpenAI
104 *
105 * @param data The extracted resume data to validate
108export async function validateResumeWithAI(data: ParsedResume): Promise<ParsedResume> {
109 try {
110 // Initialize OpenAI client
111 const openai = new OpenAI()
112
113 // Get validation prompt
136Always return the complete JSON structure with your improvements.`
137
138 console.log("Calling OpenAI API for validation and standardization...")
139
140
141 // Call OpenAI API with enhanced validation
142 const completion = await openai.beta.chat.completions.parse({
143 model: "gpt-4o",
144 messages: [
146 {role: "user", content: validationPrompt + "\n\nResume Data:\n" + JSON.stringify(data)}
147 ],
148 response_format: zodResponseFormat(OpenAICompatibleResumeSchema, 'validResume')
149 })
150
154
155 if (!responseContent) {
156 throw new Error("Empty validation response from OpenAI")
157 }
158
165 }
166 } catch (error) {
167 console.error("OpenAI validation error:", error)
168 console.warn("Using original data due to validation API error")
169 // Return original data if validation API call fails
173
174/**
175 * Helper function to check if OpenAI extraction result is valid
176 * and retry if necessary with a different prompt strategy
177 *
198 console.log("Initial extraction had issues, attempting retry with different strategy...")
199
200 // Initialize OpenAI client
201 const openai = new OpenAI()
202
203 // Create a simplified extraction prompt focused on missing data
214
215
216 // Call OpenAI API with retry strategy
217 const completion = await openai.beta.chat.completions.parse({
218 model: "gpt-4o",
219 messages: [
230Please provide a complete and corrected JSON response following the exact same schema.` }
231 ],
232 response_format: zodResponseFormat(OpenAICompatibleResumeSchema, 'retriedResume')
233 })
234
254
255/**
256 * Convert simplified OpenAI schema format to full ParsedResume format with confidence fields
257 * @param simplified Simplified resume data returned from OpenAI
258 * @returns Fully structured resume data with confidence fields
259 */

ab457573e37_.cursorrules4 matches

@vtTestLocal•Updated 2 weeks ago
100Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
101
102### OpenAI
103```ts
104import { OpenAI } from "https://esm.town/v/std/openai";
105const openai = new OpenAI();
106const completion = await openai.chat.completions.create({
107 messages: [
108 { role: "user", content: "Say hello in a creative way" },

openaiproxy2 file matches

@skutaans•Updated 3 hours ago

token-server1 file match

@kwhinnery_openai•Updated 19 hours ago
Mint tokens to use with the OpenAI Realtime API for WebRTC
reconsumeralization
import { OpenAI } from "https://esm.town/v/std/openai"; import { sqlite } from "https://esm.town/v/stevekrouse/sqlite"; /** * Practical Implementation of Collective Content Intelligence * Bridging advanced AI with collaborative content creation */ exp
kwhinnery_openai