Simple Go library and console application which use the OpenAI API to randomly generate different types of comical short stories.
JokeGen can be used in a few different ways:
- The
github.com/chippolot/jokegenpackage can be used in other Go projects for story generation. - The
jokegenconsole application can be used to test story generation directly.
JokeGen required an active OpenAI API key in order to generate new stories.
JokeGen supports a few different story types:
- Misunderstandings (
storyType: misunderstanding)- Comical stories stemming from misunderstandings.
- Slapsticks (
storyType: slapstick)- Stories involving slapstick humor.
- Curses (
storyType: curse)- Comical stories revolving around curses.
- Curses (
storyType: creature)- Comical stories revolving around mythical creatures.
To include JokeGen in another Go application just use go get:
go get -u github.com/chippolot/jokegen@latest
Next, import JokeGen in your application:
import "github.com/chippolot/jokegen"You will need to create a new data provider implementing the following interface:
type StoryDataProvider interface {
AddStory(story string, prompt string, storyType StoryType) error
GetMostRecentStory(storyType StoryType) (StoryResult, error)
GetRandomString(dataType StoryDataType, storyType StoryType) (string, error)
Close() error
}Finally, generate new stories:
openAIToken := "YOUR_OPEN_AI_TOKEN"
storyType := "misunderstanding"
dataProvider := YOUR_DATA_PROVIDER_INSTANCE
options := jokegen.StoryOptions{}
jokegen.GenerateStory(openAIToken, storyType, dataProvider, options)Build the CLI program with:
go build -o jokegen ./cmd/consoleapp
And run with:
./consoleapp -st STORY_TYPE
This project is licensed under the MIT License - see the LICENSE.md file for details