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=5&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 1910 results for "openai"(978ms)

MYHEALTHSOURCEREADME.md1 match

@SIR_FESTUS•Updated 2 days ago
99## Environment Variables
100
101- `OPENAI_API_KEY` - Required for AI chatbot functionality (automatically configured in Val Town)
102- No other API keys required - uses open health data sources and local storage

MYHEALTHSOURCEchatbot.ts4 matches

@SIR_FESTUS•Updated 2 days ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { email } from "https://esm.town/v/std/email";
4import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
7const chatbot = new Hono();
8
9// Initialize OpenAI
10const openai = new OpenAI();
11
12// System prompt for the health assistant
52
53 // Get AI response
54 const completion = await openai.chat.completions.create({
55 model: "gpt-4o-mini",
56 messages: [

untitled-8907main.tsx11 matches

@join•Updated 3 days ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { z } from "npm:zod";
4
960}
961
962// --- OpenAI API Call ---
963async function callOpenAI(sysP: string, userP: string, mid: string, tid: string, log: LogFn): Promise<string | null> {
964 log("DB", "OpenAI", `Call tid=${tid}`, { sL: sysP.length, uL: userP.length }, mid, tid);
965 try { // @ts-ignore
966 const oai = new OpenAI(); // Assumes OPENAI_API_KEY is in env
967 const comp = await oai.chat.completions.create({
968 model: "gpt-4o-mini", // Using the specified model
974 const usg = comp.usage;
975 if (!resT) {
976 log("WN", "OpenAI", `No text tid=${tid}.`, { usg, fin: comp.choices[0]?.finish_reason }, mid, tid);
977 return null;
978 }
979 log("IN", "OpenAI", `OK tid=${tid}`, { rL: resT.length, usg, fin: comp.choices[0]?.finish_reason }, mid, tid);
980 return resT.trim();
981 } catch (err: any) {
990 st: err.status,
991 };
992 log("ER", "OpenAI", `Fail tid=${tid}:${err.message}`, { e: eD }, mid, tid);
993 throw new Error(
994 `OpenAI Fail: ${err.message}` + (err.code ? `(C:${err.code},S:${err.status})` : `(S:${err.status})`),
995 );
996 }
1240 return { mid, cid: tid, p: {} as TOD, e: `${aC.name} fail:PromptGenErr.` };
1241 }
1242 const rOR = await callOpenAI(sP, uP, mid, tid, l);
1243 if (!rOR) {
1244 l("WN", aC.name, `OpenAI no content tid=${tid}.`, {}, mid, tid);
1245 return { mid, cid: tid, p: {} as TOD, e: `${aC.name} fail:AI no content.` };
1246 }

untitled-5475main.tsx11 matches

@join•Updated 3 days ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { z } from "npm:zod";
4
960}
961
962// --- OpenAI API Call ---
963async function callOpenAI(sysP: string, userP: string, mid: string, tid: string, log: LogFn): Promise<string | null> {
964 log("DB", "OpenAI", `Call tid=${tid}`, { sL: sysP.length, uL: userP.length }, mid, tid);
965 try { // @ts-ignore
966 const oai = new OpenAI(); // Assumes OPENAI_API_KEY is in env
967 const comp = await oai.chat.completions.create({
968 model: "gpt-4o-mini", // Using the specified model
974 const usg = comp.usage;
975 if (!resT) {
976 log("WN", "OpenAI", `No text tid=${tid}.`, { usg, fin: comp.choices[0]?.finish_reason }, mid, tid);
977 return null;
978 }
979 log("IN", "OpenAI", `OK tid=${tid}`, { rL: resT.length, usg, fin: comp.choices[0]?.finish_reason }, mid, tid);
980 return resT.trim();
981 } catch (err: any) {
990 st: err.status,
991 };
992 log("ER", "OpenAI", `Fail tid=${tid}:${err.message}`, { e: eD }, mid, tid);
993 throw new Error(
994 `OpenAI Fail: ${err.message}` + (err.code ? `(C:${err.code},S:${err.status})` : `(S:${err.status})`),
995 );
996 }
1240 return { mid, cid: tid, p: {} as TOD, e: `${aC.name} fail:PromptGenErr.` };
1241 }
1242 const rOR = await callOpenAI(sP, uP, mid, tid, l);
1243 if (!rOR) {
1244 l("WN", aC.name, `OpenAI no content tid=${tid}.`, {}, mid, tid);
1245 return { mid, cid: tid, p: {} as TOD, e: `${aC.name} fail:AI no content.` };
1246 }

Chatbrainauto-responder.ts4 matches

@Venny•Updated 3 days ago
1// Automated response system for social media interactions
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
4import { TwitterAPI } from "./twitter-api.ts";
22
23export class AutoResponder {
24 private openai: OpenAI;
25 private twitterAPI: TwitterAPI;
26
27 constructor() {
28 this.openai = new OpenAI();
29 this.twitterAPI = new TwitterAPI();
30 this.initDatabase();
193Do not include hashtags in the response. Return only the response text.`;
194
195 const completion = await this.openai.chat.completions.create({
196 messages: [
197 {

Chatbrainindex.html1 match

@Venny•Updated 3 days ago
117 <p class="text-white/70 text-sm">
118 Add your API keys as environment variables:
119 <br>• OPENAI_API_KEY
120 <br>• TWITTER_API_KEY, TWITTER_API_SECRET
121 <br>• LINKEDIN_ACCESS_TOKEN

Chatbraincontent-generator.ts4 matches

@Venny•Updated 3 days ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2import type { ContentType, ContentTemplate, BotConfig, GenerateContentRequest } from "../shared/types.ts";
3
64
65export class ContentGenerator {
66 private openai: OpenAI;
67
68 constructor() {
69 this.openai = new OpenAI();
70 }
71
103
104 try {
105 const completion = await this.openai.chat.completions.create({
106 messages: [
107 {

ChatbrainREADME.md1 match

@Venny•Updated 3 days ago
30
311. Set up environment variables:
32 - `OPENAI_API_KEY` (for content generation)
33 - `TWITTER_API_KEY`, `TWITTER_API_SECRET`, `TWITTER_ACCESS_TOKEN`, `TWITTER_ACCESS_SECRET`
34 - `LINKEDIN_ACCESS_TOKEN` (optional)

Towniesystem_prompt.txt4 matches

@tsuchi_ya•Updated 3 days 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

@tsuchi_ya•Updated 3 days 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" },

openaiproxy2 file matches

@skutaans•Updated 11 hours ago

token-server1 file match

@kwhinnery_openai•Updated 1 day ago
Mint tokens to use with the OpenAI Realtime API for WebRTC
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