10import { Hono } from "npm:hono@3";
11import _ from "npm:lodash@4";
12import OpenAI from "npm:openai";
13import { renderToString } from "npm:react-dom/server";
14
139
140 const contextWindow = await valleGetValsContextWindow(model);
141 const openai = new OpenAI();
142 const stream = await openai.chat.completions.create({
143 model,
144 stream: true,
7import { Hono } from "npm:hono@3";
8import _ from "npm:lodash@4";
9import OpenAI from "npm:openai";
10import { renderToString } from "npm:react-dom/server";
11
165
166 const contextWindow: any = await valleGetValsContextWindow(model);
167 const openai = new OpenAI();
168 const stream = await openai.chat.completions.create({
169 model,
170 stream: true,
6import { Hono } from "npm:hono@3";
7import _ from "npm:lodash@4";
8import OpenAI from "npm:openai";
9import { renderToString } from "npm:react-dom/server";
10
179
180 const contextWindow = await valleGetValsContextWindow.call(null, model);
181 const openai = new OpenAI();
182 const stream = await openai.chat.completions.create({
183 model,
184 stream: true,
6import { Hono } from "npm:hono";
7import _ from "npm:lodash@4";
8import OpenAI from "npm:openai";
9import { renderToString } from "npm:react-dom/server";
10
156
157 const contextWindow = await valleGetValsContextWindow(model);
158 const openai = new OpenAI();
159 const stream = await openai.chat.completions.create({
160 model,
161 stream: true,
11import { Hono } from "npm:hono";
12import _ from "npm:lodash";
13import OpenAI from "npm:openai";
14import { renderToString } from "npm:react-dom/server";
15
144
145 const contextWindow = await valleGetValsContextWindow(model);
146 const openai = new OpenAI();
147 const stream = await openai.chat.completions.create({
148 model,
149 stream: true,
1Fork it and authenticate with your Val Town API token as the password. Needs an `OPENAI_API_KEY` env var to be set.
2
3WARNING: pollutes your homepage with lots of temporary vals!!
7import { Hono } from "npm:hono@3";
8import _ from "npm:lodash@4";
9import OpenAI from "npm:openai";
10import { renderToString } from "npm:react-dom/server";
11
193
194 const contextWindow: any = await valleGetValsContextWindow(model);
195 const openai = new OpenAI();
196 const stream = await openai.chat.completions.create({
197 model,
198 stream: true,
6* Fork this val to your own profile.
7* Make a folder for the temporary vals that get generated, take the ID from the URL, and put it in `tempValsParentFolderId`.
8* If you want to use OpenAI models you need to set the `OPENAI_API_KEY` [env var](https://www.val.town/settings/environment-variables).
9* If you want to use Anthropic models you need to set the `ANTHROPIC_API_KEY` [env var](https://www.val.town/settings/environment-variables).
10* Create a [Val Town API token](https://www.val.town/settings/api), open the browser preview of this val, and use the API token as the password to log in.
6import ValTown from "npm:@valtown/sdk";
7import { Hono } from "npm:hono@3";
8import OpenAI from "npm:openai";
9import { renderToString } from "npm:react-dom/server";
10
170 );
171
172 const openai = new OpenAI();
173 const stream = await openai.chat.completions.create({
174 model,
175 stream: true,
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