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/$%7Burl%7D?q=openai&page=83&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 1675 results for "openai"(1540ms)

adroitIvoryEchidnamain.tsx3 matches

@hashamqureshi•Updated 3 months ago
434export default async function server(request: Request): Promise<Response> {
435 if (request.method === 'POST' && request.url.includes('/recommendations')) {
436 const { OpenAI } = await import("https://esm.town/v/std/openai");
437 const openai = new OpenAI();
438
439 const { latitude, longitude } = await request.json();
459 `;
460
461 const completion = await openai.chat.completions.create({
462 messages: [{ role: "user", content: prompt }],
463 model: "gpt-4o-mini",

cerebrasTemplateREADME.md2 matches

@charmaine•Updated 3 months ago
35Use Cerebras for AI on the backend like so:
36
37const { OpenAI } = await import("https://esm.sh/openai");
38const client = new OpenAI({
39 apiKey: Deno.env.get("CEREBRAS_API_KEY"),
40 baseURL: "https://api.cerebras.ai/v1"

cerebrasTemplatemain.tsx2 matches

@charmaine•Updated 3 months ago
83 const { messages } = await request.json();
84
85 const { OpenAI } = await import("https://esm.sh/openai");
86 // Cerebras Inference
87 // Very important: do not change this
88 // Keep these comments so we remember not to change this
89 const client = new OpenAI({
90 apiKey: Deno.env.get("CEREBRAS_API_KEY"),
91 baseURL: "https://api.cerebras.ai/v1",

yc_findermain.tsx1 match

@reetkumarbind•Updated 3 months ago
18brian@airbnb.com,Brian Chesky
19drew@dropbox.com,Drew Houston
20sam@openai.com,Sam Altman
21tim@apple.com,Tim Cook
22jeff@amazon.com,Jeff Bezos

OpenAIChatCompletionmain.tsx9 matches

@rozek•Updated 3 months ago
1 import { InvocationTracker } from 'https://esm.town/v/rozek/InvocationTracker'
2 import { floatingQuotaTracker } from 'https://esm.town/v/rozek/floatingQuotaTracker'
3 import { OpenAI } from 'https://esm.town/v/std/openai'
4
5// don't forget to define Env.Var "OpenAIChatCompletion" for authorization!
6
7 interface Indexable { [Key:string]:any }
8
9/**** rate-limited access to the OpenAI API ****/
10
11 export default async function (Request:Request):Promise<Response> {
28 /**** handle authorization - but only if Env.Var. is set ****/
29
30 const AccessToken = process.env.OpenAIChatCompletion
31 if (AccessToken != null) {
32 const AuthHeader = Request.headers.get('Authorization')
43 /**** count this invocation ****/
44
45 const TrackingTable = 'OpenAIChatCompletion_Usage'
46 const Granularity_ = 15*60*1000 // how precisely should be logged?
47
51 /**** limit the rate at whic hthis resource is accessed ****/
52
53 const ResourceTable = 'OpenAIChatCompletion'
54 const ResourceLimit = 10 // max. number of allowed requests per period
55 const ResourcePeriod = 60*1000 // the period, given in ms
84 try {
85 if (stream == true) {
86 const CompletionStream = await new OpenAI().chat.completions.create({
87 ...ParameterSet, stream:true
88 })
109 })
110 } else {
111 const Completion = await new OpenAI().chat.completions.create({
112 ...ParameterSet, stream:false
113 })
118 }
119
120 return await OpenAIChatCompletion(Request)
121 }
122

chatmain.tsx6 matches

@Newboon•Updated 3 months ago
5 options = {},
6) => {
7 // Initialize OpenAI API stub
8 const { Configuration, OpenAIApi } = await import(
9 "https://esm.sh/openai@3.3.0"
10 );
11 const configuration = new Configuration({
12 apiKey: process.env.OPENAI,
13 });
14 const openai = new OpenAIApi(configuration);
15 // Request chat completion
16 const messages = typeof prompt === "string"
17 ? [{ role: "user", content: prompt }]
18 : prompt;
19 const { data } = await openai.createChatCompletion({
20 model: "gpt-3.5-turbo-0613",
21 messages,

memorySampleSummarymain.tsx3 matches

@AIWB•Updated 3 months ago
1import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
2import { OpenAI } from "https://esm.town/v/std/openai";
3
4const KEY = "memorySampleSummary";
6const SCHEMA_VERSION = 1;
7
8const openai = new OpenAI();
9
10// Initialize the database
22// Generate embedding for a given text
23async function generateEmbedding(text: string): Promise<number[]> {
24 const response = await openai.embeddings.create({
25 model: "text-embedding-ada-002",
26 input: text,

caloriesmain.tsx1 match

@AIWB•Updated 3 months ago
2import { fileToDataURL } from "https://esm.town/v/stevekrouse/fileToDataURL";
3import { modifyImage } from "https://esm.town/v/stevekrouse/modifyImage";
4import { chat } from "https://esm.town/v/stevekrouse/openai";
5import { Hono } from "npm:hono@3";
6

aiMessengermain.tsx3 matches

@tesla6940•Updated 3 months ago
409export default async function server(request: Request): Promise<Response> {
410 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
411 const { OpenAI } = await import("https://esm.town/v/std/openai");
412 const KEY = "aiMessenger";
413 const openai = new OpenAI();
414
415 const SCHEMA_VERSION = 5;
655 if (mode === "ai") {
656 // Generate AI response
657 const aiCompletion = await openai.chat.completions.create({
658 messages: [{
659 role: "user",

selfassuredCoralPigmain.tsx3 matches

@tesla6940•Updated 3 months ago
393export default async function server(request: Request): Promise<Response> {
394 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
395 const { OpenAI } = await import("https://esm.town/v/std/openai");
396 const KEY = "selfassuredCoralPig";
397 const openai = new OpenAI();
398
399 const SCHEMA_VERSION = 5;
616 if (mode === 'ai') {
617 // Generate AI response
618 const aiCompletion = await openai.chat.completions.create({
619 messages: [{
620 role: "user",

translateToEnglishWithOpenAI1 file match

@shlmt•Updated 1 week 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": "*",