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/$%7Bart_info.art.src%7D?q=openai&page=99&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 1603 results for "openai"(1005ms)

multilingualchatroommain.tsx3 matches

@trob•Updated 6 months ago
498 const url = new URL(request.url);
499 const { blob } = await import("https://esm.town/v/std/blob");
500 const { OpenAI } = await import("https://esm.town/v/std/openai");
501
502 const openai = new OpenAI();
503
504 // Simple rate limiting
537
538 try {
539 const completion = await openai.chat.completions.create({
540 messages: [
541 {

openaimain.tsx9 matches

@std•Updated 6 months ago
1import { type ClientOptions, OpenAI as RawOpenAI } from "npm:openai";
2
3/**
4 * API Client for interfacing with the OpenAI API. Uses Val Town credentials.
5 */
6export class OpenAI {
7 private rawOpenAIClient: RawOpenAI;
8
9 /**
10 * API Client for interfacing with the OpenAI API. Uses Val Town credentials.
11 *
12 * @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
19 */
20 constructor(options: Omit<ClientOptions, "baseURL" | "apiKey" | "organization"> = {}) {
21 this.rawOpenAIClient = new RawOpenAI({
22 ...options,
23 baseURL: "https://std-openaiproxy.web.val.run/v1",
24 apiKey: Deno.env.get("valtown"),
25 organization: null,
28
29 get chat() {
30 return this.rawOpenAIClient.chat;
31 }
32
33 get beta() {
34 return {
35 chat: this.rawOpenAIClient.beta.chat,
36 };
37 }

crossmintSolanaTxGeneratormain.tsx3 matches

@alfongj•Updated 6 months ago
110
111export default async function server(request: Request): Promise<Response> {
112 const { OpenAI } = await import("https://esm.town/v/std/openai");
113 const openai = new OpenAI();
114
115 const url = new URL(request.url);
119
120 try {
121 const completion = await openai.chat.completions.create({
122 model: "gpt-4o",
123 messages: [

OpenAIUsagemain.tsx6 matches

@std•Updated 6 months ago
17 COUNT(*) AS count
18 FROM
19 openai_usage,
20 params
21 WHERE
38};
39
40export class OpenAIUsage {
41 constructor() {}
42 async migrate() {
43 await sqlite.batch([`CREATE TABLE IF NOT EXISTS openai_usage (
44 id INTEGER PRIMARY KEY,
45 user_id TEXT NOT NULL,
52 }
53 async drop() {
54 await sqlite.batch([`DROP TABLE IF EXISTS openai_usage`]);
55 }
56 async writeUsage(ur: UsageRow) {
57 sqlite.execute({
58 sql: "INSERT INTO openai_usage (user_id, handle, tier, tokens, model) VALUES (?, ?, ?, ?, ?)",
59 args: [ur.userId, ur.handle, ur.tier, ur.tokens, ur.model],
60 });
78 let resp = await sqlite.execute({
79 sql: `SELECT count(*)
80FROM openai_usage
81WHERE (
82 (model LIKE 'gpt-4%' AND model NOT LIKE '%mini%')

curiousTurquoiseDormousemain.tsx3 matches

@CoachCompanion•Updated 6 months ago
670 }
671
672 const { OpenAI } = await import("https://esm.town/v/std/openai");
673 const regenerateKey = request.headers.get("Regenerate-Key") || "0";
674 const openai = new OpenAI();
675
676 const { sport, skillLevel, ageGroup, groupSize, selectedTopics, sessionDuration } = await request.json();
707 Ensure that the conclusion ties together all the main concepts covered in the training, reinforces the learning objectives, and provides clear takeaways for both participants and coaches. The questions in the conclusion should prompt critical thinking about the skills practiced and their application in the sport.`;
708
709 const completion = await openai.chat.completions.create({
710 messages: [{ role: "user", content: prompt + `\n\nRegenerate key: ${regenerateKey}` }],
711 model: "gpt-4o-mini",

efficientAmberUnicornmain.tsx2 matches

@CoachCompanion•Updated 6 months ago
14 }
15
16 const { OpenAI } = await import("https://esm.town/v/std/openai");
17 const regenerateKey = request.headers.get("Regenerate-Key") || "0";
18 const openai = new OpenAI();
19
20 const { sport, skillLevel, ageGroup, groupSize, selectedTopics, sessionDuration } = await request.json();

pageshotmain.tsx1 match

@all•Updated 6 months ago
30 "settings": {
31 "model": "gpt-4o-mini",
32 "provider": "openai",
33 "system": "please summarize the following article in a 2-4 sentences, describing it from a 3rd person point of view",
34 "prompt": "{jina.content}"

podcastmain.tsx3 matches

@all•Updated 6 months ago
317
318 if (url.searchParams.has("nextMessage")) {
319 const { OpenAI } = await import("https://esm.town/v/std/openai");
320 const openai = new OpenAI();
321
322 const { personality1, personality2, topic, conversation, currentSpeaker } = await req.json();
328
329 const currentPersonality = currentSpeaker === 1 ? personality1 : personality2;
330 const response = await openai.chat.completions.create({
331 messages: [
332 {

findSlamArticlesmain.tsx3 matches

@dupontgu•Updated 6 months ago
1import cheerio from "https://esm.sh/cheerio@1.0.0-rc.12";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { blob } from "https://esm.town/v/std/blob";
4
5const openai = new OpenAI();
6export const BLOB_PREFIX = "SLAM_HEADLINE_"
7export const POST_PREFIX = "SLAM_POST_"
44
45export async function feedToChatGPT(newsItems: Headline[]): Promise<Slam[] | undefined > {
46 const completion = await openai.chat.completions.create({
47 messages: [
48 { role: "user", content: "Following is a list of headlines with the urls. For each headline, please determine the person or thing that is doing the slamming, and the person or thing that is being slammed. If you cannot determine this for a headline, skip it. Please return a list of JSON objects, each with a 'slammer' and 'slammed' key. Keep the values as short as possible, we don't need details about the subjects. Also include all the key/value pairs from the original object. Use as few words as possible to describe each, and don't use any words that are not included in the headline. Respond with only the JSON, no additional text or markdown.\n" + JSON.stringify(newsItems) },

aigreetingmain.tsx3 matches

@victorli•Updated 6 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(req: Request): Promise<Response> {
4 const openai = new OpenAI();
5
6 const completion = await openai.chat.completions.create({
7 messages: [
8 { role: "user", content: "Say hello in a creative way" },

translateToEnglishWithOpenAI1 file match

@shlmt•Updated 1 day ago

testOpenAI1 file match

@stevekrouse•Updated 3 days 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": "*",