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 2542 results for "openai"(5365ms)

funmain.tsx3 matches

@joinโ€ขUpdated 15 hours ago
4import { blob } from "https://esm.town/v/std/blob?v=11";
5// @ts-ignore
6import { OpenAI } from "https://esm.town/v/std/openai?v=4";
7
8// --- CONSTANTS ---
302// Route to handle new message submissions
303app.post("/submit", async (c) => {
304 const openai = new OpenAI();
305 const body = await c.req.json();
306 const { text, style } = body;
314
315 try {
316 const completion = await openai.chat.completions.create({
317 model: "gpt-4o",
318 messages: [

Towniesystem_prompt.txt4 matches

@chetanshi29โ€ขUpdated 19 hours 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" },

Townie.cursorrules4 matches

@chetanshi29โ€ขUpdated 19 hours 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" },

ContextualLiteREADME.md9 matches

@c15rโ€ขUpdated 1 day ago
27โ”‚ โ”‚ โ”œโ”€โ”€ files-tools.ts # Files store tool handlers
28โ”‚ โ”‚ โ”œโ”€โ”€ code-tools.ts # Code execution tool handlers
29โ”‚ โ”‚ โ””โ”€โ”€ openai-tools.ts # OpenAI API tool handlers
30โ”‚ โ””โ”€โ”€ valtown/
31โ”‚ โ””โ”€โ”€ client.ts # Val Town API client (for admin features)
116- **admin-project-info**: Get project information and structure overview using Val Town API (admin only)
117
118#### OpenAI API Tools
119- **openai-chat-completion**: Create chat completions using OpenAI's API via Val Town's built-in OpenAI integration (supports GPT-4, GPT-3.5, and other models)
120
121## OpenAI Integration
122
123The server includes OpenAI chat completion functionality using Val Town's built-in OpenAI integration. This provides seamless access to OpenAI's models without requiring additional API key configuration.
124
125### Example Usage
134 "method": "tools/call",
135 "params": {
136 "name": "openai-chat-completion",
137 "arguments": {
138 "messages": [
154 "method": "tools/call",
155 "params": {
156 "name": "openai-chat-completion",
157 "arguments": {
158 "messages": [
433- `tools["files-exists"](args)` - Check if file exists in your personal file store
434- `tools["files-metadata"](args)` - Get file metadata from your personal file store
435- `tools["openai-chat-completion"](args)` - Create OpenAI chat completions
436
437### Two Execution Modes
488**Note**: `AWS_SECRET_ACCESS_KEY` is NOT set as an environment variable. Instead, it's passed via the Authorization header for security.
489
490**OpenAI Integration**: OpenAI functionality uses Val Town's built-in OpenAI integration, which automatically handles API key management. No additional environment variables are required for OpenAI tools.
491
492### DynamoDB Table Schema

ContextualLitedefinitions.ts7 matches

@c15rโ€ขUpdated 1 day ago
362] as const;
363
364// OpenAI Tools
365export const OPENAI_TOOLS = [
366 {
367 name: "openai-chat-completion",
368 description: "Create a chat completion using OpenAI's API via Val Town's OpenAI integration",
369 inputSchema: {
370 type: "object",
391 model: {
392 type: "string",
393 description: "The OpenAI model to use",
394 default: "gpt-4o-mini",
395 enum: [
565 ...FILES_TOOLS,
566 ...CODE_TOOLS,
567 ...OPENAI_TOOLS,
568] as const;
569
573 ...FILES_TOOLS,
574 ...CODE_TOOLS,
575 ...OPENAI_TOOLS,
576 ...ADMIN_TOOLS,
577] as const;

whats-appmain.tsx4 matches

@wxwโ€ขUpdated 1 day ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2import { zodResponseFormat } from "npm:openai/helpers/zod";
3import { z } from "npm:zod";
4
6
7const VERIFY_TOKEN = "butler";
8const openai = new OpenAI();
9const app = new Hono();
10
79
80export async function parseReminder(text: string) {
81 const completion = await openai.chat.completions.create({
82 messages: [
83 {

OnboardCompanyREADME.md4 matches

@nicโ€ขUpdated 1 day ago
661. **Website Discovery**: If no website is provided, searches DuckDuckGo to find the company's official website
672. **HTML Fetching**: Retrieves the raw HTML from the company's homepage
683. **AI Logo Extraction**: Uses OpenAI's GPT-4o-mini with enhanced logic to locate the company logo
694. **Format Prioritization**: Prefers Inline SVG > SVG files > PNG > other image formats
705. **Inline SVG Conversion**: Converts inline SVG elements to base64 encoded data URLs
752. **Page Discovery**: Tries multiple pages including homepage, /about, /contact, /about-us, /contact-us, /company, /locations, /office, /headquarters
763. **HTML Analysis**: Fetches HTML from each page until an address is found
774. **AI Address Extraction**: Uses OpenAI to locate and format the company's physical address
78
79## Example Usage
147## Rate Limits
148
149This API uses OpenAI's services, so it's subject to OpenAI's rate limits. For production use, consider implementing caching and rate limiting.
150
151## Technical Details
152
153- Built with Hono framework on Val Town
154- Uses OpenAI GPT-4o-mini for logo and address extraction
155- Supports both provided websites and automatic website discovery
156- Handles relative and absolute URL conversion

OnboardCompanyindex.ts12 matches

@nicโ€ขUpdated 1 day ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { OpenAI } from "https://esm.town/v/std/openai";
3
4const app = new Hono();
102}
103
104// Helper function to extract logo URL using OpenAI
105async function extractLogoUrl(html: string, websiteUrl: string): Promise<string | null> {
106 try {
107 // Use custom API key if provided, otherwise use Val Town's built-in integration
108 const apiKey = Deno.env.get('OPENAI_API_KEY');
109 const openai = apiKey ? new OpenAI({ apiKey }) : new OpenAI();
110
111 const prompt = `I will provide you with the HTML source code of a company's website. Please examine the HTML to locate the company logo and return the appropriate URL or data.
163${html.substring(0, 25000)}`; // Increased for better SVG detection
164
165 const completion = await openai.chat.completions.create({
166 messages: [
167 { role: "user", content: prompt }
190 return result;
191 } catch (error) {
192 console.error('Error extracting logo URL with OpenAI:', error);
193 return null;
194 }
225}
226
227// Helper function to extract company address using OpenAI
228async function extractCompanyAddress(html: string, websiteUrl: string): Promise<string | null> {
229 try {
230 // Use custom API key if provided, otherwise use Val Town's built-in integration
231 const apiKey = Deno.env.get('OPENAI_API_KEY');
232 const openai = apiKey ? new OpenAI({ apiKey }) : new OpenAI();
233
234 const prompt = `I will provide you with the HTML source code of a company's website. Please examine the HTML to locate the company's physical address/headquarters address.
249${html.substring(0, 15000)}`;
250
251 const completion = await openai.chat.completions.create({
252 messages: [
253 { role: "user", content: prompt }
266 return result;
267 } catch (error) {
268 console.error('Error extracting company address with OpenAI:', error);
269 return null;
270 }
316 console.log(`Extracting logo URL from HTML (${html.length} characters)...`);
317
318 // Extract logo URL using OpenAI
319 const logoUrl = await extractLogoUrl(html, websiteUrl);
320

untitled-6961main.tsx4 matches

@joinโ€ขUpdated 1 day ago
1// @ts-ignore
2import { OpenAI } from "https://esm.town/v/std/openai?v=4";
3// @ts-ignore
4import { Hono } from "npm:hono@4.4.12";
298}
299
300// --- BACKEND LOGIC: HONO ROUTER & OPENAI INTEGRATION ---
301
302const app = new Hono();
305app.post("/generate-config-ui", async (c) => {
306 try {
307 const openai = new OpenAI();
308
309 // The kernel matrices are too large to be useful in the prompt, so they are omitted.
312 .replace("<SVG_SOURCE>", SVG_SOURCE_CODE);
313
314 const completion = await openai.chat.completions.create({
315 model: "gpt-4o",
316 messages: [

typo2main.tsx3 matches

@joinโ€ขUpdated 2 days ago
1// @ts-ignore
2import { OpenAI } from "https://esm.town/v/std/openai?v=4";
3import { Hono } from "npm:hono@4.4.12";
4
251
252 try {
253 const openai = new OpenAI();
254 const completion = await openai.chat.completions.create({
255 model: "gpt-4o", // Using gpt-4o for better spatial reasoning and precise output
256 messages: [

openai2 file matches

@wangqiao1234โ€ขUpdated 1 week ago

openaiproxy2 file matches

@wangqiao1234โ€ขUpdated 1 week ago
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