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

# Prompt Task Types

Karini AI supports the following prompt task types through its Prompt Playground.

## Classification

A classification prompt instructs the LLM to classify the user input into different classes based on the content of the input text.

#### Example:

Here is an example classification prompt. Karini's Prompt Playground gives you the flexibility to add prompt instructions, variables and few-shot examples as relevant to the task. Pay attention to the use of [special variables](https://docs.karini.ai/prompt-management/create-prompt.md#special-variables) if you want to dynamically replace the values during production use.

### **Prompt**:

```
Classify the summarized context into the appropriate category:

<summarized_context>
 {summarized_context} 
</summarized_context>

<categories>
 {categories}
</categories>

Provide the response in JSON format.
```

### **Variables**:

1. summarized\_context

{% code overflow="wrap" %}

```
The automotive industry began in the 1860s with hundreds of manufacturers that pioneered the horseless carriage. For many decades, the United States led the world in total automobile production. In 1929, before the Great Depression, the world had 32,028,500 automobiles in use, and the U.S. automobile industry produced over 90% of them. At that time, the U.S. had one car per 4.87 persons. After 1945, the U.S. produced about 75 percent of world's auto production. In 1980, the U.S. was overtaken by Japan and then became a world leader again in 1994. In 2006, Japan narrowly passed the U.S. in production and held this rank until 2009, when China took the top spot with 13.8 million units. With 19.3 million units manufactured in 2012, China almost doubled the U.S. production of 10.3 million units, while Japan was in third place with 9.9 million units. From 1970 (140 models) over 1998 (260 models) to 2012 (684 models), the number of automobile models in the U.S. has grown exponentially.
```

{% endcode %}

2. categories

```
Technology
Finance
Travel
Sports
HealthCare
Education
```

### **Output**:

```
{
"category": "Technology"
}
```

## Summarization

A summarization prompt instructs the LLM to summarize the user input text.

#### Example:

Here is an example summarization prompt. Karini's Prompt Playground gives you the flexibility to add prompt instructions, variables and few-shot examples as relevant to the task. Pay attention to the use of [special variables](https://docs.karini.ai/prompt-management/create-prompt.md#special-variables) if you want to dynamically replace the values during production use.

### **Prompt**:

```
Summarize the following text in {number_of_words} words:

{context}
```

### **Variables**:

1. number\_of\_words

```
40
```

2. context

```
The automotive industry comprises a wide range of companies and organizations involved in the design, development, manufacturing, marketing, selling, repairing, and modification of motor vehicles. It is one of the world's largest industries by revenue (from 16 % such as in France up to 40 % to countries like Slovakia).The word automotive comes from the Greek autos (self), and Latin motivus (of motion), referring to any form of self-powered vehicle. This term, as proposed by Elmer Sperry
(1860–1930), first came into use with reference to automobiles in 1898.


== History ==

The automotive industry began in the 1860s with hundreds of manufacturers that pioneered the horseless carriage. For many decades, the United States led the world in total automobile production. In 1929, before the Great Depression, the world had 32,028,500 automobiles in use, and the U.S. automobile industry produced over 90% of them. At that time, the U.S. had one car per 4.87 persons. After 1945, the U.S. produced about 75 percent of world's auto production. In 1980, the U.S. was overtaken by Japan and then became a world leader again in 1994. In 2006, Japan narrowly passed the U.S. in production and held this rank until 2009, when China took the top spot with 13.8 million units. With 19.3 million units manufactured in 2012, China almost doubled the U.S. production of 10.3 million units, while Japan was in third place with 9.9 million units. From 1970 (140 models) over 1998 (260 models) to 2012 (684 models), the number of automobile models in the U.S. has grown exponentially.Early car manufacturing involved manual assembly by a human worker. The process evolved from engineers working on a stationary car, to a conveyor belt system where the car passed through multiple stations of more specialized engineers. Starting in the 1960s, robotic equipment was introduced to the process, and today most cars are produced largely with automated machinery.


== Safety ==

Safety is a state that implies being protected from any risk, danger, damage, or cause of injury. In the automotive industry, safety means that users, operators, or manufacturers do not face any risk or danger coming from the motor vehicle or its spare parts. Safety for the automobiles themselves implies that there is no risk of damage.
Safety in the automotive industry is particularly important and therefore highly regulated. Automobiles and other motor vehicles have to comply with a certain number of regulations, whether local or international, in order to be accepted on the market. The standard ISO 26262, is considered one of the best practice frameworks for achieving automotive functional safety.In case of safety issues, danger, product defect, or faulty procedure during the manufacturing of the motor vehicle, the maker can request to return either a batch or the entire production run. This procedure is called product recall. Product recalls happen in every industry and can be production-related or stem from raw materials.
Product and operation tests and inspections at different stages of the value chain are made to avoid these product recalls by ensuring end-user security and safety and compliance with the automotive industry requirements. However, the automotive industry is still particularly concerned about product recalls, which cause considerable financial consequences.

```

