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=26&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 2123 results for "openai"(686ms)

untitled-8907main.tsx11 matches

@join•Updated 1 week 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 1 week 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 1 week 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 1 week 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 1 week 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 1 week 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 1 week 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 1 week 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" },

val.cursorrules4 matches

@amine•Updated 1 week 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" },

cerebras_coderindex.ts1 match

@downchuck_gmail_com•Updated 1 week ago
140 <option value="meta-llama/llama-3.1-8b-instruct">Llama 3.1 8B</option>
141 <option value="anthropic/claude-3.5-sonnet">Claude 3.5 Sonnet</option>
142 <option value="openai/gpt-4o">GPT-4o</option>
143 </>
144 )}

openai-client1 file match

@cricks_unmixed4u•Updated 2 days ago

openai_enrichment6 file matches

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