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=107&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 1618 results for "openai"(534ms)

add_to_notion_w_aimain.tsx3 matches

@junhoca•Updated 8 months ago
3import Instructor from "npm:@instructor-ai/instructor";
4import { Client } from "npm:@notionhq/client";
5import OpenAI from "npm:openai";
6import { z } from "npm:zod";
7
26};
27
28const oai = new OpenAI({
29 apiKey: process.env.OPENAI_API_KEY ?? undefined,
30});
31

TopHackerNewsDailyEmailmain.tsx6 matches

@browserbase•Updated 8 months ago
1import { loadPageContent } from "https://esm.town/v/charlypoly/browserbaseUtils";
2import { OpenAI } from "https://esm.town/v/std/openai?v=4";
3import { z } from "npm:zod";
4import { zodToJsonSchema } from "npm:zod-to-json-schema";
25});
26
27// we create a OpenAI Tool that takes our schema as argument
28const extractContentTool: any = {
29 type: "function",
36};
37
38const openai = new OpenAI();
39
40// We ask OpenAI to extract the content from the given web page.
41// The model will reach out to our `extract_content` tool and
42// by doing so, the model will extract the required data to satisfy
43// the requirement of `extract_content`s argument.
44const completion = await openai.chat.completions.create({
45 model: "gpt-4-turbo",
46 messages: [
55});
56
57// we retrieve the serialized arguments generated by OpenAI
58const result = completion.choices[0].message.tool_calls![0].function.arguments;
59// the serialized arguments are parsed into a valid JavaScript array of objects

digitalYellowRoadrunnermain.tsx3 matches

@athyuttamre•Updated 8 months ago
1import { OpenAI } from "npm:openai";
2import { zodResponseFormat } from "npm:openai/helpers/zod";
3import { z } from "npm:zod";
4
9});
10
11const client = new OpenAI({ apiKey: Deno.env.get("OPENAI_API_KEY") });
12
13async function main() {

genvalmain.tsx1 match

@andreterron•Updated 8 months ago
38 }
39 const code = await generateValCode(
40 process.env.VT_OPENAI_KEY,
41 value.description,
42 );

telegramBotHandlermain.tsx1 match

@stevekrouse•Updated 8 months ago
21 try {
22 let resp = await textToImageDalle(
23 process.env.openai,
24 text.replace("/dalle", ""),
25 1,

ChatGPTTextDefinitionUserscriptmain.tsx1 match

@xsec•Updated 8 months ago
100 // Configuration
101 const API_CONFIG = {
102 url: "https://willthereader-openaidefiner.web.val.run",
103 method: "POST",
104 mode: "cors",

chatREADME.md4 matches

@xsec•Updated 8 months 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(

chatmain.tsx10 matches

@xsec•Updated 8 months 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 };

bedtimeStoryMakerREADME.md2 matches

@daniellevine•Updated 8 months ago
13* and activity (befriends aliens, goes to the doctor, rides a rollercoaster, bakes a cake for friends)
14
15It uses OpenAI to write a children's bedtime story
16
17* title
21for a "fantastical story about a green whale who rides the bus" or the "spooky story about the tomato fox who explores a cave".
22
23Then using the summary, OpenAI geenrates another prompt to describe the instructions to generate a children's story book image.
24
25That's sent to Fal to generate an image.

bedtimeStoryMakermain.tsx1 match

@daniellevine•Updated 8 months ago
15import { generateOpenGraphTags, OpenGraphData } from "https://esm.town/v/dthyresson/generateOpenGraphTags";
16import { ValTownLink } from "https://esm.town/v/dthyresson/viewOnValTownComponent";
17import { chat } from "https://esm.town/v/stevekrouse/openai";
18import * as fal from "npm:@fal-ai/serverless-client";
19

translateToEnglishWithOpenAI1 file match

@shlmt•Updated 4 days ago

testOpenAI1 file match

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