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/image-url.jpg%20%22Image%20title%22?q=openai&page=53&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 1632 results for "openai"(655ms)

medicalChatBotWebsitemain.tsx3 matches

@saiprabhas•Updated 1 month ago
98export default async function server(request: Request): Promise<Response> {
99 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
100 const { OpenAI } = await import("https://esm.town/v/std/openai");
101 const openai = new OpenAI();
102
103 const { message } = await request.json();
104
105 const completion = await openai.chat.completions.create({
106 messages: [
107 {

OpenTownieNormalsystem_prompt.txt4 matches

@dcm31•Updated 1 month ago
137Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
138
139### OpenAI
140```ts
141import { OpenAI } from "https://esm.town/v/std/openai";
142const openai = new OpenAI();
143const completion = await openai.chat.completions.create({
144 messages: [
145 { role: "user", content: "Say hello in a creative way" },

Women_In_STEMmain.tsx5 matches

@hadji_b•Updated 1 month ago
2import React, { useState, useEffect } from "https://esm.sh/react@18.2.0";
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4import { OpenAI } from "https://esm.town/v/std/openai";
5
6function WomenInSTEMBlog() {
80export default async function server(request: Request): Promise<Response> {
81 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
82 const { OpenAI } = await import("https://esm.town/v/std/openai");
83 const openai = new OpenAI();
84 const KEY = "Women_In_STEM";
85 const SCHEMA_VERSION = 5;
147 for (const woman of womenAndInventions) {
148 // Generate concise, inspirational biography
149 const biographyCompletion = await openai.chat.completions.create({
150 messages: [{
151 role: "user",
157
158 // Generate detailed invention description
159 const inventionCompletion = await openai.chat.completions.create({
160 messages: [{
161 role: "user",

bedtimeStoriesChatRoommain.tsx3 matches

@Precious37•Updated 1 month ago
108export default async function server(request: Request): Promise<Response> {
109 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
110 const { OpenAI } = await import("https://esm.town/v/std/openai");
111 const KEY = "bedtimeStoriesChatRoom";
112 const openai = new OpenAI();
113
114 // Increment version to force table recreation
149 // Generate bedtime story
150 if (url.pathname === "/story") {
151 const completion = await openai.chat.completions.create({
152 messages: [{
153 role: "user",

EchoPromptermain.tsx9 matches

@data•Updated 1 month ago
938if (typeof document !== "undefined") { client(); }
939export default async function server(request: Request): Promise<Response> {
940 const { OpenAI } = await import("https://esm.town/v/std/openai");
941 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
942 const openai = new OpenAI();
943
944 // Use the val's URL as a unique key for database tables
1041 const echoPrompt = getEchoPrompt();
1042
1043 const completion = await openai.chat.completions.create({
1044 messages: [
1045 {
1097
1098 // First, generate the agent prompt
1099 const completion2 = await openai.chat.completions.create({
1100 messages: [
1101 {
1123
1124 // Then, generate commands for the agent based on its purpose and description
1125 const commandsCompletion = await openai.chat.completions.create({
1126 messages: [
1127 {
1230 }
1231
1232 // Format the history into OpenAI message format
1233 const messages = [
1234 {
1240 // Add conversation history if it exists
1241 if (history && history.length > 0) {
1242 // Filter out system messages and map to OpenAI format
1243 history.forEach(msg => {
1244 if (msg.role !== "system") {
1258
1259 // Chat with the agent using the stored prompt and history
1260 const completion = await openai.chat.completions.create({
1261 messages: messages,
1262 model: "gpt-4o-mini",
1377
1378 // Execute the command with the AI
1379 const completion = await openai.chat.completions.create({
1380 messages: messages,
1381 model: "gpt-4o-mini",

fmrepexmain.tsx3 matches

@eneyeitech•Updated 1 month ago
14
15 try {
16 const { OpenAI } = await import("https://esm.town/v/std/openai");
17 const openai = new OpenAI();
18
19 const completion = await openai.chat.completions.create({
20 messages: [
21 {

Sparkmain.tsx5 matches

@Tade•Updated 1 month ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3// Telegram Bot Token - you would replace this with your actual bot token
5const TELEGRAM_API_URL = `https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}`;
6
7// OpenAI for generating research insights
8const openai = new OpenAI();
9
10// Helper function to send Telegram message
27async function processResearchRequest(text: string) {
28 try {
29 const completion = await openai.chat.completions.create({
30 messages: [
31 {
44 return completion.choices[0].message.content || "I couldn't generate a response.";
45 } catch (error) {
46 console.error("OpenAI Error:", error);
47 return "Sorry, there was an error processing your research request.";
48 }

AIContentHashtagsGeneratormain.tsx3 matches

@amrhucien•Updated 1 month ago
125 if (request.method === "POST") {
126 try {
127 const { OpenAI } = await import("https://esm.town/v/std/openai");
128 const openai = new OpenAI();
129
130 const { topic } = await request.json();
131
132 const completion = await openai.chat.completions.create({
133 messages: [
134 {

daringPlumOctopusmain.tsx3 matches

@amrhucien•Updated 1 month ago
125 if (request.method === "POST") {
126 try {
127 const { OpenAI } = await import("https://esm.town/v/std/openai");
128 const openai = new OpenAI();
129
130 const { topic } = await request.json();
131
132 const completion = await openai.chat.completions.create({
133 messages: [
134 {

content_idea_hashtag_generatormain.tsx3 matches

@amrhucien•Updated 1 month ago
125 if (request.method === "POST") {
126 try {
127 const { OpenAI } = await import("https://esm.town/v/std/openai");
128 const openai = new OpenAI();
129
130 const { topic } = await request.json();
131
132 const completion = await openai.chat.completions.create({
133 messages: [
134 {

translateToEnglishWithOpenAI1 file match

@shlmt•Updated 6 days ago

testOpenAI1 file match

@stevekrouse•Updated 1 week ago
lost1991
import { OpenAI } from "https://esm.town/v/std/openai"; export default async function(req: Request): Promise<Response> { if (req.method === "OPTIONS") { return new Response(null, { headers: { "Access-Control-Allow-Origin": "*",