1import { getWeather } from "https://esm.town/v/chet/getWeather";
2import { email } from "https://esm.town/v/std/email";
3export async function sailingNotify(
4 where: string,
5 minWindMph = 1,
1import { blob } from "https://esm.town/v/std/blob";
2import { set } from "https://esm.town/v/std/set?v=11";
3export default async function(req: Request): Promise<Response> {
4 const searchParams = new URL(req.url).searchParams;
5 let value = searchParams.get("todo");
2import { createJTW, getForecast } from "npm:apple-weatherkit";
3
4export async function getAppleWeather(args: { lat: number; lng: number }) {
5 const token = createJTW({
6 teamId: process.env.APPLE_WEATHERKIT_TEAM_ID,
11)`);
12
13async function addTask(description: string) {
14 await sqlite.execute({
15 sql: `INSERT INTO tasks (description) VALUES (?)`,
18}
19
20async function getTasks() {
21 const { columns, rows } = await sqlite.execute(`SELECT id, description, completed FROM tasks`);
22 return rows.map((row) => {
33}
34
35async function toggleTaskCompletion(id: number, completed: boolean) {
36 await sqlite.execute({
37 sql: `UPDATE tasks SET completed = ? WHERE id = ?`,
40}
41
42async function removeTask(id: number) {
43 await sqlite.execute({
44 sql: `DELETE FROM tasks WHERE id = ?`,
11)`);
12
13async function addTask(description: string) {
14 await sqlite.execute({
15 sql: `INSERT INTO tasks (description) VALUES (?)`,
18}
19
20async function getTasks() {
21 const { columns, rows } = await sqlite.execute(`SELECT id, description, completed FROM tasks`);
22 return rows.map((row) => {
33}
34
35async function toggleTaskCompletion(id: number, completed: boolean) {
36 await sqlite.execute({
37 sql: `UPDATE tasks SET completed = ? WHERE id = ?`,
40}
41
42async function removeTask(id: number) {
43 await sqlite.execute({
44 sql: `DELETE FROM tasks WHERE id = ?`,
1function envOrUndefined(key: string): string | undefined {
2 // try/catch prevents crashes if the script doesn't have env access
3 try {
1const { default: OpenAI } = await import("npm:openai");
2
3export async function chat(apiKey, messages) {
4 const openai = new OpenAI({ apiKey });
5
9}
10
11function createPrompt(code: string, userPrompt?: string) {
12 return `
13 You are an AI assistant that writes documentation for code. You output readmes
23}
24
25async function getVal(username: string, valName: string) {
26 try {
27 const res = await fetch(`https://api.val.town/v1/alias/${username}/${valName}`, {
40}
41
42async function performOpenAICall(prompt: string, model: string, openaiOptions: ClientOptions) {
43 const openai = new OpenAI(openaiOptions);
44
65}
66
67async function updateReadme(id: string, readme: string) {
68 try {
69 const res = await fetch(`https://api.val.town/v1/vals/${id}`, {
82}
83
84async function draftReadme(options: WriterOptions) {
85 const { username, valName, model = "gpt-3.5-turbo", userPrompt, ...openaiOptions } = options;
86 const { id, code } = await getVal(username, valName);
90}
91
92async function writeReadme(options: WriterOptions) {
93 const { username, valName, model = "gpt-3.5-turbo", userPrompt, ...openaiOptions } = options;
94 const { id, code } = await getVal(username, valName);
11```
12
13### Function: draftReadme
14
15```javascript
16async function draftReadme(options: WriterOptions): Promise<string>
17```
18
19The `draftReadme` function generates a readme file based on the provided options.
20
21#### Parameters
31A promise that resolves to a string representing the generated readme file.
32
33### Function: writeReadme
34
35```javascript
36async function writeReadme(options: WriterOptions): Promise<string>
37```
38
39The `writeReadme` function generates a readme file and updates the readme of the corresponding Val with the generated content.
40
41#### Parameters
1import { ToDoesList } from "https://esm.town/v/cufaoil/todoeslist";
2
3export function ToDoes() {
4 return Response.json(ToDoesList);
5}