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/$2?q=openai&page=173&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 1972 results for "openai"(1986ms)

WriterOptionsmain.tsx1 match

@nbbaier•Updated 1 year ago
1import { type ClientOptions } from "npm:openai";
2
3export interface WriterOptions extends ClientOptions {

draftReadmeREADME.md3 matches

@nbbaier•Updated 1 year ago
1# Code Documentation Assistant
2
3The Code Documentation Assistant is an AI-powered tool that helps generate documentation for code. It uses the OpenAI GPT-3.5 Turbo model to generate readme files in GitHub-flavored markdown based on the provided code.
4
5## Usage
24 - `username` (string): The username of the code owner.
25 - `valName` (string): The name of the Val containing the code.
26 - `model` (optional, default: "gpt-3.5-turbo"): The OpenAI model to use for generating the readme.
27 - `userPrompt` (optional): Additional prompt to include in the documentation.
28
44 - `username` (string): The username of the code owner.
45 - `valName` (string): The name of the Val containing the code.
46 - `model` (optional, default: "gpt-3.5-turbo"): The OpenAI model to use for generating the readme.
47 - `userPrompt` (optional): Additional prompt to include in the documentation.
48

readmeGPTmain.tsx9 matches

@nbbaier•Updated 1 year ago
1import { type WriterOptions } from "https://esm.town/v/nbbaier/WriterOptions";
2import { fetch } from "https://esm.town/v/std/fetch?v=4";
3import OpenAI, { type ClientOptions } from "npm:openai";
4
5export class ReadmeWriter {
6 model: string;
7 openai: OpenAI;
8 apiKey: string;
9 valtownKey: string;
10
11 constructor(options: WriterOptions) {
12 const { model, ...openaiOptions } = options;
13 this.model = model ? model : "gpt-3.5-turbo";
14 this.openai = new OpenAI(openaiOptions);
15 this.valtownKey = Deno.env.get("valtown");
16 }
47 }
48
49 private async performOpenAICall(prompt: string) {
50 try {
51 const response = await this.openai.chat.completions.create({
52 messages: [{ role: "system", content: prompt }],
53 model: this.model,
55
56 if (!response.choices || response.choices.length === 0) {
57 throw new Error("No response from OpenAI");
58 }
59
61
62 if (!readme) {
63 throw new Error("No readme returned by OpenAI. Try again.");
64 }
65
92 const { id, code } = await this.getVal(username, valName);
93 const prompt = this.createPrompt(code, userPrompt);
94 const readme = await this.performOpenAICall(prompt);
95 return { id, readme };
96 }

sqliteWritermain.tsx11 matches

@nbbaier•Updated 1 year ago
1import { type WriterOptions } from "https://esm.town/v/nbbaier/WriterOptions";
2import { sqlite } from "https://esm.town/v/std/sqlite";
3import OpenAI from "npm:openai";
4
5interface QueryWriterOptons extends WriterOptions {
11 model: string;
12 apiKey: string;
13 openai: OpenAI;
14
15 constructor(options: QueryWriterOptons) {
16 const { table, model, ...openaiOptions } = options;
17 this.table = table;
18 this.model = model;
19 // this.apiKey = openaiOptions.apiKey ? openaiOptions.apiKey : Deno.env.get("OPENAI_API_KEY");
20 this.openai = new OpenAI(openaiOptions);
21 }
22
54
55 try {
56 const response = await this.openai.chat.completions.create({
57 messages: [{ role: "system", content: prompt }],
58 model: this.model,
60
61 if (!response.choices || response.choices.length === 0) {
62 throw new Error("No response from OpenAI");
63 }
64
66
67 if (!query) {
68 throw new Error("No SQL returned from OpenAI. Try again.");
69 }
70
80
81 try {
82 const response = await this.openai.chat.completions.create({
83 messages: [{ role: "system", content: prompt }],
84 model: this.model,
86
87 if (!response.choices || response.choices.length === 0) {
88 throw new Error("No response from OpenAI");
89 }
90
92
93 if (!query) {
94 throw new Error("No SQL returned from OpenAI. Try again.");
95 }
96

readmeGPTREADME.md3 matches

@nbbaier•Updated 1 year ago
1# Val Town AI Readme Writer
2
3This val provides a class `ReadmeWriter` for generating readmes for vals with OpenAI. It can both draft readmes and update them directly
4
5PRs welcome! See **Todos** below for some ideas I have.
43
44- `model` (optional): The model to be used for generating the readme. Defaults to "gpt-3.5-turbo".
45- `apiKey` (optional): An OpenAI API key. Defaults to `Deno.env.get("OPENAI_API_KEY")`.
46
47#### Methods
63
64## Todos
65- [ ] Additional options to pass to the OpenAI model
66- [ ] Ability to pass more instructions to the prompt to modify how the readme is constructed
67

sqliteWriterREADME.md2 matches

@nbbaier•Updated 1 year ago
1# SQLite QueryWriter
2
3The QueryWriter class is a utility for generating and executing SQL queries using natural language and OpenAI. It provides a simplified interface for interacting with your Val Town SQLite database and generating SQL queries based on user inputs.
4
5This val is inspired by [prisma-gpt](https://github.com/aliyeysides/prisma-gpt). PRs welcome! See **Todos** below for some ideas I have.
44- `table`: The name of the database table to operate on.
45- `model` (optional): The model to use for generating SQL queries. Defaults to "gpt-3.5-turbo".
46- `apiKey` (optional): An OpenAI API key. Defaults to `Deno.env.get("OPENAI_API_KEY")`.
47
48

add_to_notion_w_ai_webpagemain.tsx3 matches

@nerdymomocat•Updated 1 year ago
4import Instructor from "npm:@instructor-ai/instructor";
5import { Client } from "npm:@notionhq/client";
6import OpenAI from "npm:openai";
7import { render } from "npm:preact-render-to-string";
8import { z } from "npm:zod";
30};
31
32const oai = new OpenAI({
33 apiKey: process.env.OPENAI_API_KEY ?? undefined,
34});
35

add_to_notion_w_aimain.tsx3 matches

@nerdymomocat•Updated 1 year 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

add_to_notion_w_aiREADME.md1 match

@nerdymomocat•Updated 1 year ago
14Supports: checkbox, date, multi_select, number, rich_text, select, status, title, url, email
15
16- Uses `NOTION_API_KEY`, `OPENAI_API_KEY` stored in env variables and uses [Valtown blob storage](https://esm.town/v/std/blob) to store information about the database.
17- Use `get_notion_db_info` to use the stored blob if exists or create one, use `get_and_save_notion_db_info` to create a new blob (and replace an existing one if exists).
18

gpt3Examplemain.tsx2 matches

@ktodaz•Updated 1 year ago
2
3const gpt3Example = async () => {
4 const response = await fetch("https://api.openai.com/v1/completions", {
5 method: "POST",
6 headers: {
7 "Content-Type": "application/json",
8 "Authorization": "Bearer " + process.env.OPENAI_API_KEY, // Replace with your OpenAI API Key
9 },
10 body: JSON.stringify({

openaiproxy2 file matches

@skutaans•Updated 4 days ago

token-server1 file match

@kwhinnery_openai•Updated 5 days ago
Mint tokens to use with the OpenAI Realtime API for WebRTC
kwhinnery_openai
reconsumeralization
import { OpenAI } from "https://esm.town/v/std/openai"; import { sqlite } from "https://esm.town/v/stevekrouse/sqlite"; /** * Practical Implementation of Collective Content Intelligence * Bridging advanced AI with collaborative content creation */ exp