mirror of
https://github.com/vegu-ai/talemate.git
synced 2026-09-02 20:20:40 +02:00
73 lines
2.5 KiB
Markdown
73 lines
2.5 KiB
Markdown
|
|
# Memory Agent Nodes
|
||
|
|
|
||
|
|
Query the long-term memory database (RAG) and unpack the returned memory documents.
|
||
|
|
|
||
|
|
<!-- glossary:generated - everything below this line is generated by `python -m talemate.game.engine.nodes.tools glossary --write` - do not edit -->
|
||
|
|
|
||
|
|
|
||
|
|
_2 nodes._
|
||
|
|
|
||
|
|
| Node | Registry path |
|
||
|
|
| --- | --- |
|
||
|
|
| [Query Context DB](#query-context-db) | `agents/memory/QueryContextDB` |
|
||
|
|
| [Unpack Memory Document](#unpack-memory-document) | `agents/memory/UnpackMemoryDocument` |
|
||
|
|
|
||
|
|
## Query Context DB
|
||
|
|
|
||
|
|
`agents/memory/QueryContextDB`
|
||
|
|
|
||
|
|
Queries the memory agent's context database with one or more queries
|
||
|
|
and collects the matching documents, up to a total token budget.
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `state` | `any` | The graph state |
|
||
|
|
| `queries` | `list,str` | (optional) The queries to run (list, or a single query string) |
|
||
|
|
| `meta_filters` | `dict` | Metadata filters to constrain the results (optional) |
|
||
|
|
| `max_tokens` | `int` | The maximum total tokens of results to return (optional) |
|
||
|
|
| `fn_filter` | `function` | Function that receives a result and returns whether to keep it (optional) |
|
||
|
|
| `fn_formatter` | `function` | Function that receives a result and returns its formatted replacement (optional) |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `state` | `any` | The state input, passed through |
|
||
|
|
| `results` | `list` | The list of matching documents |
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `queries` | `list` | `[]` | The queries to use to query the context database |
|
||
|
|
| `meta_filters` | `dict` | `{}` | The meta filters to apply to the results |
|
||
|
|
| `max_tokens` | `int` | `1024` | The maximum number of tokens to return |
|
||
|
|
| `limit` | `int` | `10` | The number of N best results to consider per query |
|
||
|
|
| `iterate` | `int` | `3` | The number of results to return per query |
|
||
|
|
|
||
|
|
## Unpack Memory Document
|
||
|
|
|
||
|
|
`agents/memory/UnpackMemoryDocument`
|
||
|
|
|
||
|
|
Unpacks a memory document into its individual fields.
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `document` | `memory/document` | The memory document to unpack |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `document` | `memory/document` | The memory document, passed through |
|
||
|
|
| `meta` | `dict` | The document's metadata dict |
|
||
|
|
| `id` | `str` | The document's ID in the memory database |
|
||
|
|
| `raw` | `dict` | The document's raw content |
|
||
|
|
| `as_text` | `str` | The document rendered as text |
|
||
|
|
| `as_dict` | `dict` | The document as a dict |
|
||
|
|
| `context_id` | `context_id` | The document's context ID |
|