Skip to content

Commit c6d41b0

Browse files
committed
better readme
1 parent 2f72878 commit c6d41b0

File tree

1 file changed

+45
-19
lines changed

1 file changed

+45
-19
lines changed

README.md

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,62 @@
11
# Promptlab
22

3-
Promptlab is a utility for scripting common activities when working with large amounts of text with an LLM.
3+
Promptlab is a utility for managing common activities when processing large amounts of text with an LLM. It lets you:
44

5-
```
5+
- Load text from files or EPUBs into a database
6+
- Transform text using a variety of transformations. For example, convert an EPUB to markdown, split a long block into smaller blocks, or split a block into sentences. A lot of this work is required to fit the text into the LLM's token limit.
7+
- Filter out blocks of text. For example, you might only want to process one chapter in a book.
8+
- Apply templated prompts to your blocks and send them to an LLM. You can use metadata in your prompts to make them more dynamic. For example, you might have a metadata file with keys like `title`, `author`, and `topic`. You can include these keys in your prompt templates.
69

7-
You are a technical instructional designer who is reviewing a book about {{topic}} called {{title}}. You're job is to create a set of learning objectives. Here is some text in markdown format for you to use to complete the learning objectives; be sure to format them as a bullet list ("\*") and not numbers:
10+
Propmptlab helps you massage text into blocks that can be fed into an LLM using a [Jinja](https://jinja.palletsprojects.com/) template. This template contains the text of your prompt, along with variables that get passed in from the block. For example, you might have a template like this with three variables -- a topic, a title, an authos, and a block of text:
811

9-
===========================================================
10-
{{block}}
11-
===========================================================
12+
```
13+
You are a technical instructional designer who is reviewing
14+
a book about {{topic}} called {{title}} by {{author}}. Your job is to
15+
summarize the key points in each section. Here is some text in
16+
markdown format for you to use summarize:
1217
18+
{{block}}
1319
```
1420

15-
It has functions for:
21+
You supply the metadata in a YAML file, like this:
1622

17-
- loading text from files or EPUBs
18-
- transforming text using a variety of transformations
19-
- filtering blocks
20-
- appplying prompts to blocks
21-
- managing metadata for prompts
23+
```
24+
title: Fooing the Bar
25+
topic: Python Programming
26+
author: A. N. Other
27+
```
2228

23-
Promptlab has a few key concepts:
29+
When you run the `prompt` command in Promptlab, a block of text and the metadata is passed into the template:
2430

25-
- _Blocks_. Blocks of text of any length or format (text, HTML, markdown, etc).
31+
```
32+
You are a technical instructional designer who is reviewing
33+
a book about Python Programming called Fooing the Bar by A. N. Other.
34+
Your job is to summarize the key points in each section. Here is
35+
some text in markdown format for you to use summarize:
2636
27-
- _Groups_. A group of blocks created by running a script. Examples include: transforming text from one format to another (e.g., HTML to Markdown) or splitting a long block into several smaller ones (e.g. breaking a long HTML into sections hased on heading tags like H1 or H2). Some scripts are included in the repo, but users can also write their own.
37+
<A BLOCK OF TEXT FROM PROMPTLAB>
38+
```
2839

29-
- _Prompts_. The result from a prompt template applied against a block and sent to OpenAI's LLM. Promptlab combines your template (in Jinija2 format) with the given block, sends it to the LLM, and stores the result.
40+
This fully rendered text is sent to an LLM for completion. The process is repeated for the other blocks of content until all the sections you select are processed. You can then convert these resposes into new blocks or metadata, or just dump them out an save them in a file.
3041

31-
- _Metadata_. Metadata is a set of key-value pairs that can be used in prompts. For example, you might have a metadata file with keys like `title`, `author`, and `topic`. You can include these keys in your prompt templates. Metadata can be included in prompts using the `--globals` option.
42+
Finally, Promptlab can be used as part of a script to automate the process of generating prompts and responses. For example, here's an example of how tou might summarize the full contents of a book:
3243

33-
Promptlab uses [SQLite3](https://www.sqlite.org/index.html) as the database. The database is created automatically when you run `init`. You can use the [SQLite3 command line tool](https://www.sqlite.org/cli.html) to inspect the database directly or use a GUI like [DB Browser for SQLite](https://sqlitebrowser.org/).
44+
```bash
45+
# Create a new database
46+
promptlab init
47+
# Load the epub
48+
promptlab load --fn=book.epub
49+
# Apply a filter to only work on chapter
50+
promptlab filter --where="block_tag like 'ch%'"
51+
# Clean up the extraneous HTML, split the text into sections, and convert to markdown
52+
promptlab transform --transformation="clean-epub, html-h1-split, html2md"
53+
# Only work on sections with more than 1000 tokens
54+
promptlab filter --where="token_count > 1000" --group_tag=key-sections
55+
# Apply the summarization template using the metadata in metadata.yml
56+
promptlab prompt --fn=summarize.jinja --globals=metadata.yml
57+
# Write the results to a file
58+
promptlab dump --source=prompts > key-points.md
59+
```
3460

3561
# Installation
3662

@@ -255,7 +281,7 @@ Generate prompts from a set of blocks based on metadata and a template, and then
255281

256282
- `--prompt` (required) The name of the prompt template.
257283
- `--where` (optional) A SQL WHERE clause to filter the blocks that will be used to create the prompts.
258-
- `--model` (optional) The name of the openAI model to use. Defaults to gpt-4. You can see a list of models [here]https://platform.openai.com/docs/models/overview).
284+
- `--model` (optional) The name of the openAI model to use. Defaults to gpt-4. You can see a list of models [here](https://platform.openai.com/docs/models/overview).
259285
- `--prompt_tag` (optional) A tag to use for the prompt.
260286
- `--globals` (optional) A YAML file with global metadata values that can be used in the prompt template.
261287
- `--fake` (optional) Generates a fake response data (mostly for testing)

0 commit comments

Comments
 (0)