2024-05-10 04:45:22 +00:00
|
|
|
# TaleWeave AI Events
|
|
|
|
|
|
|
|
## Contents
|
|
|
|
|
|
|
|
- [TaleWeave AI Events](#taleweave-ai-events)
|
|
|
|
- [Contents](#contents)
|
|
|
|
- [Event Types](#event-types)
|
|
|
|
- [Player Events](#player-events)
|
|
|
|
- [Player Join Events](#player-join-events)
|
|
|
|
- [Player Leave Events](#player-leave-events)
|
|
|
|
- [System Events](#system-events)
|
|
|
|
- [Generate Events](#generate-events)
|
|
|
|
- [World Events](#world-events)
|
|
|
|
- [Action Events](#action-events)
|
|
|
|
- [Prompt Events](#prompt-events)
|
|
|
|
- [Reply Events](#reply-events)
|
|
|
|
- [Result Events](#result-events)
|
|
|
|
- [Status Events](#status-events)
|
2024-05-11 22:38:07 +00:00
|
|
|
- [Snapshot Events](#snapshot-events)
|
2024-05-11 10:17:03 +00:00
|
|
|
- [Server-specific Events](#server-specific-events)
|
|
|
|
- [Websocket Server Events](#websocket-server-events)
|
|
|
|
- [Websocket New Client](#websocket-new-client)
|
|
|
|
- [Websocket Player Become Character](#websocket-player-become-character)
|
|
|
|
- [Websocket Player Input](#websocket-player-input)
|
|
|
|
- [Websocket Player Name](#websocket-player-name)
|
2024-05-10 04:45:22 +00:00
|
|
|
|
|
|
|
## Event Types
|
|
|
|
|
|
|
|
- Player events
|
|
|
|
- Joining
|
|
|
|
- Leaving
|
|
|
|
- System events
|
|
|
|
- Generating the world?
|
|
|
|
- World events
|
|
|
|
- Things happening in the world
|
|
|
|
|
|
|
|
## Player Events
|
|
|
|
|
|
|
|
Player events use the following schema:
|
|
|
|
|
|
|
|
```yaml
|
2024-05-11 22:38:07 +00:00
|
|
|
type: "player"
|
2024-05-10 04:45:22 +00:00
|
|
|
status: string
|
|
|
|
character: string
|
|
|
|
client: string
|
|
|
|
```
|
|
|
|
|
|
|
|
### Player Join Events
|
|
|
|
|
|
|
|
Player join events have a `status` of `join`:
|
|
|
|
|
|
|
|
```yaml
|
2024-05-11 22:38:07 +00:00
|
|
|
type: "player"
|
2024-05-10 04:45:22 +00:00
|
|
|
status: "join"
|
|
|
|
character: string
|
|
|
|
client: string
|
|
|
|
```
|
|
|
|
|
|
|
|
### Player Leave Events
|
|
|
|
|
|
|
|
Player leave events have a `status` of `leave`:
|
|
|
|
|
|
|
|
```yaml
|
2024-05-11 22:38:07 +00:00
|
|
|
type: "player"
|
2024-05-10 04:45:22 +00:00
|
|
|
status: "leave"
|
|
|
|
character: string
|
|
|
|
client: string
|
|
|
|
```
|
|
|
|
|
|
|
|
## System Events
|
|
|
|
|
|
|
|
### Generate Events
|
|
|
|
|
|
|
|
Generate events are sent every time an entity's name is generated and again when it has been completely generated and
|
|
|
|
added to the world.
|
|
|
|
|
|
|
|
```yaml
|
2024-05-11 22:38:07 +00:00
|
|
|
type: "generate"
|
|
|
|
name: string
|
2024-05-27 01:32:03 +00:00
|
|
|
entity: Room | Character | Item | None
|
2024-05-10 04:45:22 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Two `generate` events will be fired for each entity. The first event will *not* have an `entity` set, only the `name`.
|
|
|
|
The second event after generation is complete will have the same `name` and the full `entity`. This helps provide
|
|
|
|
more frequent progress updates when generating with slow models.
|
|
|
|
|
|
|
|
## World Events
|
|
|
|
|
|
|
|
### Action Events
|
|
|
|
|
2024-05-27 01:32:03 +00:00
|
|
|
The action event is fired after player or character input has been processed and any JSON function calls have been parsed.
|
2024-05-11 22:38:07 +00:00
|
|
|
|
|
|
|
```yaml
|
|
|
|
type: "action"
|
|
|
|
action: string
|
|
|
|
parameters: dict
|
|
|
|
room: Room
|
2024-05-27 01:32:03 +00:00
|
|
|
character: Character
|
2024-05-11 22:38:07 +00:00
|
|
|
item: Item | None
|
|
|
|
```
|
|
|
|
|
2024-05-10 04:45:22 +00:00
|
|
|
### Prompt Events
|
|
|
|
|
2024-05-11 22:38:07 +00:00
|
|
|
The prompt event is fired when a character's turn starts and their input is needed for the next action.
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
type: "prompt"
|
|
|
|
prompt: string
|
|
|
|
room: Room
|
2024-05-27 01:32:03 +00:00
|
|
|
character: Character
|
2024-05-11 22:38:07 +00:00
|
|
|
```
|
|
|
|
|
2024-05-10 04:45:22 +00:00
|
|
|
### Reply Events
|
|
|
|
|
2024-05-11 22:38:07 +00:00
|
|
|
The reply event is fired when a character has been asked a question or told a message and replies.
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
type: "reply"
|
|
|
|
text: string
|
|
|
|
room: Room
|
2024-05-27 01:32:03 +00:00
|
|
|
character: Character
|
2024-05-11 22:38:07 +00:00
|
|
|
```
|
|
|
|
|
2024-05-10 04:45:22 +00:00
|
|
|
### Result Events
|
|
|
|
|
2024-05-11 22:38:07 +00:00
|
|
|
The result event is fired after a character has taken an action and contains the results of that action.
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
type: "result"
|
|
|
|
result: string
|
|
|
|
room: Room
|
2024-05-27 01:32:03 +00:00
|
|
|
character: Character
|
2024-05-11 22:38:07 +00:00
|
|
|
```
|
|
|
|
|
2024-05-27 01:32:03 +00:00
|
|
|
The result is related to the most recent action for the same character, although not every action will have a result - they
|
2024-05-11 22:38:07 +00:00
|
|
|
may have a reply or error instead.
|
|
|
|
|
2024-05-10 04:45:22 +00:00
|
|
|
### Status Events
|
2024-05-11 10:17:03 +00:00
|
|
|
|
2024-05-11 22:38:07 +00:00
|
|
|
The status event is fired for general events in the world and messages about other characters.
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
type: "status"
|
|
|
|
text: string
|
|
|
|
room: Room | None
|
2024-05-27 01:32:03 +00:00
|
|
|
character: Character | None
|
2024-05-11 22:38:07 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
### Snapshot Events
|
|
|
|
|
|
|
|
The snapshot event is fired at the end of each turn and contains a complete snapshot of the world.
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
type: "snapshot"
|
|
|
|
world: Dict
|
|
|
|
memory: Dict
|
|
|
|
step: int
|
|
|
|
```
|
|
|
|
|
|
|
|
This is primarily used to save the world state, but can also be used to sync clients and populate the world menu.
|
|
|
|
|
|
|
|
The `world` and `memory` fields within the snapshot event have already been serialized to JSON-compatible dictionaries,
|
|
|
|
because they may contain complex classes and implementation details of the underlying LLM.
|
|
|
|
|
2024-05-11 10:17:03 +00:00
|
|
|
## Server-specific Events
|
|
|
|
|
|
|
|
### Websocket Server Events
|
|
|
|
|
|
|
|
The websocket server has a few unique message types that it uses to communicate metadata with socket clients.
|
|
|
|
|
|
|
|
#### Websocket New Client
|
|
|
|
|
|
|
|
Notify a new client of its unique ID.
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
type: "id"
|
|
|
|
id: str
|
|
|
|
```
|
|
|
|
|
|
|
|
This is an outgoing event from the server to clients.
|
|
|
|
|
|
|
|
#### Websocket Player Become Character
|
|
|
|
|
|
|
|
A socket client wants to play as a character in the world.
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
type: "player"
|
|
|
|
become: str
|
|
|
|
```
|
|
|
|
|
|
|
|
This is an incoming event from clients to the server.
|
|
|
|
|
|
|
|
#### Websocket Player Input
|
|
|
|
|
|
|
|
A socket client has sent some input, usually in response to a prompt.
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
type: "input"
|
|
|
|
input: str
|
|
|
|
```
|
|
|
|
|
|
|
|
This is an incoming event from clients to the server.
|
|
|
|
|
|
|
|
#### Websocket Player Name
|
|
|
|
|
|
|
|
Update the player name attached to a socket client.
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
type: "player"
|
|
|
|
name: str
|
|
|
|
```
|
|
|
|
|
|
|
|
This is an incoming event from clients to the server.
|