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=13&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 1569 results for "openai"(1283ms)

stevensDemo.cursorrules4 matches

@arawlinsUpdated 1 week 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" },

Futuremain.tsx12 matches

@salonUpdated 1 week ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
3import * as ta from "npm:technicalindicators";
362}
363
364async function callOpenAI(
365 systemPrompt: string,
366 userMessage: string,
372): Promise<{ role: "assistant" | "system"; content: string }> {
373 const callId = Math.random().toString(36).substring(2, 8);
374 const logPfx = `OpenAI Call [${agentName} ${taskId.split("-")[1] || taskId} ${callId}]`;
375 try {
376  log("DEBUG", agentName, `${logPfx}: Initiating (${model}, JSON: ${isJsonOutputRequired})...`);
377  const openai = new OpenAI();
378  const res = await openai.chat.completions.create({
379   model,
380   messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userMessage }],
384  const content = res.choices?.[0]?.message?.content;
385  if (!content) {
386   log("ERROR", agentName, `${logPfx}: OpenAI returned empty/invalid response.`);
387   throw new Error("Invalid/empty AI response.");
388  }
394  let code = err.status || (err.response ? err.response.status : null);
395  const errData = err.response?.data || err.error || err.response || err;
396  if (errData?.message) { errMsg = `OpenAI Err (${code || "?"}) via ${agentName}: ${errData.message}`; }
397  else if (errData?.error?.message) { errMsg = `OpenAI Err (${code || "?"}) via ${agentName}: ${errData.error.message}`; }
398  else if (err.message) { errMsg += ` Details: ${err.message}`; }
399  else { try { errMsg += ` Unknown err: ${JSON.stringify(errData)}`; } catch { errMsg += " Unknown non-serializable err."; }}
402  else if (code === 400) errMsg += " (ACTION: Bad request/prompt issue)";
403  else if (err.code === "ENOTFOUND" || err.code === "ECONNREFUSED" || err.cause?.code === "UND_ERR_CONNECT_TIMEOUT") errMsg += " (ACTION: Network error)";
404  else if (code >= 500) errMsg += " (ACTION: OpenAI server issue)";
405  const escapedErr = errMsg.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\n/g, "\\n");
406  if (isJsonOutputRequired) {
659 const taskId = task.taskId;
660 log("INFO", agentName, `Task ${taskId}. Processing goals. Hash: ${hashCode(JSON.stringify(task.payload))}`);
661 const result = await callOpenAI(
662  tickerSuggestionAgentSystemPrompt,
663  JSON.stringify(task.payload),
999  },
1000 });
1001 const result = await callOpenAI(
1002  tickerInterpretationAgentSystemPrompt,
1003  input,
1111  pastPerformanceContext: pastPerformanceContext ?? "N/A",
1112 });
1113 const result = await callOpenAI(
1114  synthesisChartingDataAgentSystemPrompt,
1115  input,

stevensDemo.cursorrules4 matches

@satcarUpdated 1 week 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

@ziipoUpdated 1 week 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

@BrandonSmithUpdated 1 week 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

@macbookandrewUpdated 1 week 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

@tnorthcuttUpdated 1 week 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" },

Futuremain.tsx13 matches

@GetUpdated 1 week ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
3import * as ta from "npm:technicalindicators";
237}
238
239// --- OpenAI Call Function ---
240async function callOpenAI(
241 systemPrompt: string,
242 userMessage: string,
248): Promise<{ role: "assistant" | "system"; content: string }> {
249 const callId = Math.random().toString(36).substring(2, 8);
250 const logPfx = `OpenAI Call [${agentName} ${taskId.split("-")[1] || taskId} ${callId}]`;
251 try {
252 log("DEBUG", agentName, `${logPfx}: Initiating (${model}, JSON: ${isJsonOutputRequired})...`);
253 const openai = new OpenAI();
254 const res = await openai.chat.completions.create({
255 model,
256 messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userMessage }],
260 const content = res.choices?.[0]?.message?.content;
261 if (!content) {
262 log("ERROR", agentName, `${logPfx}: OpenAI returned empty/invalid response.`);
263 throw new Error("Invalid/empty AI response.");
264 }
270 let code = err.status || (err.response ? err.response.status : null);
271 const errData = err.response?.data || err.error || err.response || err;
272 if (errData?.message) { errMsg = `OpenAI Err (${code || "?"}) via ${agentName}: ${errData.message}`; }
273 else if (errData?.error?.message) {
274 errMsg = `OpenAI Err (${code || "?"}) via ${agentName}: ${errData.error.message}`;
275 }
276 else if (err.message) { errMsg += ` Details: ${err.message}`; }
285 " (ACTION: Bad request/prompt issue)"; else if (
286 err.code === "ENOTFOUND" || err.code === "ECONNREFUSED" || err.cause?.code === "UND_ERR_CONNECT_TIMEOUT"
287 ) errMsg += " (ACTION: Network error)"; else if (code >= 500) errMsg += " (ACTION: OpenAI server issue)";
288 const escapedErr = errMsg.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\n/g, "\\n");
289 if (isJsonOutputRequired) {
595 const taskId = task.taskId;
596 log("INFO", agentName, `Task ${taskId}. Goals hash: ${hashCode(JSON.stringify(task.payload))}`);
597 const result = await callOpenAI(
598 tickerSuggestionAgentSystemPrompt,
599 JSON.stringify(task.payload),
938 context: { newsSentiment: context?.newsSentiment?.[ticker] ?? "N/A" },
939 });
940 const result = await callOpenAI(
941 tickerInterpretationAgentSystemPrompt,
942 input,
1054 pastPerformanceContext: pastPerformanceContext ?? "N/A",
1055 });
1056 const result = await callOpenAI(
1057 synthesisChartingDataAgentSystemPrompt,
1058 input,

vt-blog-1get-old-posts.ts5 matches

@charmaineUpdated 1 week 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",

stevensDemo.cursorrules4 matches

@stasistrapUpdated 1 week 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" },

testOpenAI1 file match

@shouserUpdated 1 day ago

testOpenAI1 file match

@stevekrouseUpdated 1 day 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": "*",