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=132&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"(976ms)

awesomeREADME.md1 match

@stevekrouse•Updated 1 year ago
51- @pomdtr/serve_readme
52
53### OpenAI
54
55- @pomdtr/ask_ai

gptTagmain.tsx9 matches

@vladimyr•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}
20
21 return async function gpt(strings, ...values) {
22 const openai = await getOpenAI();
23
24 const input = strings.reduce((result, str, i) => {
34 };
35
36 const completion = await openai.chat.completions.create(createParams);
37
38 return { ...completion, content: completion.choices[0].message.content };

fetchAndStoreOpenAiUsage2README.md1 match

@nbbaier•Updated 1 year ago
1Migrated from folder: projects/OpenAiUsage/fetchAndStoreOpenAiUsage2

chatmain.tsx10 matches

@andreterron•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.
28 },
29): Promise<ChatCompletion & { content: string }> {
30 const openai = await getOpenAI();
31 const messages = Array.isArray(input) ? input : [{ role: "user", content: input }];
32 const createParams: ChatCompletionCreateParamsNonStreaming = {
34 messages,
35 };
36 const completion = await openai.chat.completions.create(createParams);
37
38 return { ...completion, content: completion.choices[0].message.content };

chatREADME.md4 matches

@andreterron•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(

awesomeREADME.md1 match

@pomdtr•Updated 1 year ago
51- @pomdtr/serve_readme
52
53### OpenAI
54
55- @pomdtr/ask_ai

apricotTurkeymain.tsx3 matches

@yawnxyz•Updated 1 year ago
1import { OpenAI } from "https://esm.town/v/std/openai?v=2";
2
3const openai = new OpenAI();
4const functionExpression = await openai.chat.completions.create({
5 "messages": [
6 { "role": "user", "content": "whats the weather in sf" },

weatherGPTREADME.md1 match

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

OpenAImain.tsx9 matches

@pomdtr•Updated 1 year ago
1import { type ClientOptions, OpenAI as RawOpenAI } from "npm:openai";
2
3/**
4 * API Client for interfacing with the OpenAI API. Uses Val Town credentials.
5 */
6export class OpenAI {
7 private rawOpenAIClient: RawOpenAI;
8
9 /**
10 * API Client for interfacing with the OpenAI API. Uses Val Town credentials.
11 *
12 * @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
19 */
20 constructor(options: Omit<ClientOptions, "baseURL" | "apiKey" | "organization"> = {}) {
21 this.rawOpenAIClient = new RawOpenAI({
22 ...options,
23 baseURL: "https://std-openaiproxy.web.val.run/v1",
24 apiKey: Deno.env.get("valtown"),
25 organization: null,
28
29 get chat() {
30 return this.rawOpenAIClient.chat;
31 }
32
33 get beta() {
34 return this.rawOpenAIClient.beta;
35 }
36}

OpenAIREADME.md6 matches

@pomdtr•Updated 1 year ago
1# OpenAI
2
3Get started using OpenAI's chat completion without the need to set your own API keys.
4
5## Usage
6
7Here's a quick example to get you started with the Val Town OpenAI wrapper:
8
9```ts
10import { OpenAI } from "https://esm.town/v/std/openai";
11
12const openai = new OpenAI();
13
14const functionExpression = await openai.chat.completions.create({
15 "messages": [
16 { "role": "user", "content": "Say hello in a creative way" },

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