# LLM Answer Generators

### Configuring the LLM Node for RAG in Dynamiq

In this section, we'll guide you through setting up the LLM node within Dynamiq's Workflow Builder for a Retrieval-Augmented Generation (RAG) application. This involves selecting an LLM provider, configuring parameters, and integrating the node into your workflow.

**Step 1: Select an LLM Provider**

Dynamiq offers a wide range of LLM providers. Choose the one that best fits your needs from the list:

<figure><img src="/files/zRtxgqpWZysRwpxlDV31" alt="" width="249"><figcaption></figcaption></figure>

**Step 2: Configure the LLM Node**

Once you've selected a provider, configure the LLM node:

<figure><img src="/files/QbsYJzJurrFWpFb1ytuw" alt="" width="375"><figcaption></figcaption></figure>

1. **Connection Configuration:**
   * Name your node for easy identification.
   * Establish a connection using the provider's API keys.
2. **Prompt Configuration:**

<figure><img src="/files/EqjqozZyDjbm71WxBUt3" alt="" width="375"><figcaption></figcaption></figure>

* Use the Prompt Library or create an Inline Prompt.
* Example prompt for question answering:

  <pre class="language-jinja"><code class="lang-jinja">Please answer the following question based on the information found
  within the sections enclosed by triplet quotes (\`\`\`).
  Your response should be concise, well-written, and follow markdown formatting guidelines:

    - Use bullet points for list items.
    - Use **bold** text for emphasis where necessary.
  <strong>
  </strong><strong>**Question:** {{query}}
  </strong>
  Thank you for your detailed attention to the request
  **Context information**:
  ```
    {% for document in documents %}
        ---
        Document title: {{ document.metadata["title"] }}
        Document information: {{ document.content }}
        ---
    {% endfor %}
  ```

  **User Question:** {{query}}
  Answer:
  </code></pre>

3\. **Core Parameters:**

* **Model:** Select the appropriate model.
* **Temperature:** Set for randomness (e.g., 0.2 for deterministic, 0.7 for creative).
* **Max Tokens:** Define the maximum output length.
* **Streaming:** Enable if real-time feedback is needed.

**Step 3: Input Transformation**

<figure><img src="/files/iCGkJjZa7hMW3sfXhrwT" alt=""><figcaption></figcaption></figure>

To use documents in your prompt, map the output from the retriever node to the LLM node:

* Use JSONPath syntax in the Input Transformer section:

  ```json
  {
      "documents":"$.weaviate-retriever.output.documents",
      "query":"$.input.output.question"
  }
  ```

**Step 4: Connect the Output**

Finally, connect the LLM node's output to the Output Node or any other node as required:

* Ensure the content from the LLM node is properly routed to display or further processing.

### **Additional Tips**

* **Streaming Responses:** Enable streaming for applications requiring immediate feedback.
* **Prompt Design:** Use Jinja templates to dynamically incorporate document metadata into prompts.

By following these steps, you can effectively set up the LLM node in your RAG workflow, ensuring accurate and contextually relevant responses.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.getdynamiq.ai/low-code-builder/rag-nodes/inference-rag-workflow/llm-answer-generators.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
