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/$2?q=openai&page=26&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 2571 results for "openai"(1803ms)

factoid-trivia.instructions.md4 matches

@bmitchinson•Updated 3 weeks 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" },

kaymain.tsx13 matches

@legal•Updated 3 weeks ago
18 * is defined directly in the main function handler below.
19 *
20 * Assumes the 'openai' secret, containing your OpenAI API key, is set in your Val Town environment.
21 *
22 * Last Updated: 2024-05-22
651export default async function(req: Request) {
652 // --- Dynamic Imports ---
653 const { OpenAI } = await import("https://esm.town/v/std/openai");
654 const { fetch } = await import("https://esm.town/v/std/fetch");
655 const { PDFExtract } = await import("npm:pdf.js-extract");
662 max_pdf_size_mb: 10,
663 text_truncation_length: 25000,
664 openai_model_name: "gpt-4o",
665 contact_form_placeholders_en: { name: "Your Name", email: "Your Email", message: "Message" },
666 contact_form_placeholders_es: { name: "Tu Nombre", email: "Tu Correo", message: "Mensaje" },
827 }
828
829 // --- Helper Function: Call OpenAI API ---
830 async function callOpenAI(
831 openai: OpenAI,
832 systemPrompt: string,
833 userMessage: string,
834 modelFromConfig = APP_CONFIG.openai_model_name || "gpt-4o",
835 expectJson = false,
836 ): Promise<{ role: "assistant" | "system"; content: string | object }> {
837 const model = modelFromConfig;
838 try {
839 const response = await openai.chat.completions.create({
840 model,
841 messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userMessage }],
856 }
857 } catch (error) {
858 console.error("OpenAI API Error:", error.message);
859 return { role: "system", content: `AI Error: ${error.message}` };
860 }
892 log: LogEntry[],
893 ): Promise<LogEntry[]> {
894 const openai = new OpenAI();
895 log.push({ agent: "System", type: "step", message: "Workflow started." });
896
943
944 const agentSystemPrompt = agentConfig.system_prompt.replace("{{document_text}}", truncText);
945 const agentResult = await callOpenAI(
946 openai,
947 agentSystemPrompt,
948 truncText,
949 APP_CONFIG.openai_model_name,
950 agentConfig.expects_json,
951 );
Plantfo

Plantfoindex.ts8 matches

@Llad•Updated 3 weeks ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2import { sqlite } from "https://esm.town/v/std/sqlite";
3import { readFile } from "https://esm.town/v/std/utils/index.ts";
56}
57
58// Initialize OpenAI
59const openai = new OpenAI();
60
61// Initialize cache on startup with error handling
176 }
177
178 console.log(`Fetching fresh data from OpenAI for: "${plantName}"`);
179 // If not cached, fetch from OpenAI
180 const prompt =
181 `Please provide detailed information about the plant "${plantName}" in the following JSON format. Be specific and accurate:
194Only return the JSON object, no additional text.`;
195
196 const completion = await openai.chat.completions.create({
197 messages: [
198 { role: "user", content: prompt },
206
207 if (!responseText) {
208 return c.json({ error: "No response from OpenAI" }, 500);
209 }
210
218 }
219
220 // Parse the JSON response from OpenAI
221 const plantInfo: PlantInfo = JSON.parse(cleanedResponse);
222

docjocmain.tsx4 matches

@legal•Updated 3 weeks ago
878
879export default async function(req: Request) {
880 const { OpenAI } = await import("https://esm.town/v/std/openai");
881 const { PDFExtract } = await import("npm:pdf.js-extract");
882
892 const action = url.searchParams.get("action");
893 const sourceUrl = import.meta.url.replace("esm.town", "val.town");
894 const openai = new OpenAI();
895 const MAX_TEXT_SUGGEST = 20000;
896 const MAX_TEXT_ANALYZE = 30000;
921 agentName: string,
922 ): Promise<object> {
923 log.push({ agent: agentName, type: "step", message: `Calling OpenAI gpt-4o...` });
924 try {
925 const response = await openai.chat.completions.create({
926 model: "gpt-4o",
927 messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userMessage }],

Synthesizemain.tsx6 matches

@talkbot•Updated 3 weeks ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2import { Hono } from "npm:hono";
3
4// Initialize Hono for routing and OpenAI for the LLM
5const app = new Hono();
6const openai = new OpenAI();
7
8/**
44
45 try {
46 // Call the OpenAI Chat Completions API
47 const completion = await openai.chat.completions.create({
48 model: "gpt-4o",
49 messages: [
63 return c.json(jsonData);
64 } catch (error) {
65 console.error("Error calling OpenAI or parsing JSON:", error);
66 // Return a structured error message if something goes wrong
67 return c.json({

OpenAIProxymain.tsx3 matches

@talkbot•Updated 3 weeks ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3const openai = new OpenAI();
4const completion = await openai.chat.completions.create({
5 "messages": [
6 { "role": "user", "content": "Say hello in a creative way" },

stravachat.cursorrules4 matches

@katzenj•Updated 3 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" },

Towniesystem_prompt.txt4 matches

@ianmenethil•Updated 3 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" },

Townie.cursorrules4 matches

@ianmenethil•Updated 3 weeks 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" },

stevensDemo.cursorrules4 matches

@asim13june•Updated 3 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" },

openai2 file matches

@wangqiao1234•Updated 2 weeks ago

openaiproxy2 file matches

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