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/?q=openai&page=1&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 345 results for "openai"(207ms)

vtProjectSearch

vtProjectSearchcomponents.tsx2 matches

@dcm31•Updated 10 hours ago
1246 <a href="?q=function" className="example-link">function</a>
1247 <a href="?q=discord" className="example-link">discord</a>
1248 <a href="?q=openai" className="example-link">openai</a>
1249 <a href="?q=react" className="example-link">react</a>
1250 </div>
1401 <a href="?q=function" className="example-link">function</a>
1402 <a href="?q=discord" className="example-link">discord</a>
1403 <a href="?q=openai" className="example-link">openai</a>
1404 <a href="?q=react" className="example-link">react</a>
1405 </div>

stevensDemo.cursorrules4 matches

@lixP•Updated 18 hours 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" },

stevens-openaihandleTelegramMessage.ts8 matches

@yash_ing•Updated 1 day ago
1import { Bot, webhookCallback } from "https://deno.land/x/grammy@v1.35.0/mod.ts";
2import { DateTime } from "https://esm.sh/luxon@3.4.4";
3import { OpenAI } from "npm:openai";
4import { backstory } from "../backstory.ts";
5import { formatMemoriesForPrompt, getRelevantMemories } from "../memoryUtils.ts";
78
79async function analyzeMessageContent(
80 openai: OpenAI,
81 username: string,
82 messageText: string,
101 const formattedHistory = chatHistory.length ? formatChatHistoryForAI(chatHistory) : [];
102
103 const completion = await openai.chat.completions.create({
104 model: "gpt-4o", // adjust as needed
105 max_tokens: 4096,
166bot.on("message", async (ctx) => {
167 try {
168 const OPENAI_KEY = Deno.env.get("OPENAI_API_KEY");
169 if (!OPENAI_KEY) {
170 console.error("OPENAI_API_KEY is not configured.");
171 await ctx.reply("I apologize, but I am not properly configured at present.");
172 return;
173 }
174
175 const openai = new OpenAI({ apiKey: OPENAI_KEY });
176
177 const messageText = ctx.message.text ?? "";
196
197 const chatHistory = await getChatHistory(chatId);
198 const analysis = await analyzeMessageContent(openai, username, messageText, chatHistory);
199
200 // ---------------- Memory CRUD ---------------- //

stevens-openaigenerateFunFacts.ts8 matches

@yash_ing•Updated 1 day ago
2import { nanoid } from "https://esm.sh/nanoid@5.0.5";
3import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
4import { OpenAI } from "npm:openai";
5
6const TABLE_NAME = `memories`;
63
64// -----------------------------------------------------------------------------
65// LLM: generate seven new fun‑facts (OpenAI)
66// -----------------------------------------------------------------------------
67async function generateFunFacts(previousFacts: { date: string; text: string }[]) {
68 const apiKey = Deno.env.get("OPENAI_API_KEY");
69 if (!apiKey) {
70 console.error("OPENAI_API_KEY is not configured.");
71 return [];
72 }
73
74 const openai = new OpenAI({ apiKey });
75
76 // Build auxiliary strings for the prompt
113
114 try {
115 const completion = await openai.chat.completions.create({
116 model: "gpt-4o-mini", // inexpensive; change if needed
117 max_tokens: 800,
145 }
146 } catch (err) {
147 console.error("OpenAI error while generating fun facts:", err);
148 return [];
149 }
211
212// -----------------------------------------------------------------------------
213// Manual test run (deno run funFactsOpenAI.ts)
214// -----------------------------------------------------------------------------
215if (import.meta.main) {

stevens-openaigetWeather.ts6 matches

@yash_ing•Updated 1 day ago
1import { getWeather, WeatherResponse } from "https://esm.town/v/geoffreylitt/getWeather";
2import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
3import { OpenAI } from "npm:openai";
4
5const TABLE_NAME = `memories`;
22
23/**
24 * Call OpenAI Chat Completions to compress a single day's forecast
25 * into a <25‑word sentence.
26 */
27async function generateConciseWeatherSummary(weatherDay: ReturnType<typeof summarizeWeather>[number]) {
28 const apiKey = Deno.env.get("OPENAI_API_KEY");
29 if (!apiKey) {
30 console.error("OPENAI_API_KEY is not configured.");
31 return null;
32 }
33
34 const openai = new OpenAI({ apiKey });
35
36 const systemPrompt = `You are a weather forecaster. Create a very concise summary of a day's forecast.`;
41
42 try {
43 const completion = await openai.chat.completions.create({
44 model: "gpt-4o-mini", // cheap & fast; change if desired
45 max_tokens: 100,

stevens-openaisendDailyBrief.ts10 matches

@yash_ing•Updated 1 day ago
1import { Bot } from "https://deno.land/x/grammy@v1.35.0/mod.ts";
2import { DateTime } from "https://esm.sh/luxon@3.4.4";
3import { OpenAI } from "npm:openai";
4import { backstory } from "../backstory.ts";
5import { BOT_SENDER_ID, BOT_SENDER_NAME, storeChatMessage } from "../importers/handleTelegramMessage.ts";
9
10/**
11 * Generate the daily briefing using OpenAI Chat Completions
12 */
13async function generateBriefingContent(
14 openai: OpenAI,
15 memories: Awaited<ReturnType<typeof getRelevantMemories>>,
16 today: DateTime,
77 };
78
79 // --------------- OPENAI CALL ----------------- //
80 const completion = await openai.chat.completions.create({
81 model: "gpt-4o", // adjust as desired
82 max_tokens: 3000,
97) {
98 // Get API keys from environment
99 const apiKey = Deno.env.get("OPENAI_API_KEY");
100 const telegramToken = Deno.env.get("TELEGRAM_TOKEN");
101
106
107 if (!apiKey) {
108 console.error("OPENAI_API_KEY is not configured.");
109 return;
110 }
120 }
121
122 // Initialize OpenAI client
123 const openai = new OpenAI({ apiKey });
124
125 // Initialize Telegram bot
140 // Generate briefing content
141 const content = await generateBriefingContent(
142 openai,
143 memories,
144 today,

stevens-openai.cursorrules4 matches

@yash_ing•Updated 1 day 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

@luke_f•Updated 1 day 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" },

valreadmegeneratormain.tsx3 matches

@dcm31•Updated 1 day ago
177 }
178
179 const { OpenAI } = await import("https://esm.town/v/std/openai");
180 const openai = new OpenAI();
181
182 const valTownClient = new ValTown({
197
198 try {
199 const completion = await openai.chat.completions.create({
200 model: "gpt-4o",
201 messages: [

valreadmegeneratorREADME.md1 match

@dcm31•Updated 1 day ago
43- **Deno:** The server-side environment.
44- **ValTown SDK:** Integrated to fetch Val details.
45- **OpenAI GPT-4:** To generate natural language README content.
46- **JavaScript Modules (ESM):** For seamless module imports.
47

stevens-openai5 file matches

@yash_ing•Updated 1 day ago

openaiPricing9 file matches

@nbbaier•Updated 1 week ago
Project created from val URLs