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.
Simple configuration
To give your collections without any advanced configuration, you can just pass strings of the collection names to the Query Agent.
from weaviate.agents.query import QueryAgent
qa = QueryAgent(
client=client,
collections=["ECommerce", "FinancialContracts"],
)
Advanced configuration
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.
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:
| Field | Type | Description |
|---|---|---|
name | str | The name of the collection to query. Required. |
target_vector | str | list[str] | None | An optional list of target vector name(s) for collections with named vectors. Required when the collection has more than one named vector. |
view_properties | list[str] | None | 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. |
tenant | str | None | An optional tenant name for collections with multi-tenancy enabled. |
additional_filters | Filter | None | An 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. |
Runtime configuration
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.
response = qa.ask(
"Recommend some shoes below $60.",
collections=[
QueryAgentCollectionConfig(
name="ECommerce",
target_vector=[
"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.
Questions and feedback
If you have any questions or feedback, let us know in the user forum.
