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?q=openai&page=92&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 1639 results for "openai"(1149ms)

fondGrayRoadrunnermain.tsx3 matches

@tsuchi_yaUpdated 4 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3const openai = new OpenAI();
4
5const completion = await openai.chat.completions.create({
6 messages: [
7 { role: "user", content: "町田市について手短に説明してください。" },

aigeneratorblogmain.tsx8 matches

@websraiUpdated 4 months ago
11
12const AI_PROVIDERS = [
13 "OpenAI",
14 "Anthropic",
15 "Groq",
26 const [user, setUser] = useState(null);
27 const [adContent, setAdContent] = useState("");
28 const [selectedProvider, setSelectedProvider] = useState("OpenAI");
29 const [apiKey, setApiKey] = useState("");
30
38 const userData = await response.json();
39 setUser(userData);
40 setSelectedProvider(userData.aiProvider || "OpenAI");
41 setApiKey(userData.apiKey || "");
42 };
280export default async function server(request: Request): Promise<Response> {
281 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
282 const { OpenAI } = await import("https://esm.town/v/std/openai");
283 const openai = new OpenAI();
284
285 const SCHEMA_VERSION = 2;
306 (name, tier, contentGenerated, aiProvider, apiKey)
307 VALUES (?, ?, ?, ?, ?)
308 `, ["Demo User", "FREE", 0, "OpenAI", ""]);
309 user = (await sqlite.execute(`SELECT * FROM ${KEY}_users_${SCHEMA_VERSION} LIMIT 1`)).rows[0];
310 }
355 }
356
357 // Generate content using OpenAI
358 const completion = await openai.chat.completions.create({
359 messages: [
360 {

legalAssistantmain.tsx3 matches

@websraiUpdated 4 months ago
188export default async function server(request: Request): Promise<Response> {
189 if (request.method === "POST") {
190 const { OpenAI } = await import("https://esm.town/v/std/openai");
191 const openai = new OpenAI();
192
193 const { query } = await request.json();
203Query: ${query}`;
204
205 const completion = await openai.chat.completions.create({
206 messages: [{ role: "user", content: legalPrompt }],
207 model: "gpt-4o-mini",

seoKeywordResearchToolmain.tsx8 matches

@websraiUpdated 4 months ago
11
12const AI_PROVIDERS = [
13 "OpenAI",
14 "Anthropic",
15 "Groq",
26 const [user, setUser] = useState(null);
27 const [adContent, setAdContent] = useState("");
28 const [selectedProvider, setSelectedProvider] = useState("OpenAI");
29 const [apiKey, setApiKey] = useState("");
30
38 const userData = await response.json();
39 setUser(userData);
40 setSelectedProvider(userData.aiProvider || "OpenAI");
41 setApiKey(userData.apiKey || "");
42 };
280export default async function server(request: Request): Promise<Response> {
281 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
282 const { OpenAI } = await import("https://esm.town/v/std/openai");
283 const openai = new OpenAI();
284
285 const SCHEMA_VERSION = 2;
306 (name, tier, contentGenerated, aiProvider, apiKey)
307 VALUES (?, ?, ?, ?, ?)
308 `, ["Demo User", "FREE", 0, "OpenAI", ""]);
309 user = (await sqlite.execute(`SELECT * FROM ${KEY}_users_${SCHEMA_VERSION} LIMIT 1`)).rows[0];
310 }
355 }
356
357 // Generate content using OpenAI
358 const completion = await openai.chat.completions.create({
359 messages: [
360 {

telegramAudioMessageTranscriptionmain.tsx4 matches

@artemUpdated 4 months ago
137 }}
138 >
139 OPENAI_API_KEY
140 </code>
141 environment variable.
305 }
306
307 const { OpenAI } = await import("npm:openai");
308 const openai = new OpenAI({ apiKey: Deno.env.get("OPENAI_API_KEY") });
309
310 const arrayBuffer = await audioFile.arrayBuffer();
311 const transcription = await openai.audio.transcriptions.create({
312 file: new File([arrayBuffer], audioFile.name, { type: audioFile.type }),
313 model: "whisper-1",

Test00_getModelBuildermain.tsx11 matches

@lisazzUpdated 4 months ago
2export async function getModelBuilder(spec: {
3 type?: "llm" | "chat" | "embedding";
4 provider?: "openai" | "huggingface";
5} = { type: "llm", provider: "openai" }, options?: any) {
6 // 2. 使用動態導入以確保兼容性
7 const { extend, cond, matches } = await import("https://esm.sh/lodash-es");
16 const setup = cond([
17 [
18 matches({ type: "llm", provider: "openai" }),
19 async () => {
20 const { OpenAI } = await import("https://esm.sh/langchain/llms/openai");
21 return new OpenAI(args);
22 },
23 ],
24 [
25 matches({ type: "chat", provider: "openai" }),
26 async () => {
27 const { ChatOpenAI } = await import("https://esm.sh/langchain/chat_models/openai");
28 return new ChatOpenAI(args);
29 },
30 ],
31 [
32 matches({ type: "embedding", provider: "openai" }),
33 async () => {
34 const { OpenAIEmbeddings } = await import("https://esm.sh/langchain/embeddings/openai");
35 return new OpenAIEmbeddings(args);
36 },
37 ],

MILLENCHATmain.tsx16 matches

@LucasMillenUpdated 4 months ago
2// {
3// "name": "AI Chat Assistant",
4// "description": "A chat assistant using OpenAI's API",
5// "permissions": ["env"]
6// }
88}
89
90async function callOpenAI(userMessage: string): Promise<string> {
91 const apiKey = Deno.env.get("OPENAI_API_KEY");
92
93 if (!apiKey) {
94 throw new Error("OpenAI API key is not configured. Please set the OPENAI_API_KEY environment variable.");
95 }
96
97 try {
98 const response = await fetch('https://api.openai.com/v1/chat/completions', {
99 method: 'POST',
100 headers: {
117 if (!response.ok) {
118 const errorBody = await response.text();
119 throw new Error(`OpenAI API error: ${response.status} - ${errorBody}`);
120 }
121
124 "I'm not sure how to respond to that.";
125 } catch (error) {
126 console.error("OpenAI API Call Error:", error);
127 throw error;
128 }
140 const [input, setInput] = useState('');
141 const [isLoading, setIsLoading] = useState(false);
142 const [openAIError, setOpenAIError] = useState<string | null>(null);
143 const messagesEndRef = useRef<HTMLDivElement>(null);
144
167 setInput('');
168 setIsLoading(true);
169 setOpenAIError(null);
170
171 try {
172 const botReply = await callOpenAI(userMessage);
173 addMessage(botReply, 'bot');
174 } catch (error) {
179 : String(error);
180
181 setOpenAIError(errorMessage);
182 const fallbackResponse = generateFallbackResponse(userMessage);
183 addMessage(`Sorry, AI service error: ${errorMessage}. Fallback response: ${fallbackResponse}`, 'bot');
195 backgroundColor: '#f4f4f4'
196 }}>
197 {openAIError && (
198 <div style={{
199 backgroundColor: '#f8d7da',
203 borderRadius: '5px'
204 }}>
205 OpenAI Error: {openAIError}
206 </div>
207 )}
279
280export default async function server(request: Request): Promise<Response> {
281 // Check if OpenAI API key is configured
282 const apiKey = Deno.env.get("OPENAI_API_KEY");
283
284 if (!apiKey) {
313 <div class="error-container">
314 <h1>🚨 Configuration Error</h1>
315 <p>OpenAI API key is not configured. Please set the OPENAI_API_KEY environment variable.</p>
316 <p>Contact the val owner to resolve this issue.</p>
317 </div>

openai_svgmain.tsx4 matches

@stevekrouseUpdated 4 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function (req: Request): Promise<Response> {
117 }
118
119 // Generate SVG using OpenAI
120 const openai = new OpenAI();
121 const completion = await openai.chat.completions.create({
122 messages: [
123 { role: "system", content: "You are a helpful assistant that generates simple SVG images based on text input. Return only valid SVG code wrapped in ```xml tags without any explanation." },

dreamInterpreterAppmain.tsx3 matches

@BilelghrsalliUpdated 4 months ago
68export default async function server(request: Request): Promise<Response> {
69 if (request.method === "POST" && new URL(request.url).pathname === "/interpret") {
70 const { OpenAI } = await import("https://esm.town/v/std/openai");
71 const openai = new OpenAI();
72
73 const { dream } = await request.json();
74
75 try {
76 const completion = await openai.chat.completions.create({
77 messages: [
78 {

openai_svgREADME.md1 match

@stevekrouseUpdated 4 months ago
1# OpenAI SVG
2
3Generates an SVG based on the ?text input pararm

translateToEnglishWithOpenAI1 file match

@shlmtUpdated 1 week ago

testOpenAI1 file match

@stevekrouseUpdated 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": "*",