Readme

Val Town AI Readme Writer

This val provides a class ReadmeWriter for generating readmes for vals with OpenAI. It can both draft readmes and update them directly

PRs welcome! See Todos below for some ideas I have.

Usage

To draft a readme for a given code, use the draftReadme method:

import { ReadmeWriter } from "https://esm.town/v/nbbaier/readmeGPT"; const readmeWriter = new ReadmeWriter({}); const val = "https://www.val.town/v/:username/:valname"; const generatedReadme = await readmeWriter.draftReadme(val);

To write and update a readme for a given code, use the writeReadme method:

import { ReadmeWriter } from "https://esm.town/v/nbbaier/readmeGPT"; const readmeWriter = new ReadmeWriter({}); const val = "https://www.val.town/v/:username/:valname"; const successMessage = await readmeWriter.writeReadme(val);

API Reference

Class: ReadmeWriter

The ReadmeWriter class represents a utility for generating and updating README files.

Constructor

Creates an instance of the ReadmeWriter class.

Parameters:
  • model (optional): The model to be used for generating the readme. Defaults to "gpt-3.5-turbo".
  • apiKey (optional): An OpenAI API key. Defaults to Deno.env.get("OPENAI_API_KEY").

Methods

  • draftReadme(val: string): Promise<string>: Generates a readme for the given val.

    • Parameters:

      • val: URL of the code repository.
    • Returns:

      • A promise that resolves to the generated readme.
  • writeReadme(val: string): Promise<string>: Generates and updates a readme for the given val.

    • Parameters:

      • val: URL of the code repository.
    • Returns:

      • A promise that resolves to a success message if the update is successful.

Todos

  • Additional options to pass to the OpenAI model
  • Ability to pass more instructions to the prompt to modify how the readme is constructed
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
6
stevekrouse avatar

Awesome!!! I'd love it if the Usage sections would output a single code snippet one could copy and paste into a val. Right now it requires a lot of different copy and pastes. Maybe a change to the prompt could fix that?

nbbaier avatar

I'll do that!

stevekrouse avatar

Excellent! I'd simplify your API and docs like so:

import { draftReadme } from "https://esm.town/v/nbbaier/readmeGPT";

console.log(await draftReadme({ username: "nbbaier", val: "exampleVal" }))
nbbaier avatar

I added this to the prompt: Usage sections should include a single code snippet that a user can copy and paste.

Also, to clarify your API suggestion - you're saying move away from the class based API here?

stevekrouse avatar

Yep! There's no reason to do a class based thing here in my opinion

nbbaier avatar

Fair! I'll refactor later this week

January 22, 2024