Skip to content

Commit

Permalink
start dev guide
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Jun 17, 2024
1 parent a256e82 commit f8a6372
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TaleWeave AI can:
- Be run locally - does not require any cloud services, but does play nicely with them
- Connect to your data - game systems can fetch data for RAG
- Export training data for fine tuning character models
- Plug in to your workflow - run step by step in notebook as a Python library
- Plug in to your workflow - run the simulation step by step in Jupyter notebooks as a Python library
- Connect to your server and vice versa - the Discord bot is a plugin and can be replaced with your favorite chat platform

## Contents
Expand Down
86 changes: 86 additions & 0 deletions docs/guides/developer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Developer's Guide to TaleWeave AI

## Contents

- [Developer's Guide to TaleWeave AI](#developers-guide-to-taleweave-ai)
- [Contents](#contents)
- [Extending the Game](#extending-the-game)
- [Developing Extra Actions](#developing-extra-actions)
- [Developing Game Systems](#developing-game-systems)
- [Modifying the Prompts](#modifying-the-prompts)
- [Modifying the World](#modifying-the-world)
- [Using the World Editor](#using-the-world-editor)
- [Creating New Worlds](#creating-new-worlds)
- [Modifying Existing Worlds](#modifying-existing-worlds)

## Extending the Game

There are two primary ways to extend TaleWeave AI: extra actions and new game systems.

Extra actions offer characters new ways to interact with the world or give administrators new ways to control the world.

Game systems can add new game mechanics, logical systems, and even new stages during each turn. All of the base game
mechanics are implemented using optional systems - you can disable the planning and action stages, if you want.

### Developing Extra Actions

Actions are Python functions using the Langchain tool calling mechanism and OpenAI tool JSON schema.

### Developing Game Systems

Game systems can provide callbacks to:

- `format` entity attributes to be added to their prompt
- `generate` attributes and other data for the system
- `initialize` the system's data
- `simulate` the system on each turn

## Modifying the Prompts

TaleWeave AI ships with prompts that are compatible with most Llama-based models, but you may want to use custom
prompts if you are using models that use a different prompt style or were trained in a different language.

## Modifying the World

### Using the World Editor

TaleWeave AI comes with a basic command-line world editor that can be used to add, remove, and modify entities in
your game worlds and saved states.

### Creating New Worlds

TaleWeave AI worlds are stored in human-readable markup languages, usually JSON or YAML. You can create new worlds
using the world editor or your favorite text editor.

You can use the JSON schema for the `World` entity to generate new worlds using models that understand JSON schemas
or tools like `outlines`.

Prompts for ChatGPT and similar models:

> Characters:
>
> - Alice
> - Bob
>
> Rooms:
>
> - House
> - Office
>
> Remember these lists and help generate each room, one by one, based on the following schema.
> I will prompt you for each room. Do not generate any rooms until prompted.
> Generate one room for each prompt, and include some characters. Only include each character in one room, do not reuse characters.
Followed by:

> Generate the "House" room based on this JSON schema.
Upload the `schema/room.json` file along with the last prompt.

To generate more rooms:

> Generate another room using the same JSON schema. Generate the "Office" room.
If the model starts to forget the schema, upload the prompt again and alternate prompts as needed.

### Modifying Existing Worlds
6 changes: 5 additions & 1 deletion taleweave/systems/planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,8 @@ def simulate_planning(world: World, turn: int, data: Any | None = None):

def init_planning():
# TODO: add format method that renders the recent notes and upcoming events
return [GameSystem("planning", simulate=simulate_planning)]
return [
GameSystem(
"planning", initialize=initialize_planning, simulate=simulate_planning
)
]

0 comments on commit f8a6372

Please sign in to comment.