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/$%7Bsuccess?q=openai&page=131&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 1578 results for "openai"(407ms)

chatREADME.md4 matches

@weaverwhale•Updated 1 year ago
1# OpenAI ChatGPT helper function
2
3This val uses your OpenAI token if you have one, and the @std/openai if not, so it provides limited OpenAI usage for free.
4
5```ts
6import { chat } from "https://esm.town/v/stevekrouse/openai";
7
8const { content } = await chat("Hello, GPT!");
11
12```ts
13import { chat } from "https://esm.town/v/stevekrouse/openai";
14
15const { content } = await chat(

poembuilder3main.tsx1 match

@stevekrouse•Updated 1 year ago
1/** @jsxImportSource npm:hono@3/jsx */
2import { OpenAI } from "https://esm.town/v/std/openai?v=2";
3import { sqlite } from "https://esm.town/v/std/sqlite?v=5";
4import { Hono } from "npm:hono@3";

poembuildermain.tsx1 match

@stevekrouse•Updated 1 year ago
1/** @jsxImportSource npm:hono@3/jsx */
2import { OpenAI } from "https://esm.town/v/std/openai?v=2";
3import { sqlite } from "https://esm.town/v/std/sqlite?v=5";
4import { Hono } from "npm:hono@3";

openaiUploadFilemain.tsx3 matches

@yawnxyz•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function openaiUploadFile({ key, data, filename = "data.json", purpose = "assistants" }: {
4 key: string;
5 data: any;
17 formData.append("purpose", purpose);
18 formData.append("file", file, filename);
19 let result = await fetch("https://api.openai.com/v1/files", {
20 method: "POST",
21 headers: {
25 }).then((r) => r.json());
26 if (result.error)
27 throw new Error("OpenAI Upload Error: " + result.error.message);
28 else
29 return result;

openaiFineTuneDatamain.tsx6 matches

@stevekrouse•Updated 1 year ago
1import { delay } from "https://esm.town/v/stevekrouse/delay";
2import { openaiFineTune } from "https://esm.town/v/stevekrouse/openaiFineTune";
3import { openaiUploadFile } from "https://esm.town/v/stevekrouse/openaiUploadFile?v=15";
4
5export async function openaiFineTuneData({ key, data, model }: {
6 key: string;
7 data: any;
8 model?: string;
9}) {
10 let upload = await openaiUploadFile({
11 key,
12 data,
13 });
14 let fineTune = await openaiFineTune({
15 key,
16 model,
21 console.log("File not ready, will try again in a second");
22 await delay(1000);
23 fineTune = await openaiFineTune({
24 key,
25 model,

openaiUploadFilemain.tsx3 matches

@stevekrouse•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function openaiUploadFile({ key, data, purpose = "assistants" }: {
4 key: string;
5 data: any;
16 formData.append("purpose", purpose);
17 formData.append("file", file, "data.json");
18 let result = await fetch("https://api.openai.com/v1/files", {
19 method: "POST",
20 headers: {
24 }).then((r) => r.json());
25 if (result.error)
26 throw new Error("OpenAI Upload Error: " + result.error.message);
27 else
28 return result;

oliveButterflymain.tsx3 matches

@yawnxyz•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function openaiUploadFile({ key, data, purpose = "assistants" }: {
4 key: string;
5 data: any;
16 formData.append("purpose", purpose);
17 formData.append("file", file, "data.json");
18 let result = await fetch("https://api.openai.com/v1/files", {
19 method: "POST",
20 headers: {
24 }).then((r) => r.json());
25 if (result.error)
26 throw new Error("OpenAI Upload Error: " + result.error.message);
27 else
28 return result;

openaiUploadFileREADME.md1 match

@yawnxyz•Updated 1 year ago
1Migrated from folder: Libraries/ai/OpenAI/openaiUploadFile

openaimain.tsx10 matches

@stevekrouse•Updated 1 year ago
1import type { ChatCompletion, ChatCompletionCreateParamsNonStreaming, Message } from "npm:@types/openai";
2
3async function getOpenAI() {
4 // if you don't have a key, use our std library version
5 if (Deno.env.get("OPENAI_API_KEY") === undefined) {
6 const { OpenAI } = await import("https://esm.town/v/std/openai");
7 return new OpenAI();
8 } else {
9 const { OpenAI } = await import("npm:openai");
10 return new OpenAI();
11 }
12}
13
14/**
15 * Initiates a chat conversation with OpenAI's GPT model and retrieves the content of the first response.
16 * This function can handle both single string inputs and arrays of message objects.
17 * It supports various GPT models, allowing for flexibility in choosing the model based on the application's needs.
25 options?: Omit<ChatCompletionCreateParamsNonStreaming, "messages">,
26): Promise<ChatCompletion & { content: string }> {
27 const openai = await getOpenAI();
28 const messages = Array.isArray(input) ? input : [{ role: "user", content: input }];
29 const createParams: ChatCompletionCreateParamsNonStreaming = {
33 messages,
34 };
35 const completion = await openai.chat.completions.create(createParams);
36
37 return { ...completion, content: completion.choices[0].message.content };

weatherGPTmain.tsx1 match

@seflless•Updated 1 year ago
20
21export default async function weatherGPT(req: Request) {
22 const { OpenAI } = await import("npm:openai");
23
24 if (new URL(req.url).pathname === "/data") {

testOpenAI1 file match

@stevekrouse•Updated 1 day ago

testOpenAI1 file match

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