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=121&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 1606 results for "openai"(628ms)

coralCarpmain.tsx6 matches

@willthereader•Updated 10 months ago
1/** @jsxImportSource https://esm.sh/react */
2import OpenAI from "npm:openai";
3import { renderToString } from "npm:react-dom/server";
4const openai = new OpenAI();
5import { Hono } from "npm:hono@3";
6
47const app = new Hono();
48app.get("/", async (c) => {
49 const thread = await openai.beta.threads.create();
50 const assistant = await openai.beta.assistants.create({
51 name: "",
52 instructions:
106 const message = c.req.query("message");
107
108 await openai.beta.threads.messages.create(
109 threadId,
110 { role: "user", content: message },
118 ));
119 };
120 const run = openai.beta.threads.runs.stream(threadId, {
121 assistant_id: assistantId,
122 // Make sure we only display messages we haven't seen yet.

emeraldRaccoonmain.tsx6 matches

@willthereader•Updated 10 months ago
1/** @jsxImportSource https://esm.sh/react */
2import OpenAI from "npm:openai";
3import { renderToString } from "npm:react-dom/server";
4const openai = new OpenAI();
5import { Hono } from "npm:hono@3";
6
47const app = new Hono();
48app.get("/", async (c) => {
49 const thread = await openai.beta.threads.create();
50 const assistant = await openai.beta.assistants.create({
51 name: "",
52 instructions:
106 const message = c.req.query("message");
107
108 await openai.beta.threads.messages.create(
109 threadId,
110 { role: "user", content: message },
118 ));
119 };
120 const run = openai.beta.threads.runs.stream(threadId, {
121 assistant_id: assistantId,
122 // Make sure we only display messages we haven't seen yet.

emeraldRaccoonREADME.md1 match

@willthereader•Updated 10 months ago
1# ChatGPT Implemented in Val Town
2
3Demonstrated how to use assistants and threads with the OpenAI SDK and how to stream the response with Server-Sent Events

valTownChatGPTREADME.md1 match

@willthereader•Updated 10 months ago
1# ChatGPT Implemented in Val Town
2
3Demonstrated how to use assistants and threads with the OpenAI SDK and how to stream the response with Server-Sent Events

valTownChatGPTmain.tsx6 matches

@willthereader•Updated 10 months ago
1/** @jsxImportSource https://esm.sh/react */
2import OpenAI from "npm:openai";
3import { renderToString } from "npm:react-dom/server";
4const openai = new OpenAI();
5import { Hono } from "npm:hono@3";
6
47const app = new Hono();
48app.get("/", async (c) => {
49 const thread = await openai.beta.threads.create();
50 const assistant = await openai.beta.assistants.create({
51 name: "",
52 instructions:
106 const message = c.req.query("message");
107
108 await openai.beta.threads.messages.create(
109 threadId,
110 { role: "user", content: message },
118 ));
119 };
120 const run = openai.beta.threads.runs.stream(threadId, {
121 assistant_id: assistantId,
122 // Make sure we only display messages we haven't seen yet.

getContentFromUrlmain.tsx3 matches

@willthereader•Updated 10 months ago
61 prompt = prompt || "Summarize this article in 30 words, focusing on the primary author. Do not respond with JSON or XML or stage instructions. Only reply in text. Text:"
62 let result = await ai({
63 provider: "openai",
64 model: "gpt-3.5-turbo",
65 prompt: prompt + content
71 prompt = prompt || "Return a comma separated list of 3-4 tags that broadly describes the text. Do not repeat the given text. Just return text and commas, no other symbols. Text to categorize:"
72 let result = await ai({
73 provider: "openai",
74 model: "gpt-3.5-turbo",
75 prompt: prompt + content
80export const getEmbeddingsFn = async (content) => {
81 let result = await ai({
82 provider: "openai",
83 embed:true,
84 value: content

tomatoMinnowmain.tsx2 matches

@nicoalbanese•Updated 10 months ago
1import { openai } from "npm:@ai-sdk/openai";
2import { StreamingTextResponse, streamText } from "npm:ai";
3
4export default async function(req: Request): Promise<Response> {
5 const result = await streamText({
6 model: openai("gpt-4o"),
7 prompt: "Generate a fast recipe for Lasagna.",
8 });

tomatoMinnowREADME.md1 match

@nicoalbanese•Updated 10 months ago
2Use the Vercel AI SDK in your Vals.
3
4**Note**: you must add your OpenAI key to your Val Town [Env variables](https://www.val.town/settings/environment-variables) under `OPENAI_API_KEY`. If you would like to specify a different name for your API Key, you can [create a custom OpenAI provider](https://sdk.vercel.ai/providers/ai-sdk-providers/openai#provider-instance) with the `createOpenAI` function.
5
6Prefer another AI provider? Use [any supported provider](https://sdk.vercel.ai/providers/ai-sdk-providers) by changing just two lines of code!

tealBadgermain.tsx3 matches

@stevekrouse•Updated 11 months ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2export default async function(req: Request): Promise<Response> {
3 const openai = new OpenAI();
4 const stream = await openai.chat.completions.create({
5 stream: true,
6 messages: [{ role: "user", content: "Write a poem in the style of beowulf about the DMV" }],

openAIStreamingExamplemain.tsx3 matches

@stevekrouse•Updated 11 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 const stream = await openai.chat.completions.create({
6 stream: true,
7 messages: [{

translateToEnglishWithOpenAI1 file match

@shlmt•Updated 2 days ago

testOpenAI1 file match

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