mirror of
https://github.com/vegu-ai/talemate.git
synced 2026-09-03 04:30:14 +02:00
280 lines
8.1 KiB
Markdown
280 lines
8.1 KiB
Markdown
|
|
# Asset Nodes
|
||
|
|
|
||
|
|
Manage scene assets (images and other files): add, fetch, list, remove and update them, and set cover and avatar images.
|
||
|
|
|
||
|
|
<!-- glossary:generated - everything below this line is generated by `python -m talemate.game.engine.nodes.tools glossary --write` - do not edit -->
|
||
|
|
|
||
|
|
|
||
|
|
_9 nodes._
|
||
|
|
|
||
|
|
| Node | Registry path |
|
||
|
|
| --- | --- |
|
||
|
|
| [Add Asset](#add-asset) | `assets/AddAsset` |
|
||
|
|
| [Asset Exists](#asset-exists) | `assets/AssetExists` |
|
||
|
|
| [Get Asset](#get-asset) | `assets/GetAsset` |
|
||
|
|
| [Get Assets](#get-assets) | `assets/GetAssets` |
|
||
|
|
| [List Assets](#list-assets) | `assets/ListAssets` |
|
||
|
|
| [Remove Asset](#remove-asset) | `assets/RemoveAsset` |
|
||
|
|
| [Set Avatar Image](#set-avatar-image) | `assets/SetAvatarImage` |
|
||
|
|
| [Set Cover Image](#set-cover-image) | `assets/SetCoverImage` |
|
||
|
|
| [Update Message Assets](#update-message-assets) | `assets/UpdateMessageAsset` |
|
||
|
|
|
||
|
|
## Add Asset
|
||
|
|
|
||
|
|
`assets/AddAsset`
|
||
|
|
|
||
|
|
Add an asset to the scene from image data (base64 data URL).
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `state` | `any` | graph state (required) |
|
||
|
|
| `image_data` | `str` | (optional) base64 data URL (e.g., "data:image/png;base64,...") |
|
||
|
|
| `meta` | `asset_meta` | asset metadata (optional) |
|
||
|
|
| `asset_attachment_context` | `asset_attachment_context` | controls automatic asset attachment behavior (optional) |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `state` | `any` | graph state |
|
||
|
|
| `asset` | `asset` | the created asset object |
|
||
|
|
| `asset_id` | `str` | the asset ID |
|
||
|
|
| `image_data` | `str` | the image data (passed through) |
|
||
|
|
| `meta` | `asset_meta` | the asset metadata (passed through) |
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `image_data` | `str` | `""` | Base64 data URL (e.g., 'data:image/png;base64,...') |
|
||
|
|
|
||
|
|
## Asset Exists
|
||
|
|
|
||
|
|
`assets/AssetExists`
|
||
|
|
|
||
|
|
Check if an asset exists by ID.
|
||
|
|
|
||
|
|
Routes to 'yes' output if the asset exists, 'no' output if it doesn't.
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `asset_id` | `str` | (optional) the asset ID to check |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `yes` | `any` | activated if asset exists (contains asset_id) |
|
||
|
|
| `no` | `any` | activated if asset does not exist (contains asset_id) |
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `asset_id` | `str` | `""` | The asset ID to check |
|
||
|
|
| `return_bool` | `bool` | `False` | If True, return True instead of asset_id |
|
||
|
|
| `allow_partial` | `bool` | `False` | If True, match assets whose ID starts with the given asset_id |
|
||
|
|
|
||
|
|
## Get Asset
|
||
|
|
|
||
|
|
`assets/GetAsset`
|
||
|
|
|
||
|
|
Get an asset by ID.
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `asset_id` | `str` | (optional) the asset ID |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `asset` | `asset` | the asset object |
|
||
|
|
| `asset_id` | `str` | the asset ID (passed through) |
|
||
|
|
| `file_type` | `str` | the file type |
|
||
|
|
| `media_type` | `str` | the media type |
|
||
|
|
| `meta` | `asset_meta` | the asset metadata |
|
||
|
|
| `asset_bytes` | `any` | the asset bytes (only set if connected) |
|
||
|
|
| `base64_data` | `str` | the asset bytes as base64 (only set if connected) |
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `asset_id` | `str` | `""` | The asset ID |
|
||
|
|
|
||
|
|
## Get Assets
|
||
|
|
|
||
|
|
`assets/GetAssets`
|
||
|
|
|
||
|
|
Get multiple assets by their IDs.
|
||
|
|
|
||
|
|
Asset IDs that don't exist are skipped rather than raising an error.
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `asset_ids` | `list` | (optional) list of asset IDs |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `assets` | `list` | list of asset objects |
|
||
|
|
| `asset_ids` | `list` | list of asset IDs that were found (missing assets are skipped) |
|
||
|
|
| `asset_count` | `int` | number of assets retrieved |
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `asset_ids` | `list` | `[]` | List of asset IDs |
|
||
|
|
|
||
|
|
## List Assets
|
||
|
|
|
||
|
|
`assets/ListAssets`
|
||
|
|
|
||
|
|
List all asset IDs in the scene.
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `asset_ids` | `list` | list of asset IDs |
|
||
|
|
| `asset_count` | `int` | number of assets |
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `reference_only` | `bool` | `False` | If True, only return reference assets |
|
||
|
|
|
||
|
|
## Remove Asset
|
||
|
|
|
||
|
|
`assets/RemoveAsset`
|
||
|
|
|
||
|
|
Remove an asset from the scene.
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `state` | `any` | graph state (required) |
|
||
|
|
| `asset_id` | `str` | (optional) the asset ID to remove |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `state` | `any` | graph state |
|
||
|
|
| `asset_id` | `str` | the asset ID (passed through) |
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `asset_id` | `str` | `""` | The asset ID to remove |
|
||
|
|
|
||
|
|
## Set Avatar Image
|
||
|
|
|
||
|
|
`assets/SetAvatarImage`
|
||
|
|
|
||
|
|
Set the avatar image for a character (default or current).
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `state` | `any` | graph state (required) |
|
||
|
|
| `asset_id` | `str` | the asset ID to set as avatar |
|
||
|
|
| `character` | `character` | the character to set the avatar for |
|
||
|
|
| `avatar_type` | `str` | (optional) "default" or "current" (defaults to "default") |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `state` | `any` | graph state |
|
||
|
|
| `asset_id` | `str` | the asset ID (passed through) |
|
||
|
|
| `character` | `character` | the character (passed through) |
|
||
|
|
| `avatar_type` | `str` | the avatar type (passed through) |
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `avatar_type` | `str` | `"default"` | Type of avatar to set: 'default' or 'current'. Choices: `default`, `current`. |
|
||
|
|
|
||
|
|
## Set Cover Image
|
||
|
|
|
||
|
|
`assets/SetCoverImage`
|
||
|
|
|
||
|
|
Set the cover image for the scene and/or a character from an existing scene asset.
|
||
|
|
|
||
|
|
If `set_on_scene` is true the asset becomes the scene cover image; if a
|
||
|
|
character is provided the asset becomes that character's cover image. The
|
||
|
|
override flags control whether an existing cover image is replaced.
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `state` | `any` | The graph state |
|
||
|
|
| `asset_id` | `str` | The id of the asset to use as the cover image |
|
||
|
|
| `set_on_scene` | `bool` | Whether to set the cover image on the scene (optional) |
|
||
|
|
| `override_scene` | `bool` | Whether to override an existing scene cover image (optional) |
|
||
|
|
| `override_character` | `bool` | Whether to override an existing character cover image (optional) |
|
||
|
|
| `character` | `character` | The character to set the cover image for (optional) |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `state` | `any` | The state input, passed through |
|
||
|
|
| `asset_id` | `str` | The asset id, passed through |
|
||
|
|
| `set_on_scene` | `bool` | The set_on_scene input, passed through |
|
||
|
|
| `override_scene` | `bool` | The override_scene input, passed through |
|
||
|
|
| `override_character` | `bool` | The override_character input, passed through |
|
||
|
|
| `character` | `character` | The character input, passed through |
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `asset_id` | `str` | `""` | asset_id |
|
||
|
|
| `set_on_scene` | `bool` | `False` | Whether to set the cover image on the scene |
|
||
|
|
| `override_scene` | `bool` | `False` | Whether to override the scene cover image |
|
||
|
|
| `override_character` | `bool` | `False` | Whether to override the character cover image |
|
||
|
|
|
||
|
|
## Update Message Assets
|
||
|
|
|
||
|
|
`assets/UpdateMessageAsset`
|
||
|
|
|
||
|
|
Update the asset_id of messages in the scene history
|
||
|
|
|
||
|
|
Messages that aren't found are skipped rather than raising an error.
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `state` | `any` | graph state (required) |
|
||
|
|
| `message_ids` | `list` | (optional) List of message IDs to update |
|
||
|
|
| `asset_id` | `str` | The new asset ID |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `state` | `any` | graph state |
|
||
|
|
| `messages` | `list` | List of updated message objects |
|
||
|
|
| `message_ids` | `list` | List of message IDs (passthrough) |
|
||
|
|
| `asset_id` | `str` | The asset ID (passthrough) |
|