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

Search documentation

Type to search this documentation.

On this pageOverview

Collection configuration

The Query Agent, in Ask Mode or Search Mode, has the option to search one or more of any collections that are provided to it.

These collections can either be specified by a string (the name of the collection) or via a more advanced configuration.

To give your collections without any advanced configuration, you can just pass strings of the collection names to the Query Agent.

Python
from weaviate.agents.query import QueryAgent

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

const qaSimple = new QueryAgent(client, {
    collections: ['ECommerce', 'FinancialContracts'],
});

You can provide a more detailed configuration on how you want the agents to interact with your collections to define the tenant names (for a multi-tenant collection), target vector(s), property names and any additional filters.

Python
from weaviate.agents.classes import QueryAgentCollectionConfig

qa = QueryAgent(
    client=client,
    collections=[
        # Use QueryAgentCollectionConfig class to provide further collection configuration
        QueryAgentCollectionConfig(
            name="ECommerce", 
            target_vector=[
                "name_description_brand_vector"
            ], 
            view_properties=[
                "name",
                "description",
                "category",
                "brand",
            ],  
        ),
        QueryAgentCollectionConfig(
            name="FinancialContracts"
        ),
    ],
)

The QueryAgentCollectionConfig class accepts the following arguments:

FieldTypeDescription
namestrThe name of the collection to query. Required.
target_vectorstr | list[str] | NoneAn optional list of target vector name(s) for collections with named vectors. Required when the collection has more than one named vector.
view_propertieslist[str] | NoneAn optional list of property names that the agent is allowed to view when reasoning about and querying the collection. If omitted, the agent can view all properties.
tenantstr | NoneAn optional tenant name for collections with multi-tenancy enabled.
additional_filtersFilter | NoneAn optional Filter object that is always combined with any agent-generated filters when querying this collection. See the page on additional filters for more detail.
TypeScript
const qa = new QueryAgent(client, {
    collections: [
        // Provide an object to specify further collection configuration
        {
            name: 'ECommerce',
            targetVector: [
                'name_description_brand_vector'
            ],
            viewProperties: [
                'name',
                'description',
                'category',
                'brand',
            ],
        },
        {
            name: 'FinancialContracts'
        },
    ],
});

A collection configuration object accepts the following fields:

FieldTypeDescription
namestringThe name of the collection to query. Required.
targetVectorstring | string[]An optional list of target vector name(s) for collections with named vectors. Required when the collection has more than one named vector.
viewPropertiesstring[]An optional list of property names that the agent is allowed to view when reasoning about and querying the collection. If omitted, the agent can view all properties.
tenantstringAn optional tenant name for collections with multi-tenancy enabled.
additionalFiltersFilterValueAn optional Filter object that is always combined with any agent-generated filters when querying this collection. See the page on additional filters for more detail.

The examples above show configuring collections at instantiation of the Query Agent. This defines the default collections which will be used automatically when running Ask Mode or Search Mode.

You can instead or additionally provide collection information at runtime of the Query Agent, which will override any default collections set at instantiation.

Python
response = qa.ask(
    "Recommend some shoes below $60.",
    collections=[
        QueryAgentCollectionConfig(
            name="ECommerce",
            target_vector=[
                "name_description_brand_vector"
            ],
        ),
    ],
)
JavaScript/TypeScript
const response = await qa.ask(
    "Recommend some shoes below $60.", {
    collections: [
        {
            name: 'ECommerce',
            targetVector: [
                'name_description_brand_vector'
            ],
        }
    ],
});

Similarly to above, this collection can also be either string(s) of the collection name(s), or a set of configurations.

This is possible in both Ask and Search Mode.

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