Skip to main content
Weaviate Docs (migrated from docs.weaviate.io) Docs

Search documentation

Type to search this documentation.

On this pageOverview

Customizing the system prompt

You can provide a custom system prompt to guide the Query Agent's behavior, by passing it as part of the instantiation.

Python
from weaviate.agents.query import QueryAgent
from weaviate.agents.classes import QueryAgentCollectionConfig

# Define a custom system prompt to guide the agent's behavior
system_prompt = """
You are a helpful assistant that can answer questions about the products and users in the database.
When you write your response use standard markdown formatting for lists, tables, and other structures.
Emphasize key insights and provide actionable recommendations when relevant.
"""

qa = QueryAgent(
    client=client,
    collections=[
        QueryAgentCollectionConfig(
            name="ECommerce",
            target_vector=["name_description_brand_vector"],
        )
    ],
    system_prompt=system_prompt,
JavaScript/TypeScript
import { QueryAgent } from 'weaviate-agents';

// Define a custom system prompt to guide the agent's behavior
const systemPrompt = `
You are a helpful assistant that can answer questions about the products and users in the database.
When you write your response use standard markdown formatting for lists, tables, and other structures.
Emphasize key insights and provide actionable recommendations when relevant.
`;

const qa = new QueryAgent(client, {
    systemPrompt: systemPrompt,
    collections: [
        {
            name: 'ECommerce',
            targetVector: [
                'name_description_brand_vector'
            ],
        },
    ],
});

Then any run using the Query Agent will use this new set of instructions.

A custom system prompt is supported in both Ask Mode and Search Mode.

The system prompt is used in two places:

  1. During the query/aggregation writing - the system prompt is passed in addition to a general set of instructions to guide the construction of any queries.
  2. During the writing of the final answer - the system prompt overrides a general prompt.

Therefore it is most useful to use the system prompt in one of two ways:

  • Instructions specific for your data, so that the query writing agent has additional information to write queries more effectively.
  • A guide for style and tone in writing the final answer, such as specific formatting instructions.

Have a question or feedback? Here's how to reach us.

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu