Skip to content

Commit

Permalink
Merge pull request #2 from agorischek/docs
Browse files Browse the repository at this point in the history
Add `ideas`
  • Loading branch information
agorischek committed Jan 27, 2024
2 parents d22b159 + eef4530 commit 322f67f
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 23 deletions.
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
Add variation to your content through randomized placeholders — Great for
inspiring creativity in language model prompts.

[![Version](https://img.shields.io/npm/v/fill-in-the-blank)](https://www.npmjs.com/package/fill-in-the-blank "Version")
[![Workflow](https://img.shields.io/github/actions/workflow/status/agorischek/fill-in-the-blank/.github/workflows/ci.yml)](https://github.com/agorischek/fill-in-the-blank/actions/workflows/.github/workflows/ci.yml "Workflow")
[![License](https://img.shields.io/github/license/agorischek/fill-in-the-blank)](https://github.com/agorischek/fill-in-the-blank#readme/blob/main/LICENSE "License")
[![Badges](https://img.shields.io/badge/badges-rolled-white)](https://github.com/agorischek/badge-roll "Badges")
[![Version](https://img.shields.io/npm/v/fill-in-the-blank)](https://www.npmjs.com/package/fill-in-the-blank 'Version')
[![Workflow](https://img.shields.io/github/actions/workflow/status/agorischek/fill-in-the-blank/.github/workflows/ci.yml)](https://github.com/agorischek/fill-in-the-blank/actions/workflows/.github/workflows/ci.yml 'Workflow')
[![License](https://img.shields.io/github/license/agorischek/fill-in-the-blank)](https://github.com/agorischek/fill-in-the-blank#readme/blob/main/LICENSE 'License')
[![Badges](https://img.shields.io/badge/badges-rolled-white)](https://github.com/agorischek/badge-roll 'Badges')

```ts
const prompt = `Would a ${animal} make a good ${profession}?`;
Expand Down Expand Up @@ -56,10 +56,17 @@ To get more varied responses from a language model, you can include the
const prompt = 'Write a poem.' + creativity;
```

This will insert a variety of ideas that the model can use to guide its
response. Note that the behavior will be highly dependent on your model,
settings, and other prompt content, and getting desirable results will likely
require iteration.
This will insert a random topic that the model can use to guide its response.

To generate multiple possible topics, use the `ideas` blank:

```ts
const prompt = `Write a story by combining two of these ideas: ${ideas}`;
```

Note that the behavior will be highly dependent on your model, settings, and
other prompt content, and getting desirable results will likely require
iteration.

## Q&A

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fill-in-the-blank",
"version": "0.0.3",
"version": "0.0.4",
"description": "Word generator",
"main": "dist/index.js",
"type": "module",
Expand Down
32 changes: 20 additions & 12 deletions src/prompting/creativity.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
animal,
appliance,
color,
emotion,
exercise,
musicGenre,
Expand All @@ -12,19 +11,28 @@ import {
} from '../index.js';
import { wrap } from '../shared/wrap.js';

/** Provides a variety of topics for a model to consider when generating a response
*
* @remarks
* The results of using `creativity` will vary greatly depending on your model, settings, and other prompt content.
* Expect to iterate on your prompt and settings to get the desired results.
*
const kinds = [
exercise,
animal,
emotion,
plant,
vehicle,
appliance,
shape,
musicGenre,
profession,
];

/** Provides random inspiration for a model to consider when generating a response
* @example
* ```ts
* const prompt = "Tell me a joke." + creativity;
* // "Tell me a joke. Consider mentioning one of the following topics..."
* // "Tell me a joke. Use 'toaster' for creative inspiration."
* ```
*/
export const creativity = wrap(
() =>
` Consider mentioning whichever **ONE** of these is most relevant: ${exercise}, ${animal}, the color ${color}, being ${emotion}, ${plant}, ${vehicle}, ${appliance}, ${shape}, ${musicGenre} music, or ${profession}.`,
);
export const creativity = wrap(() => {
const index = Math.floor(Math.random() * kinds.length);
const topic = kinds[index]();
const content = ` Use '${topic}' for creative inspiration.`;
return content;
});
30 changes: 30 additions & 0 deletions src/prompting/ideas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {
animal,
appliance,
color,
emotion,
exercise,
musicGenre,
plant,
profession,
shape,
vehicle,
} from '../index.js';
import { wrap } from '../shared/wrap.js';

/** Provides a variety of ideas for a model to consider when generating a response
*
* @remarks
* The results of using `ideas` will vary greatly depending on your model, settings, and other prompt content.
* Expect to iterate on your prompt and settings to get the desired results.
*
* @example
* ```ts
* const prompt = "Write me a story. Here are some ideas to get started: ${ideas}";
* // "Write me a story. Here are some ideas to get started: running, bunny, the color blue..."
* ```
*/
export const ideas = wrap(
() =>
`${exercise}, ${animal}, the color ${color}, being ${emotion}, ${plant}, ${vehicle}, ${appliance}, ${shape}, ${musicGenre} music, and ${profession}.`,
);

0 comments on commit 322f67f

Please sign in to comment.