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=130&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 1581 results for "openai"(1253ms)

openAiHelloWorldmain.tsx4 matches

@yawnxyz•Updated 1 year ago
1import { OpenAI } from "npm:openai";
2
3// Create a secret named OPENAI_API_KEY at https://www.val.town/settings/environment-variables
4
5const openai = new OpenAI();
6const functionExpression = await openai.chat.completions.create({
7 "messages": [
8 { "role": "user", "content": "Say hello in a creative way" },

openAIHonoChatStreamExampleREADME.md2 matches

@yawnxyz•Updated 1 year ago
1Example of using Hono to stream OpenAI's streamed chat responses!
2
3Migrated from folder: Utils/ai/examples/openAIHonoChatStreamExample

GistGPTmain.tsx3 matches

@weaverwhale•Updated 1 year ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { Hono } from "npm:hono";
3import { OpenAI } from "npm:openai";
4
5const gistGPT = async (input: string, about?: boolean) => {
8 const chatInput = about ? input : await (await fetch(input)).text();
9
10 const openai = new OpenAI();
11 let chatCompletion = await openai.chat.completions.create({
12 messages: [
13 {

valwritermain.tsx1 match

@yawnxyz•Updated 1 year ago
1/** @jsxImportSource npm:hono@3/jsx */
2import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
3import { chat } from "https://esm.town/v/stevekrouse/openai";
4import cronstrue from "npm:cronstrue";
5import { Hono } from "npm:hono@3";

PriestGPTmain.tsx3 matches

@mjweaver01•Updated 1 year ago
1import { Hono } from "npm:hono";
2import { OpenAI } from "npm:openai";
3
4const priestGPT = async (verse: string, about?: boolean) => {
5 const openai = new OpenAI();
6 let chatCompletion = await openai.chat.completions.create({
7 messages: [
8 {

PriestGPTREADME.md1 match

@mjweaver01•Updated 1 year ago
11
12
13If you fork this, you'll need to set `OPENAI_API_KEY` in your [Val Town Secrets](https://www.val.town/settings/secrets).
14
15

weatherBotmain.tsx7 matches

@jdan•Updated 1 year ago
2import { fetchWebpage } from "https://esm.town/v/jdan/fetchWebpage";
3import { weatherOfLatLon } from "https://esm.town/v/jdan/weatherOfLatLon";
4import { OpenAI } from "https://esm.town/v/std/openai?v=4";
5
6const openai = new OpenAI();
7
8const toolbox = {
9 "latLngOfCity": {
10 openAiTool: {
11 type: "function",
12 function: {
33 },
34 "weatherOfLatLon": {
35 openAiTool: {
36 type: "function",
37 function: {
60 },
61 "fetchWebpage": {
62 openAiTool: {
63 type: "function",
64 function: {
82};
83
84const tools = Object.values(toolbox).map(({ openAiTool }) => openAiTool);
85const transcript = [
86 { role: "user", content: "What's the weather in Hoboken, NJ? Do your best to follow URLs and summarize the weather instead of having the user do it." },
94
95async function runConversation() {
96 const response = await openai.chat.completions.create({
97 messages: transcript,
98 tools,

fetchWebpageREADME.md1 match

@jdan•Updated 1 year ago
1Migrated from folder: openai_function_calling/fetchWebpage

weatherOfLatLonREADME.md1 match

@jdan•Updated 1 year ago
1Migrated from folder: openai_function_calling/weatherOfLatLon

latLngOfCityREADME.md1 match

@jdan•Updated 1 year ago
1Migrated from folder: openai_function_calling/latLngOfCity

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