### **Output**:

```
The automotive industry involves companies engaged in designing, manufacturing, marketing, and servicing motor vehicles. It is one of the largest industries globally, with revenue contributions ranging from 16% to 40% in different countries. The industry originated in the 1860s and has evolved from manual assembly to automated production lines. Safety is a critical aspect, governed by stringent regulations and standards to ensure user protection and compliance.
```

## QnA (Deprecated)

This prompt helps obtain answers from the provided context.

#### Example:

Here is an example QnA prompt. Karini's Prompt Playground gives you the flexibility to add prompt instructions, variables and few-shot examples as relevant to the task. Pay attention to the use of [special variables](https://docs.karini.ai/prompt-management/create-prompt.md#special-variables) if you want to dynamically replace the values during production use.

### **Prompt**:

```
Considering the information presented in the context, your task is to analyze and answer the following questions in a concise and structured manner. Ensure that your responses directly address the specific details outlined in the context provided.

Context:{context}

Question:{question}
```

### **Variables**:

1. context

```
A travel document is an identity document issued by a government or international entity pursuant to international agreements to enable individuals to clear border control measures. Travel documents usually assure other governments that the bearer may return to the issuing country, and are often issued in booklet form to allow other governments to place visas as well as entry and exit stamps into them.
```

2. question

```
What is travel document?
```

### **Output**:

```
A travel document is an identity document issued by a government or international entity, designed in accordance with international agreements to facilitate the movement of individuals across borders. It serves to verify the identity and nationality of the bearer, ensuring that they can pass through border control measures. Additionally, it provides assurance to foreign governments that the holder has the right to return to the country that issued the document. Typically issued in booklet form, travel documents allow for the inclusion of visas, as well as entry and exit stamps, by other countries.
```

## Evaluation

This prompt assesses answers against ground truth answers, offering metric scores based on specified criteria.

#### Example:

Here is an example evaluation prompt. Karini's Prompt Playground gives you the flexibility to add prompt instructions, variables and few-shot examples as relevant to the task. Pay attention to the use of [special variables](https://docs.karini.ai/prompt-management/create-prompt.md#special-variables) if you want to dynamically replace the values during production use.

### **Prompt**:

```
Task: Evaluate Relevance

Objective:
Assess the alignment of the Model Output with the Evaluation Input and, crucially, the Ground Truth. The evaluation should rigorously follow the defined metric and grading criteria, with a special focus on the Ground Truth's role in determining relevance.

Metric: {evaluation_metric_name}
Description: {evaluation_metric_description}

Grading Criteria: {evaluation_grading_criteria}

Parameters:
- Input: {evaluation_input}
- Model Output: {evaluation_output}
- Ground Truth: {evaluation_ground_truth} (Note: This parameter is pivotal. If the output significantly diverges from the Ground Truth, the relevance score should be adjusted downwards accordingly.)

Instructions:
Critically analyze the Model Output in the context of the Evaluation Input and especially the Ground Truth. The presence, accuracy, and alignment of the Ground Truth with the Model Output are paramount in this evaluation. Assign a relevance score that reflects this emphasis, with a lowered score for outputs that do not align with a well-defined Ground Truth. Provide a concise justification, limited to 10 words, for the assigned score.

Output Format (JSON string) example with key-values for each metric:
[{{'metric_name': 'metric-1-name', 'score': x1, 'justification': 'Provide justification for metric 1 here.'}}, {{'metric_name': 'metric-2-name', 'score': x2, 'justification': 'Provide justification for metric 2 here.'}}]

Note: Ensure that each entry in the output array corresponds to one of the metrics listed. The 'score' should reflect the assessment based on the specific grading criteria for that metric, and the 'justification' should concisely capture the rationale behind the assigned score. The number of objects in the output array should match the number of metrics being evaluated.
```

### **Variables:**

1. evaluation\_metric\_name

```
Relevance
```

2. evaluation\_metric\_description

```
Relevance evaluates the extent to which the provided answer aligns with the question and context. A fully relevant answer should directly and comprehensively address the query, avoiding extraneous content. Conversely, an irrelevant answer diverges from the query, offering incomplete responses or unrelated details.
```

3. evaluation\_grading\_criteria

```
- Score 5: Direct, complete, and fully relevant answer.
- Score 4: Mostly relevant, with minor irrelevant details.
- Score 3: Partial relevance, noticeable deviation or incompleteness.
- Score 2: Limited relevance, significant deviation or incorrectness.
- Score 1: Completely irrelevant, lacking any pertinent content.
```

