mirror of
https://github.com/vegu-ai/talemate.git
synced 2026-09-02 12:09:31 +02:00
142 lines
3.9 KiB
Markdown
142 lines
3.9 KiB
Markdown
|
|
# Utility Nodes
|
||
|
|
|
||
|
|
Miscellaneous helpers: counters, string diffs, list extraction from text, ISO date durations and the **Module Style** node that sets a module's canvas appearance.
|
||
|
|
|
||
|
|
<!-- glossary:generated - everything below this line is generated by `python -m talemate.game.engine.nodes.tools glossary --write` - do not edit -->
|
||
|
|
|
||
|
|
|
||
|
|
_5 nodes._
|
||
|
|
|
||
|
|
| Node | Registry path |
|
||
|
|
| --- | --- |
|
||
|
|
| [Counter](#counter) | `util/Counter` |
|
||
|
|
| [Diff](#diff) | `util/Diff` |
|
||
|
|
| [Extract List](#extract-list) | `util/ExtractList` |
|
||
|
|
| [ISO Date Duration](#iso-date-duration) | `util/IsoDateDuration` |
|
||
|
|
| [Module Style](#module-style) | `util/ModuleStyle` |
|
||
|
|
|
||
|
|
## Counter
|
||
|
|
|
||
|
|
`util/Counter`
|
||
|
|
|
||
|
|
Counter node that increments a numeric value inside a
|
||
|
|
dict and returns the new value.
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `state` | `any` | The graph state |
|
||
|
|
| `dict` | `dict` | The dict containing the value to increment |
|
||
|
|
| `key` | `str` | (optional) The key to the value to increment |
|
||
|
|
| `reset` | `bool` | (optional) If true, the value will be reset to 0 |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `state` | `any` | The state input, passed through |
|
||
|
|
| `value` | `any` | The new value |
|
||
|
|
| `dict` | `dict` | The dict with the new value |
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `increment` | `number` | `1` | The amount to increment the value by. Min: 1. |
|
||
|
|
| `key` | `str` | `"counter"` | The key to the value to increment |
|
||
|
|
| `reset` | `bool` | `False` | If true, the value will be reset to 0 |
|
||
|
|
|
||
|
|
## Diff
|
||
|
|
|
||
|
|
`util/Diff`
|
||
|
|
|
||
|
|
Diff node that returns the diff between two strings.
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `a` | `str` | The original string |
|
||
|
|
| `b` | `str` | The changed string |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `diff_plain` | `str` | The diff as plain text |
|
||
|
|
| `diff_html` | `str` | The diff as inline HTML markup |
|
||
|
|
| `a` | `str` | The a input, passed through |
|
||
|
|
| `b` | `str` | The b input, passed through |
|
||
|
|
|
||
|
|
## Extract List
|
||
|
|
|
||
|
|
`util/ExtractList`
|
||
|
|
|
||
|
|
Extracts a list from a string.
|
||
|
|
|
||
|
|
Parses a numbered ("1.") or bulleted ("*" / "-") list out of text, such
|
||
|
|
as an LLM response, returning the items as a list of strings.
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `string` | `str` | The text to extract the list from |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `string` | `str` | The string input, passed through |
|
||
|
|
| `list` | `list` | The extracted list items |
|
||
|
|
| `is_empty` | `bool` | True if no list items were found |
|
||
|
|
|
||
|
|
## ISO Date Duration
|
||
|
|
|
||
|
|
`util/IsoDateDuration`
|
||
|
|
|
||
|
|
IsoDateDuration node that allows constructing ISO 8601 duration strings.
|
||
|
|
|
||
|
|
Combines an amount and a unit into an ISO 8601 duration
|
||
|
|
(e.g., 3 + "day" -> "P3D").
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `unit` | `str` | The unit of the duration (year, month, week, day, hour, minute, second) |
|
||
|
|
| `amount` | `number` | The amount of the duration |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `unit` | `str` | The unit input, passed through |
|
||
|
|
| `amount` | `number` | The amount input, passed through |
|
||
|
|
| `duration` | `str` | The ISO 8601 duration string |
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `unit` | `str` | `"day"` | The unit of the duration. Choices: `year`, `month`, `week`, `day`, `hour`, `minute`, `second`. |
|
||
|
|
| `amount` | `number` | `1` | The amount of the duration. Min: 1. |
|
||
|
|
|
||
|
|
## Module Style
|
||
|
|
|
||
|
|
`util/ModuleStyle`
|
||
|
|
|
||
|
|
An isolated node that defines the visual style of the graph it is
|
||
|
|
placed in, when that graph is used as a node module inside another
|
||
|
|
graph.
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `title_color` | `color` | `unset` | Title Color |
|
||
|
|
| `node_color` | `color` | `unset` | Node Color |
|
||
|
|
| `auto_title` | `str` | `unset` | Auto Title |
|
||
|
|
| `icon` | `str` | `unset` | Icon (Material Icon Codepoint) |
|