Runnable With Message History
Runnable With Message History passes a message to a connected agent or chain and returns its answer as text, like Runnable Executor, but adding the conversation’s previous messages. That way the agent remembers what was said and can answer questions such as “and the other model?”.
By default, messages are kept in NappAI’s internal memory, separated by flow, session and conversation. If you prefer another memory, connect it to External Memory.
When to use it
- A chat assistant that has to remember what the user said earlier.
- Giving an agent or a chain, besides the message, other named input data.
Configuration
| Field | What it does |
|---|---|
| Input | The message passed to the agent or chain. |
| Agent Executor (required) | The agent or chain that runs. |
| External Memory | An external memory where messages are read from and saved. Empty, NappAI’s internal memory is used. |
| Stream | Returns the answer in parts, as it is generated. On by default. |
| Memory top message | How many previous messages are retrieved from the internal memory. Default: 5. |
| Number of extra input parameters | How many extra input values are passed, from 1 to 15. For each one an input parameter N field appears, where you give a name and its value, which can come from another component. |
Advanced options
| Field | What it does |
|---|---|
| Output Key | The name of the result taken from the answer. Default: output. |
| Input Key | The name of the input the agent or chain expects. Default: input. |
| Executor Name | The name the run shows in the log. Default: executor_with_history. |
Output
The Text output is the agent’s or chain’s answer.
Example
An online shop wants an assistant that keeps track of the conversation.
- Connect the customer’s message to Input and the shop’s agent to Agent Executor.
- Leave External Memory empty and set Memory top message to 10.
- Connect Text to the chat output.
Best practices
- Retrieving more messages gives the agent more context, but makes each request longer.
- Use an external memory when the conversation has to be shared with other systems.
Related components
- Runnable Executor: runs an agent or a chain without history.
- Redis Chat Memory: an external memory.