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%22Optional%20title%22?q=openai&page=63&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 2472 results for "openai"(1676ms)

autonomous-valagent.tsx2 matches

@abrinz•Updated 1 month ago
1import { anthropic } from "npm:@ai-sdk/anthropic";
2import { openai } from "npm:@ai-sdk/openai";
3import { generateText, streamText } from "npm:ai";
4import { getSystemPrompt } from "./prompt.tsx";
34 const maxSteps = 10;
35
36 const model = Deno.env.get("ANTHROPIC_API_KEY") ? anthropic("claude-3-7-sonnet-latest") : openai("gpt-4.1");
37
38 const options = {

untitled-7748telegram-image-bot.ts7 matches

@Rajparbat01•Updated 1 month ago
1// Telegram Bot that uses OpenAI's DALL-E to generate images
2import { OpenAI } from "https://esm.town/v/std/openai";
3
4// Initialize OpenAI client
5const openai = new OpenAI();
6
7// Telegram Bot API types
91}
92
93// Function to generate an image using OpenAI's DALL-E
94async function generateImage(prompt: string) {
95 try {
96 const response = await openai.images.generate({
97 model: "dall-e-3",
98 prompt: prompt,
123 chatId,
124 "👋 Welcome to the Image Generation Bot!\n\n" +
125 "I can generate images based on your descriptions using OpenAI's DALL-E model.\n\n" +
126 "Simply send me a description of the image you want to create, and I'll generate it for you.\n\n" +
127 "For example: *A serene lake surrounded by mountains at sunset*"
Hubspot-Research

Hubspot-Research.cursorrules4 matches

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

nightwatchmain.tsx16 matches

@join•Updated 1 month ago
1// Val Town Narrative Engine with Integrated Test UI
2// =============================================================================
3import { OpenAI } from "https://esm.town/v/std/openai"; // Val Town's OpenAI integration
4// import { Env } from "https://esm.town/v/std/env"; // Not needed if OpenAI() handles API key
5
6// --- Configuration & Constants ---
7const OPENAI_MODEL = "gpt-4o";
8const MAX_TOKENS_RESPONSE = 700;
9
127}
128
129// --- OpenAI System Prompt (same as before) ---
130const SYSTEM_PROMPT = `
131You are a Rick and Morty-styled transdimensional narrative engine, probably cobbled together by Rick in a drunken stupor. Your primary role is to generate hilariously chaotic, compelling, and atmospherically bizarre narrative turns for an epic journey to save the multiverse (or, you know, whatever Rick feels like doing).
549 } = ensureDefaultsAndInferStates(inputContext);
550
551 const contextForOpenAI = {
552 ...processedContext,
553 _inferred_states_for_your_convenience: {
558 };
559 const userMessage = `Input Context JSON (with inferred states for your reference):\n${
560 JSON.stringify(contextForOpenAI, null, 2)
561 }`;
562
563 try {
564 const openai = new OpenAI();
565 const completion = await openai.chat.completions.create({
566 model: OPENAI_MODEL,
567 response_format: { type: "json_object" },
568 messages: [
576 const rawContent = completion.choices[0]?.message?.content;
577 if (!rawContent) {
578 console.error("OpenAI returned an empty response message.");
579 return new Response(
580 JSON.stringify(
581 getFallbackOutput("OpenAI empty response.", processedContext),
582 ),
583 { status: 500, headers: { "Content-Type": "application/json" } },
595 ) {
596 console.error(
597 "OpenAI response missing critical fields or incorrect structure.",
598 JSON.stringify(generatedJson, null, 2),
599 );
602 JSON.stringify(
603 getFallbackOutput(
604 "OpenAI response schema validation failed after generation.",
605 processedContext,
606 ),
618 });
619 } catch (error) {
620 console.error("Error during OpenAI API call or processing:", error);
621 let errorMessage = "Internal server error";
622 if (error.response && error.response.data && error.response.data.error) { // More specific OpenAI error
623 errorMessage = `OpenAI API Error: ${error.response.data.error.message}`;
624 } else if (error.message) {
625 errorMessage = error.message;

usmain.ts10 matches

@join•Updated 1 month ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { z } from "npm:zod";
4
524}
525
526async function callOpenAI(sysP: string, userP: string, mid: string, tid: string, log: LogFn): Promise<string | null> {
527 log("DB", "OpenAI", `Call tid=${tid}`, { sL: sysP.length, uL: userP.length }, mid, tid);
528 try { // @ts-ignore
529 const oai = new OpenAI();
530 const comp = await oai.chat.completions.create({
531 model: "gpt-4o-mini",
537 const usg = comp.usage;
538 if (!resT) {
539 log("WN", "OpenAI", `No text tid=${tid}.`, { usg, fin: comp.choices[0]?.finish_reason }, mid, tid);
540 return null;
541 }
542 log("IN", "OpenAI", `OK tid=${tid}`, { rL: resT.length, usg, fin: comp.choices[0]?.finish_reason }, mid, tid);
543 return resT.trim();
544 } catch (err: any) {
552 st: err.status,
553 };
554 log("ER", "OpenAI", `Fail tid=${tid}:${err.message}`, { e: eD }, mid, tid);
555 throw new Error(
556 `OpenAI Fail: ${err.message}` + (err.code ? `(C:${err.code},S:${err.status})` : `(S:${err.status})`),
557 );
558 }
785 return { mid, cid: tid, p: {} as TOD, e: `${aC.name} fail:PromptGenErr.` };
786 }
787 const rOR = await callOpenAI(sP, uP, mid, tid, l);
788 if (!rOR) {
789 l("WN", aC.name, `OpenAI no content tid=${tid}.`, 0, mid, tid);
790 return { mid, cid: tid, p: {} as TOD, e: `${aC.name} fail:AI no content.` };
791 }

FlexCalformatting.ts3 matches

@malcolmocean•Updated 1 month ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3// Interface for formatting rules
123export async function extractFlightInfoWithAI(event: any): Promise<string> {
124 try {
125 const openai = new OpenAI();
126
127 const prompt = `
135 `;
136
137 const completion = await openai.chat.completions.create({
138 messages: [
139 { role: "system", content: "You extract airport codes from flight information." },
vtProjectSearch

vtProjectSearchcomponents.tsx2 matches

@maxm•Updated 1 month ago
1246 <a href="?q=function" className="example-link">function</a>
1247 <a href="?q=discord" className="example-link">discord</a>
1248 <a href="?q=openai" className="example-link">openai</a>
1249 <a href="?q=react" className="example-link">react</a>
1250 </div>
1400 <a href="?q=function" className="example-link">function</a>
1401 <a href="?q=discord" className="example-link">discord</a>
1402 <a href="?q=openai" className="example-link">openai</a>
1403 <a href="?q=react" className="example-link">react</a>
1404 </div>

val-town-blogget-old-posts.ts5 matches

@pomdtr•Updated 1 month ago
198 },
199 {
200 "title": "An Introduction to OpenAI fine-tuning",
201 "slug": "an-introduction-to-openai-fine-tuning",
202 "link": "/blog/an-introduction-to-openai-fine-tuning",
203 "description": "How to customize OpenAI to your liking",
204 "pubDate": "Fri, 25 Aug 2023 00:00:00 GMT",
205 "author": "Steve Krouse",
417 "slug": "val-town-newsletter-16",
418 "link": "/blog/val-town-newsletter-16",
419 "description": "Our seed round, growing team, Codeium completions, @std/openai, and more",
420 "pubDate": "Mon, 22 Apr 2024 00:00:00 GMT",
421 "author": "Steve Krouse",

TommyAiREADME.md3 matches

@Bcbxbxbxb•Updated 1 month ago
29- Maintains context within conversations
30- Generates images based on text descriptions
31- Analyzes uploaded images using OpenAI's vision capabilities
32- Simple rule-based response system
33
47### Backend
48- Built with Hono for routing
49- OpenAI integration for image analysis
50- Val Town image generation service integration
51- Conversation context tracking with support for different message types
57
58### Image Analysis
59- Uses OpenAI's vision capabilities to analyze uploaded images
60- Supports common image formats (JPEG, PNG, etc.)
61- Provides detailed descriptions of image content

TommyAiindex.ts5 matches

@Bcbxbxbxb•Updated 1 month ago
4
5// For image analysis
6import { OpenAI } from "https://esm.town/v/std/openai";
7
8const app = new Hono();
9const openai = new OpenAI();
10
11// Unwrap Hono errors to see original error details
172}
173
174// Image analysis function using OpenAI
175async function analyzeImage(imageData: string) {
176 try {
178 const base64Image = imageData.split(',')[1];
179
180 // Call OpenAI API to analyze the image
181 const response = await openai.chat.completions.create({
182 model: "gpt-4o",
183 messages: [

openai2 file matches

@wangqiao1234•Updated 2 days ago

openaiproxy2 file matches

@wangqiao1234•Updated 2 days ago
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