> For the complete documentation index, see [llms.txt](https://docs.datasaur.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datasaur.ai/llm-projects/sandbox/conversational-prompt.md).

# Conversational prompt

## Overview

Conversational prompting supports multi-turn conversation testing in LLM Labs. It allows prompts and responses to be evaluated across multiple interactions, helping assess how well a language model maintains context and coherence throughout a conversation. This feature can be used to test and analyze model behavior in conversational workflows.

## Get started

1. Navigate to your [Sandbox](/llm-projects/sandbox.md).
2. Click the three-dot menu in a prompt.

   <figure><img src="/files/p8xJfwe7PVgobwbAlL8v" alt=""><figcaption></figcaption></figure>
3. Choose your method:
   * **Add conversation**: Manually input a new conversation directly into the prompt. Learn more on how to [write the conversation](#write-conversation-manually).

     <figure><img src="/files/CKc7cYG9itnVlIRbx0H3" alt=""><figcaption></figcaption></figure>
   * **Upload conversation file**: Upload a `.json` conversation file for testing. Learn more about the [JSON file format](#create-the-json-file-format).

     <figure><img src="/files/OXzwhp9RtSawe8yHvTgQ" alt=""><figcaption></figcaption></figure>
4. Execute the conversation and observe how the language model performs, maintaining context and coherence across turns.

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

### Understanding roles

Roles are used to represent the conversational input from the user and the assistant.

* **User:** Represents input from the user, such as a request or question sent to the model.
* **Assistant:** Represents the model's response, either as a reply or part of the conversation history in a prompt.

You can manually change the roles via the dropdown when writing the conversational prompt to define the prompt input. This flexibility allows you to simulate various conversational dynamics and test how the model responds to different types of interactions.

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

### Write conversation manually

1. In the **Add conversation** dialog:

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

   1. Write the prompt to represent the input based on your needs, whether it is for the assistant or user roles.
   2. Use the role dropdown to specify the role for each message (user or assistant).
   3. Enter the content of the message in the provided text area.
2. Add more messages to the conversation:

   You can also add more messages in this dialog. To add a message, hover to the text input, and there will be 3 buttons:

   1. **Add above:** When clicked, a new text input will appear above the current text input that you are hovering.
   2. **Add below:** When clicked, a new text input will appear under the current text input that you are hovering.
   3. **Delete:** When clicked, it will delete the message.
3. **Reorder the conversation**: You can drag and drop each message to reorder the conversation.

   <figure><img src="/files/lSxnJnkdLRr6wUWOVYnA" alt=""><figcaption></figcaption></figure>
4. **Attach files and URLs**:

   You can attach files or URLs to messages with the **User** role. This capability is useful for simulating real-world scenarios where users might share documents or links. Learn more about [file attachment](/llm-projects/sandbox/file-attachment.md).

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

{% hint style="info" %}
Each message in a conversation can have up to 5 attachments. For example, with 3 messages in a prompt, you can have up to 15 attachments.
{% endhint %}

### Create the JSON file format

**Structure:**

The core structure is an array of objects:

```jsx
[
  {
    "content": "...",
    "role": "..."
  },
  {
    "content": "...",
    "role": "..."
  },
  // ... more turns
]
```

**Fields:**

* **`content`:**
  * This field holds the actual message or interaction data.
  * It can be a simple string for plain text messages.
  * Alternatively, it can be an array of objects to include attachments like URLs or images.
  * This field **cannot be empty**. Every conversation turn must contain content.
* **`role`:**
  * This field indicates the speaker's role in the conversation.
  * It can be either `"user"` or `"assistant"`.

**Attachments (URLs and files):**

To include attachments, the `content` field should be an array of objects. Each object within this array can represent text, a file URL, or a website URL.

* **Text:**
  * Use `{"type": "text", "text": "Your text here"}`.
* **File URL:**
  * Use `{"type": "image_url", "image_url": {"url": "<https://example.com/image.jpg>"}}`.
* **URL (Website link):**
  * Use `{"type": "image_url", "url": "<https://example.com>"}`.

**Sample JSON file**:

{% file src="/files/WIRTVv1SALXms5N2F6KW" %}

## Conversational vs basic prompt

<figure><img src="/files/2FYx8b72YIPYjLDLr73E" alt=""><figcaption></figcaption></figure>

#### Conversational prompt

* Maintains and understands the full history of the conversation.
* Handles back-and-forth dialogue naturally.
* Generates replies based on accumulated context.

#### Basic prompt

* Treats each input as an independent request.
* Has no memory of previous interactions.
* Generates replies based solely on the immediate input.
