---
schema_version: "1"
id: 1073434b87d2f976269d6388d9c0ec6522dd55a9004d40911e6c6dbef220ac94
title: Configuring RAG Operations
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mulesoft-ai-chain-connector/latest/configuring-rag-operations.md
canonical_url: https://docs.mulesoft.com/mulesoft-ai-chain-connector/latest/configuring-rag-operations
source_site: docs.mulesoft.com
content_type: documentation
content_hash: de9d6d5e24701e9378e20873e5ea03eee9e968a084ed4ece5695d0415c16ce4b
description: MuleSoft Documentation Site
release: "2.0"
latest: true
---
---
product: MuleSoft AI Chain Connector
version: 2.0
is-latest-version: true
---

# Configuring RAG Operations

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Retrieval-Augmented Generation (RAG) is a technique for enhancing AI-generated outputs by retrieving
relevant content, and using it to augment AI prompts with additional context. By grounding LLMs with
this additional information, they can provide more accurate and reliable responses.

## Configure the RAG Load Document Operation

The **RAG load document** operation retrieves information based on a plain text prompt from an
in-memory embedding store.

To configure the **RAG load document** operation:

1.  Select the operation on the Anypoint Code Builder or Studio canvas.

2.  In the **General** properties tab for the operation, enter these values:

    - **Data**

      The prompt to send to the LLM and the embedding store to respond to.

    - **Context Path**

      Contains the full file path for the document to ingest into the embedding store. Ensure the
      file path is accessible.

      You can also use a DataWeave expression for this field, for example:

      ```dataweave
      mule.home ++ "/apps/" ++ app.name ++ "/customer-service.pdf"
      ```

3.  In the **Context** section for the operation, select the **File Type**:

    - **text**

      Text files, such as JSON, XML, TXT, and CSV.

    - **URL**

      A single URL pointing to web content to ingest.

This is the XML configuration for this operation:

```xml
<ms-aichain:rag-load-document
  doc:name="RAG load document"
  doc:id="3d3edd66-4970-4dad-a5bf-2a8eae123da4"
  config-ref="MAC_AI_Llm_configuration"
  data="#[payload.prompt]"
  contextPath="#[payload.contextPath]"
/>
```

## Output Configuration

This operation responds with a JSON payload that contains the main LLM response. Additionally,
attributes such as token usage are included as part of the metadata (attributes), but not within the
main payload.

This is an example response of the JSON payload:

```json
{
  "response": "Wakanda, a technologically advanced and environmentally conscious nation in Africa, is renowned for its unique integration of ancient traditions with cutting-edge innovations, powered by the rare metal Vibranium. With a population of 12.5 million, it emphasizes sustainable growth, quality education, and healthcare, while maintaining a zero carbon footprint through advanced eco-tech solutions. Despite its peaceful nature, Wakanda's formidable military and cultural heritage, led by King T’Challa and the Dora Milaje, ensure its resilience and unity as a symbol of progress and tradition."
}
```

The operation also returns attributes that aren’t within the main JSON payload, which include
information about token usage, for example:

```json
{
  "tokenUsage": {
    "outputCount": 9,
    "totalCount": 18,
    "inputCount": 9
  },
  "additionalAttributes": {}
}
```

- `tokenUsage`

  Token usage metadata returned as attributes

- `outputCount`

  Number of tokens used to generate the output

- `totalCount`

  Total number of tokens used for input and output

- `inputCount`

  Number of tokens used to process the input

## See Also

- [Using Anypoint Code Builder to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-acb)

- [Using Studio to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-studio)

- [MuleSoft AI Chain Connector Overview](https://docs.mulesoft.com/mulesoft-ai-chain-connector/latest/)

- [MuleSoft AI Chain Connector Reference](https://docs.mulesoft.com/mulesoft-ai-chain-connector/latest/mulesoft-ai-chain-connector-reference)

- [Salesforce Help](https://help.salesforce.com)
