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=45&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 1604 results for "openai"(895ms)

blog1get-old-posts.ts5 matches

@charmaine•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",

sbirmain.tsx15 matches

@Learn•Updated 1 month ago
1// Combined Frontend (React/ChakraUI) and Backend (Hono/OpenAI) for Val Town
2// Funding Assistant Dashboard Prototype - v6 (Corrected AgencyInfo Prompt Logic)
3
509export default async function server(request: Request): Promise<Response> {
510 // Only import server-side dependencies here
511 const { OpenAI } = await import("https://esm.town/v/std/openai");
512 // const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite"); // DB optional
513 const { Hono } = await import("npm:hono");
514
515 // --- OpenAI Client ---
516 // Ensure API key is set as Val Town env var 'openai'
517 let openai;
518 try {
519 openai = new OpenAI();
520 } catch (e) {
521 console.error("FATAL: Failed to initialize OpenAI client. Is the 'openai' environment variable set?", e);
522 // Return a generic server error response if OpenAI cannot be initialized
523 return new Response(JSON.stringify({ error: "Server configuration error. Unable to initialize OpenAI client." }), {
524 status: 500,
525 headers: { "Content-Type": "application/json" },
675 ];
676
677 // --- Call OpenAI ---
678 console.log(`Calling OpenAI for agent: ${agentType}...`);
679 const completion = await openai.chat.completions.create({
680 messages: messages,
681 model: "gpt-4o",
706
707 } catch (error) {
708 // Catches errors in request handling, OpenAI API call itself, etc.
709 console.error(`Critical error initiating agent ${agentType}:`, error);
710 let errorMsg = `Server error initiating agent ${agentType}.`;
711 // Check for specific OpenAI errors if needed for better diagnostics
712 // if (error instanceof OpenAI.APIError) { errorMsg = `OpenAI API Error: ${error.status} ${error.message}`; }
713 else if (error.message) {
714 errorMsg = `${errorMsg} Details: ${error.message}`;

blogget-old-posts.ts5 matches

@valdottown•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",

blog-vt2get-old-posts.ts5 matches

@jxnblk•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",

exemplaryTanFireflymain.tsx3 matches

@toowired•Updated 1 month ago
12
13async function gpt4(prompt: string): Promise<string> {
14 const { OpenAI } = await import("https://esm.town/v/std/openai");
15 const openai = new OpenAI();
16 const completion = await openai.chat.completions.create({
17 messages: [{ role: "user", content: prompt }],
18 model: "gpt-4-mini",

Open-Toowniesystem_prompt.txt4 matches

@toowired•Updated 1 month ago
137Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
138
139### OpenAI
140```ts
141import { OpenAI } from "https://esm.town/v/std/openai";
142const openai = new OpenAI();
143const completion = await openai.chat.completions.create({
144 messages: [
145 { role: "user", content: "Say hello in a creative way" },

OpenTowniesystem_prompt.txt4 matches

@neverstew•Updated 1 month ago
137Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
138
139### OpenAI
140```ts
141import { OpenAI } from "https://esm.town/v/std/openai";
142const openai = new OpenAI();
143const completion = await openai.chat.completions.create({
144 messages: [
145 { role: "user", content: "Say hello in a creative way" },

ingeniousYellowRavenmain.tsx9 matches

@Learn•Updated 1 month ago
567// --- Backend Server (Val Town) ---
568export default async function server(request: Request): Promise<Response> {
569 const { OpenAI } = await import("https://esm.town/v/std/openai");
570
571 if (request.method === "OPTIONS") {
590 if (request.method === "POST" && new URL(request.url).pathname === "/grade-card") {
591 try {
592 // Check for OpenAI API Key in Val Town secrets
593 const openai = new OpenAI(); // Assumes OPENAI_API_KEY is set in Val Town secrets
594 const { imageBase64 } = await request.json();
595 if (!imageBase64 || typeof imageBase64 !== "string") {
600 }
601
602 console.log("Received image data, preparing request to OpenAI...");
603
604 const modelChoice = "gpt-4o"; // Or "gpt-4o-mini"
605
606 // --- Construct the detailed prompt for OpenAI ---
607 const prompt = `
608Alright, listen up, collector fam—here’s the no-BS, sharp-as-a-PSA-10 shorthand guide to grading and authenticating cards. No fluff, just gospel truths. Let’s get it:
712`;
713
714 const response = await openai.chat.completions.create({
715 model: modelChoice,
716 response_format: { type: "json_object" },
734 });
735
736 console.log("Received response from OpenAI.");
737
738 const jsonString = response.choices[0]?.message?.content;
739 if (!jsonString) {
740 throw new Error("OpenAI did not return valid response content.");
741 }
742
746 console.log("Successfully parsed JSON response.");
747 } catch (parseError) {
748 console.error("Failed to parse JSON from OpenAI:", jsonString);
749 throw new Error("AI returned improperly formatted JSON data.");
750 }

campycardsmain.tsx9 matches

@find•Updated 1 month ago
567// --- Backend Server (Val Town) ---
568export default async function server(request: Request): Promise<Response> {
569 const { OpenAI } = await import("https://esm.town/v/std/openai");
570
571 if (request.method === "OPTIONS") {
590 if (request.method === "POST" && new URL(request.url).pathname === "/grade-card") {
591 try {
592 // Check for OpenAI API Key in Val Town secrets
593 const openai = new OpenAI(); // Assumes OPENAI_API_KEY is set in Val Town secrets
594 const { imageBase64 } = await request.json();
595 if (!imageBase64 || typeof imageBase64 !== "string") {
600 }
601
602 console.log("Received image data, preparing request to OpenAI...");
603
604 const modelChoice = "gpt-4o"; // Or "gpt-4o-mini"
605
606 // --- Construct the detailed prompt for OpenAI ---
607 const prompt = `
608 Alright, listen up, collector fam—here’s the no-BS, sharp-as-a-PSA-10 shorthand guide to grading and authenticating cards. No fluff, just gospel truths. Let’s get it:
727`;
728
729 const response = await openai.chat.completions.create({
730 model: modelChoice,
731 response_format: { type: "json_object" },
749 });
750
751 console.log("Received response from OpenAI.");
752
753 const jsonString = response.choices[0]?.message?.content;
754 if (!jsonString) {
755 throw new Error("OpenAI did not return valid response content.");
756 }
757
761 console.log("Successfully parsed JSON response.");
762 } catch (parseError) {
763 console.error("Failed to parse JSON from OpenAI:", jsonString);
764 throw new Error("AI returned improperly formatted JSON data.");
765 }

aircraftmain.tsx12 matches

@Learn•Updated 1 month ago
757// --- Backend Server (Val Town / Cloud Function) ---
758export default async function server(request: Request): Promise<Response> {
759 // Dynamically import OpenAI only when needed on the server
760 const { OpenAI } = await import("https://esm.town/v/std/openai");
761
762 // Standard CORS preflight handling
782 if (request.method === "POST" && new URL(request.url).pathname === "/analyze-aircraft") {
783 try {
784 // Check for OpenAI API Key in Val Town secrets (Val Town automatically injects process.env)
785 // The library handles finding the key from secrets/env vars.
786
787 const openai = new OpenAI(); // Instantiates with key from secrets
788
789 const { imageBase64 } = await request.json();
796 }
797
798 console.log("Received image data for aircraft analysis, preparing request to OpenAI...");
799
800 const modelChoice = "gpt-4o"; // Use the powerful vision model
801
802 // --- Construct the detailed prompt for OpenAI ---
803 // This prompt guides the AI to act as an aircraft maintenance analyzer.
804 const prompt = `
899`;
900
901 // --- Call OpenAI API ---
902 const response = await openai.chat.completions.create({
903 model: modelChoice,
904 response_format: { type: "json_object" }, // Enforce JSON output
926 });
927
928 console.log("Received response from OpenAI for aircraft analysis.");
929
930 const jsonString = response.choices[0]?.message?.content;
931 if (!jsonString) {
932 throw new Error("OpenAI did not return valid response content.");
933 }
934
936 try {
937 parsedResponse = JSON.parse(jsonString);
938 console.log("Successfully parsed JSON response from OpenAI.");
939 } catch (parseError) {
940 console.error("Failed to parse JSON from OpenAI:", jsonString);
941 // Try to provide the invalid JSON in the error for debugging
942 throw new Error(`AI returned improperly formatted JSON data. Received: ${jsonString.substring(0, 500)}...`);

translateToEnglishWithOpenAI1 file match

@shlmt•Updated 1 day ago

testOpenAI1 file match

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