4. evaluation\_input

```
What is AWS?
```

5. evaluation\_output

```
AWS (Amazon Web Services) is a comprehensive cloud computing platform provided by Amazon. It offers a broad set of global cloud-based products and services for businesses and developers to build, deploy, and manage applications and services cost-effectively and at scale.

Some key areas where AWS provides services include:

Compute: Services like EC2 (Elastic Compute Cloud) for virtual servers, Lambda for serverless computing, and more.
Storage: Services like S3 (Simple Storage Service) for object storage, EBS (Elastic Block Store) for block storage, and more.
Databases: Managed database services like RDS (Relational Database Service), DynamoDB (NoSQL database), and more.
Networking: Services like VPC (Virtual Private Cloud), Direct Connect, and more for secure networking.
Analytics: Services like Athena, Redshift, EMR (Elastic MapReduce), and more for big data processing and analytics.
Machine Learning: Services like SageMaker, Rekognition, Lex, and more for building and deploying ML models.
Internet of Things (IoT): Services like IoT Core, IoT Greengrass, and more for building IoT applications.
And many more services across various domains like security, management tools, mobile, AR/VR, and more.
```

6. evaluation\_ground\_truth

```
Amazon Web Services (AWS) is a comprehensive cloud computing platform provided by Amazon.com. AWS offers a wide range of services that cater to computing power, storage, databases, machine learning, analytics, content delivery, Internet of Things (IoT), security, and more. These services are delivered over the internet on a pay-as-you-go basis, allowing businesses and individuals to scale and utilize computing resources without the need to invest in and maintain physical infrastructure.

Key components and services of AWS include:

Compute Services:

Amazon Elastic Compute Cloud (EC2): Provides resizable compute capacity in the cloud.
AWS Lambda: Lets you run code without provisioning or managing servers.
Storage Services:

Amazon Simple Storage Service (S3): Scalable object storage for data backup, archiving, and analytics.
Amazon Elastic Block Store (EBS): Provides block-level storage volumes for use with EC2 instances.
Database Services:

Amazon RDS: Managed relational database service.
Amazon DynamoDB: Managed NoSQL database service.
Networking:

Amazon Virtual Private Cloud (VPC): Enables you to launch Amazon Web Services resources into a virtual network.
Amazon Route 53: Scalable domain name system (DNS) web service.
Machine Learning and AI:

Amazon SageMaker: Fully managed service for building, training, and deploying machine learning models.
Amazon Polly: Text-to-speech service.
Amazon Rekognition: Image and video analysis service.
Analytics and Big Data:

Amazon Redshift: Fully managed, petabyte-scale data warehouse service.
Amazon Athena: Query data in Amazon S3 using SQL.
Security and Identity:

AWS Identity and Access Management (IAM): Securely control access to AWS services and resources.
AWS Key Management Service (KMS): Managed service that makes it easy for you to create and control the keys used to encrypt your data.
Internet of Things (IoT):

AWS IoT Core: Connects devices to the cloud and enables them to interact with applications.
AWS has become a dominant force in the cloud computing industry and is widely used by businesses, startups, and individuals globally for building and deploying applications and services.
```

### **Output**:

```
[{'metric_name': 'Relevance', 'score': 4, 'justification': 'Mostly relevant, minor irrelevant details.'}]
```

## Agent

An agent prompt can take actionable steps, creating a more sophisticated system that can understand and process information, evaluate situations, take appropriate actions, communicate responses, and track ongoing situations.

#### Example:

Here is an example agent prompt. Karini's Prompt Playground gives you the flexibility to add prompt instructions, variables and few-shot examples as relevant to the task. Pay attention to the use of [special variables](https://docs.karini.ai/prompt-management/create-prompt.md#special-variables) if you want to dynamically replace the values during production use.

### **Prompt**:

```
You are a virtual insurance agent. Answer questions as best as you can.

Rules for Email Notification:

1.For specific information requests, such as policy details or policy status, ask the user if they would like an email notification with the information.
2.If the user confirms they would like an email notification, ask them to provide their email address. Follow this instruction strictly.
3.Do not send an email on your own; simply confirm receipt of the email address and proceed to the next step.
4.When the email address is provided, acknowledge with "Final Answer" and confirm that the user's request for email notification is noted.Follow this instruction carefully and strictly.
5.Always provide a complete and detailed answer to the user's question as your "Final Answer" before asking if they need an email notification.
```

### Question

```
Give me details on Alice's policy. Give structured and easy to read output, explaining impact.
```

### Output:

