# answer_documents

A RocketRide adapter node that turns model/agent answers into embeddable documents, so validated, self-describing facts can be indexed back into a vector store.

## What it does

Reads the `answers` lane and emits documents on the `documents` lane, bridging a gap in the pipeline graph: many nodes produce `answers`, but none previously turned an answer back into `documents`, so an LLM's structured/validated output could not be re-embedded and indexed.

Granularity is "one document per validated fact":

- a JSON array answer yields one document per item (each fact is indexed independently),
- a JSON object or plain-text answer yields a single document,
- an empty/whitespace answer yields no documents.

Each output document's `page_content` is the fact text (list items that are already strings are used verbatim; other values are serialized as JSON). Documents are stamped with an incrementing `chunkId` (reset for each input object) and marked as non-table content (`isTable: false`, `tableId: 0`).

The original answer is always passed through unchanged on the `answers` lane, so a single pipeline can both index the answer and keep serving it (for example to a response node) in the same run.

The node has no Python package requirements of its own: it relies entirely on the separately installed AI module.

---

## Configuration

### Lanes

| Lane in   | Lane out               | Description                                                             |
|-----------|------------------------|-------------------------------------------------------------------------|
| `answers` | `documents`, `answers` | Emit one document per validated fact; pass the original answer through  |

No configuration fields. Wire answers in.

---

## Usage

Place this node after an LLM, agent, or extract/validate node (anything that produces `answers`) and before an embedding node and vector store:

```text
llm / agent  →  answer_documents  →  embedding_*  →  vector store
                                 ↘  response (original answer, optional)
```

The `documents` output is embedded and indexed for later retrieval, enabling the highest-quality RAG design — indexing self-describing, validated facts rather than raw chunks. The `answers` passthrough lets the same answer continue to a downstream sink in the same pipeline.

Example: an upstream node returns a validated JSON array of facts

```json
[
  {"metric": "revenue", "period": "FY2024", "value": "5.2M", "currency": "USD"},
  {"metric": "gross_margin", "period": "FY2024", "value": "61%"}
]
```

`answer_documents` emits two documents, one per fact, each ready to be embedded and indexed.

---

<!-- ROCKETRIDE:GENERATED:PARAMS START -->
<!-- Generated by nodes:docs-generate. Do not edit by hand. -->

## Schema

_No configuration fields._

## Source

[<svg viewBox="0 0 16 16" width="15" height="15" fill="currentColor" aria-hidden="true" style="vertical-align:-0.15em;margin-right:0.35em"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg> View source](https://github.com/rocketride-org/rocketride-server/tree/develop/nodes/src/nodes/answer_documents)
<!-- ROCKETRIDE:GENERATED:PARAMS END -->
