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/$%7BsvgDataUrl%7D?q=openai&page=7&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 2311 results for "openai"(2372ms)

openai2 file matches

@stevekrouse•Updated 1 year ago

OpenAI2 file matches

@pomdtr•Updated 1 year ago

chat_openai1 file match

@cosmo•Updated 1 year ago

openAiFreeUsage2 file matches

@patrickjm•Updated 1 year ago

openaiOpenAPI2 file matches

@stevekrouse•Updated 1 year ago

openAiTextCompletion2 file matches

@patrickjm•Updated 1 year ago

openaiCompletion2 file matches

@fgeierst•Updated 1 year ago

demoOpenAIGPTSummary2 file matches

@zzz•Updated 1 year ago

openAiFreeQuotaExceeded2 file matches

@patrickjm•Updated 1 year ago

demoOpenAIGPT4Summary2 file matches

@zzz•Updated 1 year ago

kaymain.tsx13 matches

@legal•Updated 1 hour 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 9 hours 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
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