```
The details of Alice's policy have been provided, including her personal information, policy number, expiry date, status, premium amount, and coverage amount. The policy is currently pending, and Alice needs to ensure it becomes active to benefit from the $100,000 coverage.
```

## Deep Agent

[Deep Agent](https://docs.karini.ai/prompt-management/deep-agent-beta.md) is an advanced evolution of agentic workflows, giving developers fine-grained control over AI agent behavior, tool execution, and decision-making. Unlike standard agents that execute autonomously, deep agents support interruption points, approval workflows, sub-agents, and reusable skills.

#### Example:

Here is an example deep agent prompt. Karini's Prompt Playground gives you the flexibility to add prompt instructions, variables and few-shot examples as relevant to the task. Pay attention to the use of [special variables](https://docs.karini.ai/prompt-management/create-prompt.md#special-variables) if you want to dynamically replace the values during production use.

### **Prompt**:

```
# Task: Answer Questions Using Available Tools

You are an AI assistant equipped with various tools to help answer questions accurately and effectively.

## Objective
Provide the best possible answer to the user's question by leveraging the tools at your disposal.

## Instructions

1. **Analyze the Question**: Carefully read and understand what the user is asking.

2. **Identify Relevant Tools**: Determine which of your available tools would be most helpful in answering the question.

3. **Use Tools Strategically**: 
   - Select the most appropriate tool(s) for the task
   - Use tools in a logical sequence if multiple tools are needed
   - Interpret tool outputs accurately

4. **Formulate Your Answer**:
   - Synthesize information gathered from the tools
   - Provide a clear, comprehensive response
   - Ensure your answer directly addresses the question asked

5. **Handle Limitations**:
   - If no suitable tool is available, use your general knowledge
   - If you cannot answer with confidence, acknowledge the limitation
   - Explain your reasoning process when appropriate
```

### Question

```
How can Amazon SageMaker Clarify help streamline the evaluation process?
```

### Output:

```
Let me use the Knowledge Base Tool to gather information about Amazon SageMaker Clarify and its evaluation capabilities.. Workflow interrupted: {'interrupted': True, 'decisions_required': [{'node_name': 'DeepAgent', 'tool_name': 'Knowledge_Base_Tool', 'args': {'query': 'How does Amazon SageMaker Clarify make evaluation easier? What are its key features for model evaluation?'}, 'allowed_decisions': ['approve', 'edit', 'reject']}]} Based on the information retrieved, let me provide a comprehensive response about how Amazon SageMaker Clarify makes evaluation easier. Amazon SageMaker Clarify makes model evaluation easier in several key ways: 1. Unified Evaluation Platform: - Provides a single place to evaluate and compare any LLM based on predefined criteria - Supports evaluation during model selection and throughout the model customization workflow 2. Comprehensive Evaluation Methods: - Offers automatic evaluation capabilities - Includes human-in-the-loop capabilities for subjective criteria assessment - Allows evaluation of metrics like helpfulness, creative intent, and style 3. Flexible Evaluation Options: - Provides curated prompt datasets for common LLM tasks: * Open-ended text generation * Text summarization * Question answering (Q&A) * Classification - Supports custom prompt datasets and metrics for specific use cases 4. Workforce Options: - Allows using your own workforce - Provides access to managed workforce through SageMaker Ground Truth 5. Detailed Reporting: - Generates evaluation reports with natural language summaries - Includes visualizations and examples - Provides downloadable metrics and reports - Integrates with SageMaker MLOps workflows 6. Easy Access and Setup: - Accessible through SageMaker Studio under "Jobs" menu - Direct evaluation option from model details page in SageMaker JumpStart - Guided UI wizard for setting up evaluation jobs 7. Broad Model Support: - Evaluates LLMs from SageMaker JumpStart - Supports models trained and hosted outside of AWS - Removes the complexity of adopting academic benchmarks for generative AI use cases These features significantly simplify the process of evaluating and selecting foundation models while providing comprehensive assessment capabilities.
```

### OCR (Optical Character Recognition)

An OCR prompt instructs the LLM to extract and process text from images, including documents, screenshots, handwritten notes, or any visual content containing text.

Use OCR prompts to digitize printed or handwritten text from images, extract information from forms, process scanned documents, or analyze text within visual content. The LLM processes image inputs and returns structured text output.

#### Example

The following example demonstrates the default VLM Document Extraction template from the Prompt Playground.

**Prompt:**

*System Message:*

```
You are a document and image analysis engine. Your task is to perform exhaustive content extraction from the provided image. Extract **every element** - text, tables, figures, forms, diagrams, photos, logos, stamps, barcodes, handwriting, watermarks, and any other visual content. Nothing should be omitted.

Assume the downstream consumer **cannot see the image** and must reconstruct a complete understanding from your output alone.

Analyze the attached image and produce a structured extraction report covering layout, text content, tables, forms, figures, images, logos, barcodes, handwriting, and other visual elements. For each category not present in the image, explicitly state "Not present".

- Use **markdown** formatting
- Reproduce tables as markdown tables
- Be exhaustive - completeness is more important than brevity
```

*User Message:*

```
{image}
```

**Variables:**

`image`:

* Description: The image or document to analyze
* Default: (empty - file upload expected)

**Example Input:**

\[Image of a invoice document]

**Example Output:**

```
## Document Layout
Single-column portrait layout. Standard invoice format with header, itemized body, and footer.

## Text Content

INVOICE

ABC Corporation
123 Business Street, New York, NY 10001
Phone: (555) 123-4567

Bill To: XYZ Company
Invoice Number: INV-2024-001234
Invoice Date: January 15, 2024
Due Date: February 14, 2024

## Tables

| Item Description | Quantity | Unit Price | Amount |
|-----------------|----------|------------|---------|
| Professional Services | 40 hrs | $150.00 | $6,000.00 |
| Software License | 1 | $2,500.00 | $2,500.00 |

Subtotal: $8,500.00
Tax (8.5%): $722.50
Total Amount Due: $9,222.50

## Purpose
Business invoice requesting payment for professional services and software licensing provided to XYZ Company.
```

### Dynamic Filtering (OpenSearch)

A dynamic filtering prompt for OpenSearch instructs the LLM to generate appropriate query DSL (Domain Specific Language) based on natural language input, enabling dynamic search queries against OpenSearch indices.

Use dynamic filtering prompts to translate user questions into OpenSearch query syntax, build complex filter combinations, generate aggregations, and create search queries without requiring users to know OpenSearch DSL syntax.

#### Example

The following example shows the default Dynamic Filtering (OpenSearch) template.

**Prompt:**

*System Message:*

```
You generate OpenSearch/Elasticsearch filter queries from a user's natural language question and the available index metadata schema.

Instructions:
1. Extract filtering criteria from the question: entity names, values, date ranges, numeric thresholds, exclusions
2. Map to schema fields using the provided index_metadata
3. Select the right operator per field type:
   - keyword fields: use term (single value) or terms (multiple values) inside filter for exact matching
   - text fields: use match inside must with fuzziness: AUTO
   - integer/float fields: use term for exact values, range for thresholds
   - date fields: use range with gte/lte/gt/lt in ISO format (YYYY-MM-DD)
4. Place filters in the correct bool clause: filter, must, should, or must_not
5. Field access: always prefix fields with metadata.

Return ONLY the JSON query object. No markdown fences, no explanation, no preamble.
```

*User Message:*

```
[QUESTION]
{question}
[/QUESTION]

[INDEX METADATA]
{index_metadata}
[/INDEX METADATA]
```

**Variables:**

`question`:

* Description: User retrieval question
* Default: (empty)

`index_metadata`:

* Description: Index metadata schema
* Default: (empty)

**Example Input:**

```
Question: Find invoices from January 2024 for vendor Acme Corp with amounts over $5000

Index Metadata:
{"fields": {"metadata.invoice_date": {"type": "date"}, "metadata.vendor_name": {"type": "text"}, "metadata.amount": {"type": "float"}}}
```

**Example Output:**

```json
{
  "query": {
    "bool": {
      "filter": [
        {"range": {"metadata.invoice_date": {"gte": "2024-01-01", "lt": "2024-02-01"}}},
        {"range": {"metadata.amount": {"gt": 5000}}}
      ],
      "must": [
        {"match": {"metadata.vendor_name": {"query": "Acme Corp", "fuzziness": "AUTO"}}}
      ]
    }
  }
}
```

***

### Dynamic Filtering (Teradata)

A dynamic filtering prompt for Teradata instructs the LLM to generate SQL WHERE clauses optimized for Teradata databases based on natural language questions.

Use dynamic filtering prompts to convert user questions into Teradata SQL syntax, leverage Teradata-specific features and optimizations, handle complex joins and aggregations, and generate efficient queries for large-scale data warehouse operations.

#### Example

The following example demonstrates the default Dynamic Filtering (Teradata) template.

**Prompt:**

*System Message:*

```
You generate a Teradata SQL WHERE clause from a user's natural language question and the available table schema. Never hallucinate column names, operators, or values outside what is provided.

Instructions:
1. Extract filter criteria from the question
2. Match to table columns using the provided schema
3. Discard unmappable concepts - if a concept has no matching column, omit it entirely
4. If no reliable filter can be constructed, set where_condition to null

Operator rules by type:
- VARCHAR/CHAR: =, LIKE '%value%', IN ('val1', 'val2')
- INTEGER/BIGINT: =, >, <, >=, <=, BETWEEN, IN
- DATE: =, >, <, >=, <=, BETWEEN. Literals: DATE 'YYYY-MM-DD'
- TIMESTAMP: Literals: TIMESTAMP 'YYYY-MM-DD HH:MM:SS'

Return ONLY a valid JSON object with a single key where_condition. No markdown fences, no explanation.
Format: {"where_condition": "<clause string or null>"}
```

*User Message:*

```
[QUESTION]
{question}
[/QUESTION]

[TABLE SCHEMA]
{table_schema}
[/TABLE SCHEMA]
```

**Variables:**

`question`:

* Description: User retrieval question
* Default: (empty)

`table_schema`:

* Description: Teradata table schema
* Default: (empty)

### Dynamic Filtering (PostgreSQL)

A dynamic filtering prompt for PostgreSQL instructs the LLM to generate PostgreSQL-compliant SQL WHERE clauses with appropriate syntax and features for PostgreSQL databases.

Use dynamic filtering prompts to create PostgreSQL queries from natural language, utilize PostgreSQL-specific functions and features, generate complex queries with CTEs and window functions, and optimize for PostgreSQL query planner.

#### Example

The following example shows the default Dynamic Filtering (PostgreSQL) template.

**Prompt:**

*System Message:*

```
You generate a PostgreSQL SQL WHERE clause from a user's natural language question and the available table schema. Never hallucinate column names, operators, or values outside what is provided.

Instructions:
1. Extract filter criteria from the question
2. Match to table columns using the provided schema
3. Discard unmappable concepts
4. If no reliable filter can be constructed, set where_condition to null

Operator rules by type:
- TEXT/VARCHAR: =, ILIKE '%value%', IN ('val1', 'val2'). Prefer ILIKE over LIKE
- INTEGER/BIGINT/SMALLINT: =, >, <, >=, <=, BETWEEN, IN
- BOOLEAN: = TRUE or = FALSE (never use string values)
- DATE: =, >, <, >=, <=, BETWEEN. Literals: 'YYYY-MM-DD'
- TIMESTAMP: Literals: 'YYYY-MM-DD HH:MI:SS'
- TEXT[] arrays: @> for contains, = ANY(column) for membership check
- JSONB: ->> 'key' for text values

Return ONLY a valid JSON object: {"where_condition": "<clause string or null>"}
```

*User Message:*

```
[QUESTION]
{question}
[/QUESTION]

[TABLE SCHEMA]
{table_schema}
[/TABLE SCHEMA]
```

**Variables:**

`question`:

* Description: User retrieval question
* Default: (empty)

`table_schema`:

* Description: PostgreSQL table schema
* Default: (empty)

### Dynamic Filtering (Azure AI Search)

A dynamic filtering prompt for Azure AI Search instructs the LLM to generate Azure AI Search filter JSON based on natural language input, enabling semantic search and filtering.

Use dynamic filtering prompts to create Azure AI Search queries from user questions, leverage semantic search capabilities, apply filters and facets, and generate scoring profiles for relevance ranking.

#### Example

The following example demonstrates the default Dynamic Filtering (Azure AI Search) template.

**Prompt:**

*System Message:*

```
You generate Azure AI Search filter JSON from a user's natural language question and the available index metadata schema. Never hallucinate field names, operators, or values outside what is provided.

Instructions:
1. Extract filterable concepts: entities, dates, categories, numeric values
2. Match to schema: Map strictly to fields in index_metadata
3. Discard unmappable concepts
4. Resolve temporal expressions: Convert relative dates to ISO 8601 ranges only if confident
5. If no constraints remain, return {}

All fields must be prefixed with metadata_ using underscore notation.

Filter syntax examples:
- Exact match: { "metadata_category": "HR" }
- Match any (IN): { "metadata_category": ["HR", "Finance"] }
- Range: { "metadata_date": { "gte": "2023-01-01T00:00:00Z", "lt": "2023-07-01T00:00:00Z" } }
- Collection fields: { "metadata_tags": { "$any": "compliance" } }
- Logical: "$and": [...], "$or": [...]

Return ONLY the JSON filter object. No markdown fences, no explanation. If no constraints, return {}.
```

*User Message:*

```
[QUESTION]
{question}
[/QUESTION]

[INDEX METADATA]
{index_metadata}
[/INDEX METADATA]
```

**Variables:**

`question`:

* Description: User retrieval question
* Default: (empty)
* Required: True
* User Input: True

`index_metadata`:

* Description: Index metadata schema
* Default: (empty)

### Dynamic Filtering (Pinecone)

A dynamic filtering prompt for Pinecone instructs the LLM to generate vector search queries with metadata filters for Pinecone vector databases.

Use dynamic filtering prompts to create Pinecone queries combining vector similarity search with metadata filtering, optimize query parameters for relevance, and generate appropriate filter expressions.

#### Example

The following example shows the default Dynamic Filtering (Pinecone) template.

**Prompt:**

*System Message:*

```
You generate Pinecone metadata filter JSON from a user's natural language question and the available index metadata schema. Never hallucinate field names, operators, or values outside what is provided.

Operators by type:
- string: $eq, $ne, $in, $nin
- float/integer: $eq, $gt, $gte, $lt, $lte
- boolean: $eq (true or false only, never strings)
- nullable: $exists (true or false)
- logical: $and (array), $or (array), $not (single object)

Rules:
1. Use ONLY field names present in the schema
2. Use ONLY operators valid for that field's type
3. Multiple conditions must be wrapped in $and
4. $in / $nin values must always be a JSON array
5. boolean values must be true or false, never strings
6. Date fields stored as float/integer must be converted to Unix epoch (seconds, 10 digits)
7. If no filterable condition can be extracted, return {}
8. Return ONLY raw JSON. No markdown fences, no explanation

Examples:
Single condition: {"field": {"$eq": "value"}}
AND: {"$and": [{"f1": {"$eq": "v1"}}, {"f2": {"$gte": 0}}]}
No filter: {}
```

*User Message:*

```
[QUESTION]
{question}
[/QUESTION]

[INDEX METADATA]
{index_metadata}
[/INDEX METADATA]
```

**Variables:**

`question`:

* Description: User retrieval question
* Default: (empty)
* Required: True
* User Input: True

`index_metadata`:

* Description: Index metadata schema
* Default: (empty)

### Metadata Extractor

A metadata extractor prompt instructs the LLM to identify and extract structured metadata from unstructured text, such as dates, names, locations, categories, or any predefined metadata fields.

#### Purpose

Use metadata extractor prompts to automatically tag content, populate database fields from text, extract key information for indexing, and standardize data from various sources into consistent metadata formats.

#### Example

The following example demonstrates the default Metadata Extraction template.

**Prompt:**

*System Message:*

```
You are a metadata extraction engine. Given a text block (from OCR output) and a target schema, extract structured metadata as strict JSON. The output will be used for metadata filtering in a vector database, so precision and type correctness are critical.

Instructions:
1. Schema compliance: Output JSON keys must exactly match the provided schema keys
2. Type mapping: Cast each extracted value to its declared type:
   - date: ISO 8601 format (YYYY-MM-DD)
   - keyword: exact string, preserve original casing
   - text: free-form string
   - integer: whole number, strip commas/currency
   - float/double: numeric with decimal precision
   - boolean: resolve to true or false
3. Missing values: If a schema key has no matching value, omit the key entirely
4. Ambiguity handling: Select from primary/header content over remarks/footnotes
5. Source priority: Extract from main body first

Output: ONLY the JSON object. No markdown fences, no explanation.
```

*User Message:*

```
[SCHEMA]
{entities}
[/SCHEMA]

[TEXT]
{text_data}
[/TEXT]
```

**Variables:**

`entities`:

* Description: Target metadata schema
* Default: (empty)

`text_data`:

* Description: OCR / source text for extraction
* Default: (empty)

**Example Input:**

```
Schema:
{
  "invoice_number": "keyword",
  "invoice_date": "date",
  "vendor_name": "keyword",
  "amount": "float",
  "status": "keyword"
}

Text:
INVOICE
Invoice #: INV-2024-001234
Date: January 15, 2024
Vendor: Acme Corporation
Total Amount: $9,222.50
Status: PAID
```

**Example Output:**

```json
{
  "invoice_number": "INV-2024-001234",
  "invoice_date": "2024-01-15",
  "vendor_name": "Acme Corporation",
  "amount": 9222.50,
  "status": "PAID"
}
```

### Multi-Query Rewrite

A multi-query rewrite prompt instructs the LLM to generate multiple variations of a search query to improve information retrieval and capture different phrasings of the same intent.

Use multi-query rewrite prompts to enhance search recall, handle ambiguous queries, generate synonymous phrasings, and improve retrieval from vector databases or search engines by querying multiple perspectives of the same question.

#### Example

The following example shows the default Multi-Query Rewrite template.

**Prompt:**

*System Message:*

```
You are a query rewriter for a vector database that uses semantic similarity search. Your job is to transform a user's question into one or more focused search queries that will retrieve the most relevant chunks from the knowledgebase.

Guidelines:
1. Simple questions: If the question targets a single topic, rewrite it as one clear, specific query
2. Multi-topic questions: If the question covers multiple distinct topics or asks for comparisons, decompose it into separate queries - one per topic
3. Complex/multi-step questions: Generate a chain of simpler queries that together cover the full question
4. Keyword precision: Preserve domain-specific terms, model numbers, product names exactly as stated
5. Conversation-aware: If conversation history is provided, resolve pronouns into explicit terms
6. Minimize query count: Generate the fewest queries needed (typically 1-4)
```

*User Message:*

```
{question}
```

**Variables:**

`question`:

* Description: The user's original question to rewrite into search queries
* Default: (empty)

**Example Input:**

```
How does the AWS Lambda pricing model work and what are the cost optimization strategies?
```

**Example Output:**

```
AWS Lambda pricing structure and billing model
Cost optimization techniques for AWS Lambda functions
AWS Lambda pricing per invocation and memory allocation
```

### Query Expansion

A query expansion prompt instructs the LLM to enhance search queries by generating a hypothetical passage that would contain the answer, improving search coverage and recall.

Use query expansion prompts to broaden search scope through hypothetical document generation, compensate for vocabulary mismatches, and improve retrieval results from search systems or databases by creating a rich query context.

#### Example

The following example demonstrates the default Query Expansion template.

**Prompt:**

*System Message:*

```
Write a short factual passage (3-5 sentences) that would contain the information needed to answer the given question. This passage should read like an excerpt from a reference document, technical manual, or knowledgebase article - not like a direct answer to the question.

Do not address the user. Do not answer the question. Do not include phrases like "the answer is" or "in summary." Write the passage as if it already exists in a source document and someone could find the answer by reading it.

Preserve any domain-specific terms, model numbers, product names, or technical vocabulary from the question exactly as stated.
```

*User Message:*

```
{question}
```

**Variables:**

`question`:

* Description: The question to generate a hypothetical answer passage for
* Default: (empty)

**Example Input:**

```
What are the benefits of using Docker containers?
```

**Example Output:**

```
Docker containers provide several key advantages in modern software development and deployment. Containers offer consistent environments across development, testing, and production, eliminating "works on my machine" issues. They enable faster deployment times and efficient resource utilization by sharing the host operating system kernel. Docker's lightweight architecture allows multiple containers to run on a single host with minimal overhead, while built-in version control and isolation ensure application dependencies don't conflict.
```

### Question Generator (Follow-up Questions)

A question generator prompt instructs the LLM to create relevant follow-up questions based on a given question-answer pair to encourage deeper exploration of the topic.

Use question generator prompts to enhance conversational AI systems, create interactive learning experiences, guide users toward relevant information, and prompt further exploration of topics.

#### Example

The following example shows the default Follow-Up Questions (Basic) template.

**Prompt:**

*System Message:*

```
You generate exactly 3 follow-up questions based on a reference question-answer pair. These questions will be shown to users to encourage deeper exploration of the topic.

Guidelines:
1. Each question must directly expand on, clarify, or explore a related angle of the reference Q&A. Do not repeat or rephrase the original question.
2. Questions must be self-contained - a reader should understand them without needing to see the reference Q&A.
3. Keep questions diverse. Each should target a different aspect and use a different question type: process/how-to, comparison, clarification, or contextual/when-would-this-apply.
4. Use the reference answer as a basis - identify gaps, next steps, edge cases, or related subtopics worth asking about.
5. One question per slot. No compound questions joined by "and" or "or".

If [MODEL ANSWER] (after stripping leading whitespace) begins with the literal string "Search Results:" (case-insensitive), output exactly this single token and nothing else:
<<NO_OUTPUT>>

Otherwise, output exactly three lines and nothing else:
Question-1: <question text>
Question-2: <question text>
Question-3: <question text>

No preamble, explanation, or reasoning.
```

*User Message:*

```
User's Question:
{question}

Chatbot Answer:
{answer}
```

**Variables:**

`question`:

* Description: User question
* Default: (empty)

`answer`:

* Description: Chatbot answer
* Default: (empty)

**Example Input:**

```
User's Question:
What is machine learning?

Chatbot Answer:
Machine learning is a subset of artificial intelligence that enables computers to learn from data and improve their performance on tasks without being explicitly programmed. It uses algorithms to identify patterns in data and make predictions or decisions based on those patterns. Common applications include image recognition, natural language processing, and recommendation systems.
```

**Example Output:**

```
Question-1: How do machine learning algorithms identify patterns in data?
Question-2: What's the difference between supervised and unsupervised machine learning?
Question-3: When should I use machine learning versus traditional programming approaches?
```
