Prompt Data Limited info

Extract Only the Facts From the User's Latest Message

Reads a conversation and returns a JSON object of only the facts the user explicitly stated in the latest message, using earlier turns just to understand the question, and treating a correction as the new truth.

  • 🤖 Any chat LLM
  • 🗂️ Data

Prompt by Confident AI (confident-ai/deepeval) · Original source (opens in a new tab)

Extract Only the Facts From the User's Latest Message — prompt preview

The prompt

prompt
You are given a conversation between an AI assistant and a user. The assistant is asking questions to collect structured information, and the user is responding casually or factually.

Your task is to extract **only the factual information found in the most recent user message** and return it as a JSON object.

---
**Guidelines:**
1. Only extract information that is **explicitly stated** in the user message.
2. Use the previous turns only to understand what the assistant is asking about.
3. Do not extract anything based on assumptions or the assistant's message alone.
4. If the user message confirms, corrects, or adds to earlier facts, treat the user message as the source of truth.
5. Output a valid **JSON object**. All keys must be **strings**, and all values must be **strings or lists of strings**.
6. If there is no factual content in the user message, return an empty JSON (`{}`).

---
**Example A**
Previous Turns:
{
  {
    "role": "assistant", "content": "What's your full name?"
  }
}
User message: "It's Emily Chen"
JSON:
{
  "data": {
    "Full Name": "Emily Chen"
  }
}

---
**Example B**
Previous Turns:
{
  {
    "role": "assistant", "content": "Where are you currently located?"
  }
}
User message: "I'm in Berlin right now."
JSON:
{
  "data": {
    "Current Location": "Berlin"
  }
}

---
**Example C**
Previous Turns:
{
  {
    "role": "assistant", "content": "Do you have any dietary restrictions?"
  }
}
User message: "Yes, I'm vegetarian and allergic to peanuts."
JSON:
{
  "data": {
    "Dietary Restrictions": ["Vegetarian", "Peanut Allergy"]
  }
}

---
**Example D**
Previous Turns:
{
  {
    "role": "assistant", "content": "Can I confirm your birth year is 1989?"
  }
}
User message: "No, it's actually 1992."
JSON:
{
  "data": {
    "Birth Year": "1992"
  }
}

---
Now complete the task below:

Previous Turns:
{{ previous_turns }}

Latest User Message:
{{ user_message }}

JSON:

What it is

Reads a conversation and returns a JSON object of only the facts the user explicitly stated in the latest message, using earlier turns just to understand the question, and treating a correction as the new truth. The repository publishes this prompt without a printed sample of its output. The prompt text comes from the deepeval repository (Apache License 2.0; pyproject.toml declares Apache-2.0). Licence: https://github.com/confident-ai/deepeval/blob/main/LICENSE.md and https://www.apache.org/licenses/LICENSE-2.0. Original author: Confident AI (confident-ai/deepeval). Changes by FoxaMind: the text is copied from the source file; any joining or trimming is described in the tips.

Who it's for

  • Developers building chatbots that collect details
  • Teams testing whether a bot remembers

يقرأ محادثة ويعيد كائن JSON يحوي فقط الحقائق التي ذكرها المستخدم صراحة في آخر رسالة، ويعتبر التصحيح هو الحقيقة الجديدة.

Tips

  • The double-brace fields are template variables from the framework that ships this prompt. Replace them with your own values.
  • It has four few-shot examples inside the prompt, written by the authors. They are not outputs from a real run.
  • The 'previous turns' examples in the source use odd double braces. The source shows them that way.