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=39&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 2151 results for "openai"(815ms)

MullbotgenerateFunFacts.tsx9 matches

@Shmully•Updated 2 weeks 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@4.26.0";
5
6const TABLE_NAME = `memories`;
71
72/**
73 * Generates fun facts for the next 7 days using OpenAI API
74 * @param previousFacts Previous fun facts to avoid duplication
75 * @returns Array of generated fun facts
78 try {
79 // Get API key from environment
80 const apiKey = Deno.env.get("OPENAI_API_KEY");
81 if (!apiKey) {
82 console.error("OpenAI API key is not configured.");
83 return null;
84 }
85
86 // Initialize OpenAI client
87 const openai = new OpenAI({ apiKey });
88
89 // Format previous facts for the prompt
139 console.log({ message });
140
141 // Call OpenAI API
142 const response = await openai.chat.completions.create({
143 model: "gpt-4-turbo-preview", // You can adjust the model as needed
144 messages: [
193/**
194 * Fallback parser for when JSON parsing fails
195 * @param responseText The raw response text from OpenAI
196 * @param expectedDates Array of expected dates for facts
197 * @returns Array of parsed facts

NPLLMsystem_prompt.txt4 matches

@wolf•Updated 2 weeks ago
89Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
90
91### OpenAI
92
93```ts
94import { OpenAI } from "https://esm.town/v/std/openai";
95const openai = new OpenAI();
96const completion = await openai.chat.completions.create({
97 messages: [
98 { role: "user", content: "Say hello in a creative way" },

simple-agentagent.tsx2 matches

@abrinz•Updated 2 weeks ago
1import { openai } from "npm:@ai-sdk/openai";
2import { generateText, streamText } from "npm:ai";
3import { getSystemPrompt } from "./prompt.tsx";
34
35 const options = {
36 model: openai("gpt-4.1"),
37 temperature: 0.1,
38 maxSteps,

AbercrombieSaleREADME.md4 matches

@ryanwashburne•Updated 2 weeks ago
192. It fetches the Abercrombie & Fitch website with browser-like headers
203. Extracts both general content and specific promotional elements
214. Uses OpenAI to analyze if there's a special sale or promotion
225. If a sale is detected, it sends an email notification with details
236. Tracks the state of sales to avoid sending duplicate notifications
322. The email will be sent to the email address associated with your Val Town account.
33
343. Make sure you have set up your OpenAI API key in Val Town environment variables.
35
36## Customization
46
47If the AI analysis isn't working:
48- Verify your OpenAI API key is correctly set in Val Town
49- Check if you have sufficient credits in your OpenAI account
50- Review the logs to see the AI's response and reasoning
1import { email } from "https://esm.town/v/std/email";
2import { blob } from "https://esm.town/v/std/blob";
3import { OpenAI } from "https://esm.town/v/std/openai";
4
5// This function will run on a schedule via cron
187// Function to use AI to analyze if there's a sale
188async function analyzeForSale(pageContent): Promise<SaleAnalysis> {
189 const openai = new OpenAI();
190
191 const prompt = `
219`;
220
221 const completion = await openai.chat.completions.create({
222 messages: [
223 { role: "user", content: prompt }

Edu_botapi.ts6 matches

@Dark_Guy_Dami•Updated 2 weeks ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import * as db from "../database/queries.ts";
4import type { ConversationRequest, ConversationResponse } from "../../shared/types.ts";
5
6const api = new Hono();
7const openai = new OpenAI();
8
9// Get all subjects
167 });
168
169 // Prepare messages for OpenAI
170 const systemPrompt = `You are an educational assistant helping a student learn about ${concept.title} in ${concept.subject}.
171Your goal is to explain concepts clearly, ask thoughtful questions to check understanding, and provide helpful feedback.
180 ];
181
182 // Get response from OpenAI
183 const completion = await openai.chat.completions.create({
184 messages: apiMessages,
185 model: "gpt-4o-mini",
201 let suggestedFollowUps: string[] = [];
202 try {
203 const followUpCompletion = await openai.chat.completions.create({
204 messages: [
205 ...apiMessages,

Edu_botREADME.md1 match

@Dark_Guy_Dami•Updated 2 weeks ago
46- Frontend: React with TypeScript
47- Database: SQLite for data storage
48- AI: OpenAI API for conversational learning
49- Styling: TailwindCSS

Motiv-ateREADME.md4 matches

@ogtegs•Updated 2 weeks ago
151. Enter your name or a keyword in the input field
162. Click the "Generate Quote" button
173. The application sends your input to the OpenAI API
184. A personalized motivational quote is generated and displayed
19
21
22- **Frontend**: HTML, CSS (Tailwind CSS), and JavaScript
23- **Backend**: Val Town HTTP trigger with OpenAI API integration
24- **AI**: Uses OpenAI's GPT-3.5-Turbo model to generate personalized quotes quickly
25
26## Project Structure
37## Dependencies
38
39- OpenAI API (via Val Town's standard library)
40- Tailwind CSS (via CDN)
41

Motiv-ateindex.ts6 matches

@ogtegs•Updated 2 weeks ago
1import { readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
2import { OpenAI } from "https://esm.town/v/std/openai";
3
4// Initialize OpenAI client
5const openai = new OpenAI();
6
7export default async function(req: Request): Promise<Response> {
27 }
28
29 // Generate quote using OpenAI - using gpt-3.5-turbo for faster response
30 const completion = await openai.chat.completions.create({
31 messages: [
32 {
44 });
45
46 console.log("OpenAI response:", completion); // Debug log
47
48 let quote = completion.choices[0]?.message?.content || "Could not generate a quote. Please try again.";

Towniesystem_prompt.txt4 matches

@dinavinter•Updated 2 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" },

openai-client1 file match

@cricks_unmixed4u•Updated 3 days ago

openai_enrichment6 file matches

@stevekrouse•Updated 4 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