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/$1?q=openai&page=53&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 2160 results for "openai"(1813ms)

mandateagent_ecosystem.ts29 matches

@salon•Updated 3 weeks ago
4import { AgentContext, AgentInput, AgentOutput } from "https://esm.town/v/salon/mandate/interfaces.ts";
5import { fetch } from "https://esm.town/v/std/fetch";
6import { OpenAI } from "https://esm.town/v/std/openai";
7// If Deno.env is used, ensure it's for Val Town secrets if possible or clearly noted.
8// For direct Deno.env.get('OPENAI_API_KEY'), it relies on the Val Town environment variable being set.
9// The std/openai library usually handles API key abstraction using user's Val Town secrets.
10
11// Your provided summarizerAgent
27 }
28
29 const openai = new OpenAI(); // Using OpenAI client as per your example
30
31 log("INFO", "SummarizerAgent", "Generating summary with OpenAI...");
32 const completion = await openai.chat.completions.create({
33 model: "gpt-4o-mini", // Explicitly setting a model
34 messages: [
45
46 if (summary === "Could not generate summary.") {
47 log("WARN", "SummarizerAgent", "OpenAI did not return a valid summary content.");
48 }
49
200// Your provided combinerAgent (not directly used in the 12-step orchestrator, but kept for reference)
201export async function combinerAgent(
202 // ... (combinerAgent code as you provided, also updating its OpenAI call) ...
203 input: AgentInput<{
204 summary?: string;
254 }
255
256 const openai = new OpenAI(); // Using OpenAI client as per your example
257 log("INFO", "CombinerAgent", "Combining text with OpenAI...");
258 const completion = await openai.chat.completions.create({
259 model: "gpt-4o-mini", // Explicitly setting a model
260 messages: [
274 const combined = completion.choices[0]?.message?.content?.trim() ?? "Could not combine information.";
275 if (combined === "Could not combine information.")
276 log("WARN", "CombinerAgent", "OpenAI did not return valid combined content.");
277 log("SUCCESS", "CombinerAgent", "Combined successfully");
278 return { mandateId, correlationId: taskId, payload: { combined } };
336 const { userQuery } = input.payload;
337 log("INFO", "ConfigurationAgent", `Processing query: ${userQuery}`);
338 const openai = new OpenAI();
339
340 const systemPrompt =
347
348 try {
349 const completion = await openai.chat.completions.create({
350 model: "gpt-4o-mini",
351 messages: [{ role: "system", content: systemPrompt }, { role: "user", content: userQuery }],
483 const { log } = context;
484 const { articles, topic, keywords } = input.payload;
485 const openai = new OpenAI();
486 let relevantArticles: FetchedArticle[] = [];
487 log("INFO", "RelevanceAssessmentAgent", `Assessing relevance for ${articles.length} articles on topic: ${topic}`);
496 let assessment = { isRelevant: false, rationale: "LLM assessment failed or unclear." };
497 try {
498 const completion = await openai.chat.completions.create({
499 model: "gpt-4o-mini",
500 messages: [{ role: "system", content: "You are a relevance assessor. Output JSON." }, {
559): Promise<AgentOutput<{ articlesWithSentiment: FetchedArticle[] }>> {
560 const { log } = context;
561 const openai = new OpenAI();
562 let articlesWithSentiment: FetchedArticle[] = [];
563 if (!input.payload.articles)
572 let sentimentScore: FetchedArticle["sentimentScore"] = 0.0;
573 try {
574 const completion = await openai.chat.completions.create({
575 model: "gpt-4o-mini",
576 messages: [{ role: "system", content: "You are a sentiment analysis expert. Output JSON." }, {
607): Promise<AgentOutput<{ articlesWithThemes: FetchedArticle[] }>> {
608 const { log } = context;
609 const openai = new OpenAI();
610 let articlesWithThemes: FetchedArticle[] = [];
611 log(
621 let themeResult: { themes: string[]; entities: FetchedArticle["entities"] } = { themes: [], entities: [] };
622 try {
623 const completion = await openai.chat.completions.create({
624 model: "gpt-4o-mini",
625 messages: [{ role: "system", content: "You are a thematic/NER expert. Output JSON." }, {
653 const { log } = context;
654 const { articlesWithThemes, topic, historicalContextSummary } = input.payload;
655 const openai = new OpenAI();
656 log(
657 "INFO",
676 let trendReport: any = { dominantSentiment: "N/A", keyThemes: [], emergingPatterns: "Not analyzed." };
677 try {
678 const completion = await openai.chat.completions.create({
679 model: "gpt-4o-mini",
680 messages: [{ role: "system", content: "Trend analysis expert. Output JSON." }, {
697 let anomalyReport: any = { anomaliesFound: false, anomalyDetails: [] };
698 try {
699 const completion = await openai.chat.completions.create({
700 model: "gpt-4o-mini",
701 messages: [{ role: "system", content: "Anomaly detection expert. Output JSON." }, {
724 const { log } = context;
725 const { trendReport, anomalyReport, config, articlesCount } = input.payload;
726 const openai = new OpenAI();
727 log("INFO", "InsightGenerationAgent", `Generating insights for topic: ${config.topic}`);
728 const contextSummary =
737 let insights: string[] = ["No specific insights generated."];
738 try {
739 const completion = await openai.chat.completions.create({
740 model: "gpt-4o-mini",
741 messages: [{ role: "system", content: "Strategic analyst providing concise insights." }, {
852
853 log("INFO", "ReportCompilationAgent", `Compiling report for topic: ${config.topic}`); // Directly use 'config'
854 const openai = new OpenAI(); // Ensure API key is configured via environment variables or client options
855
856 // The agent code used 'relevantArticles'. If 'articlesWithThemes' is the correct data source
882 let finalReport = "Report generation failed.";
883 try {
884 const completion = await openai.chat.completions.create({
885 model: "gpt-4o-mini",
886 messages: [
912 const { log } = context;
913 const { anomalyReport, insights, config } = input.payload;
914 const openai = new OpenAI();
915 let criticalInfo = "";
916 if (anomalyReport?.anomaliesFound && anomalyReport.anomalyDetails.length > 0) {
932 let alertMessage: string | undefined = undefined;
933 try {
934 const completion = await openai.chat.completions.create({
935 model: "gpt-4o-mini",
936 messages: [{ role: "system", content: "Alert generation specialist." }, { role: "user", content: prompt }],

stevenns.cursorrules4 matches

@pugio•Updated 4 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" },

BizdevMain.ts11 matches

@Get•Updated 4 weeks ago
3import { validator } from "https://esm.sh/hono@4.3.7/validator";
4// Using @valtown/sqlite
5import { OpenAI } from "https://esm.town/v/std/openai?v=1";
6import { Batch, sqlite, Statement } from "https://esm.town/v/std/sqlite?v=4";
7
190
191async function draftColdEmail(
192 openai: OpenAI,
193 businessName: string | undefined,
194 websiteUrl: string,
241
242 try {
243 const chatCompletion = await openai.chat.completions.create({
244 model: "gpt-3.5-turbo",
245 messages: [{ role: "user", content: prompt }],
250 const responseText = chatCompletion.choices[0]?.message?.content?.trim();
251 if (!responseText) {
252 await updateLeadStatus(leadId, "error_drafting_empty_response", {}, "OpenAI returned empty response");
253 return null;
254 }
279 } catch (error) {
280 console.error(`Error drafting email for ${emailAddress} (lead ${leadId}):`, error);
281 await updateLeadStatus(leadId, "error_drafting", {}, `OpenAI API error: ${error.message}`);
282 return null;
283 }
286async function processJob(jobId: string, searchQuery: string) {
287 await updateJobStatus(jobId, "processing_search");
288 const openaiApiKey = Deno.env.get("openai");
289 if (!openaiApiKey) {
290 console.error("OpenAI API key secret 'openai' is not set.");
291 await updateJobStatus(jobId, "failed_config", "OpenAI API key not configured.");
292 return;
293 }
294 const openai = new OpenAI({ apiKey: openaiApiKey });
295
296 const websites = await searchWebsites(searchQuery, jobId);
327 const emailAddress = await extractEmailsFromWebsite(site.url, leadId);
328 if (emailAddress) {
329 await draftColdEmail(openai, truncatedBusinessName, site.url, emailAddress, searchQuery, leadId);
330 }
331 }

StarterPackFeeds.cursorrules4 matches

@moe•Updated 4 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" },

blog-cloneget-old-posts.ts5 matches

@jamiesinclair•Updated 4 weeks 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",

blogget-old-posts.ts5 matches

@jamiesinclair•Updated 4 weeks 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",

French_Bulldogmain.tsx5 matches

@ynonp•Updated 4 weeks ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2import { telegramSendMessage } from "https://esm.town/v/vtdocs/telegramSendMessage?v=5";
3import {
15 console.log(`received: ${text}`)
16 if (text) {
17 const response = await translateWithOpenAI(text);
18 console.log(`translated to: ${response}`);
19 ctx.reply(response);
33
34
35async function translateWithOpenAI(text: string) {
36 const openai = new OpenAI();
37 const completion = await openai.chat.completions.create({
38 messages: [
39 {

Mili_Botmain.tsx5 matches

@ynonp•Updated 4 weeks ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2import { telegramSendMessage } from "https://esm.town/v/vtdocs/telegramSendMessage?v=5";
3import {
15 console.log(`received: ${text}`)
16 if (text) {
17 const response = await translateWithOpenAI(text);
18 console.log(`translated to: ${response}`);
19 ctx.reply(response);
33
34
35async function translateWithOpenAI(text: string) {
36 const openai = new OpenAI();
37 const completion = await openai.chat.completions.create({
38 messages: [
39 {

selectmain.ts16 matches

@salon•Updated 4 weeks ago
4// SERVER-SIDE LOGIC (TypeScript)
5// =============================================================================
6import { OpenAI } from "https://esm.town/v/std/openai";
7
8// --- Configuration ---
23 maskSrc?: string;
24}
25interface OpenAIResponse {
26 races: RaceInfo[];
27}
105];
106
107// --- OpenAI Generation Function ---
108async function generateRaceDataWithOpenAI(): Promise<RaceInfo[]> {
109 const openai = new OpenAI();
110 const numToRequest = Math.max(1, NUM_CARDS_TO_GENERATE);
111 const prompt =
126Return STRICTLY as a single JSON object: { "races": [ { race1 }, { race2 }, ... ] }. No introductory text or explanations outside the JSON structure.`;
127 try {
128 console.info(`Requesting ${numToRequest} race data generation from OpenAI...`);
129 const completion = await openai.chat.completions.create({
130 model: "gpt-4o",
131 messages: [{ role: "user", content: prompt }],
134 });
135 const rawContent = completion.choices[0]?.message?.content;
136 if (!rawContent) throw new Error("OpenAI returned an empty response message.");
137
138 let parsedJson;
140 parsedJson = JSON.parse(rawContent);
141 } catch (parseError) {
142 console.error("Failed to parse OpenAI JSON response:", parseError);
143 console.error("Raw OpenAI response:", rawContent);
144 throw new Error(`JSON Parsing Error: ${parseError.message}`);
145 }
160 ) {
161 console.warn(
162 `OpenAI response JSON failed validation for ${numToRequest} races:`,
163 JSON.stringify(parsedJson, null, 2),
164 );
165 throw new Error(
166 "OpenAI response JSON structure, count, data types, color format, hint value, or mask URL invalid.",
167 );
168 }
169
170 const generatedData = (parsedJson as OpenAIResponse).races.map(race => ({
171 ...race,
172 borderAnimationHint: race.borderAnimationHint || "none",
173 }));
174 console.info(`Successfully generated and validated ${generatedData.length} races from OpenAI.`);
175 return generatedData;
176 } catch (error) {
177 console.error("Error fetching or processing data from OpenAI:", error);
178 console.warn("Using fallback race data due to the error.");
179 return fallbackRaceData.slice(0, numToRequest).map(race => ({
186// --- Main HTTP Handler (Val Town Entry Point) ---
187export default async function server(request: Request): Promise<Response> {
188 const activeRaceData = await generateRaceDataWithOpenAI();
189
190 const css = `

ArabicChef_Botmain.tsx5 matches

@ynonp•Updated 4 weeks ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2import { telegramSendMessage } from "https://esm.town/v/vtdocs/telegramSendMessage?v=5";
3import {
15 console.log(`received: ${text}`)
16 if (text) {
17 const response = await translateWithOpenAI(text);
18 console.log(`translated to: ${response}`);
19 ctx.reply(response);
33
34
35async function translateWithOpenAI(text: string) {
36 const openai = new OpenAI();
37 const completion = await openai.chat.completions.create({
38 messages: [
39 {

openai-client1 file match

@cricks_unmixed4u•Updated 4 days ago

openai_enrichment6 file matches

@stevekrouse•Updated 5 days ago
kwhinnery_openai
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