Skip to main content

Weaviate Query Agent: Overview

Technical Preview

This Weaviate Agent is in technical preview. This Weaviate Agent is in technical preview.

Sign up here for notifications on Weaviate Agents, or visit this page to see the latest updates and provide feedback.

The Weaviate Query Agent is a pre-built agentic service designed to answer natural language queries based on the data stored in Weaviate Cloud.

The user simply provides a prompt/question in natural language, and the Query Agent takes care of all intervening steps to provide an answer.

Weaviate Query Agent from a user perspective Weaviate Query Agent from a user perspective

Changelog and feedback

The official changelog for Weaviate Agents can be found here. If you have feedback, such as feature requests, bug reports or questions, please submit them here, where you will be able to see the status of your feedback and vote on others' feedback.

Architecture

The Query Agent is provided as a service on Weaviate Cloud.

When a user provides a prompt/query, the query agent analyses it and any other known context to autonomously carry out the searches itself.

Query Agent context

The Query agent analyses collection and property descriptions to better understand how to construct relevant queries.

The context may also include previous conversation history, and any other relevant information.

Query Agent: visualized workflow

Weaviate Query Agent at a high level Weaviate Query Agent at a high level

The Query Agent follows these high-level steps:

  • Use appropriate generative models (e.g. large language models) to analyze the task & the required queries. Determine the exact queries to perform. (Steps 1 & 2)
  • Send queries to Weaviate. Weaviate vectorizes the queries as needed using the specified vectorizer integration. (Steps 3-5)
  • Receive the results from Weaviate, and use appropriate generative models to generate the final respond to the user prompt/query. (Step 6)

Then, the Query Agent returns the answer to the user, as well as intermediate outputs, such as the underlying search results from Weaviate.

Note that the term Query Agent refers to the entire system. The Query Agent may comprise multiple subsystems, such as microservices and/or agents under the hood, each responsible for a specific task.

Weaviate Query Agent comprises multiple agents Weaviate Query Agent comprises multiple agents

Basic Usage

Here is an overview of how to use the this Weaviate Agent. For more detailed information, refer to the Usage page.

Prerequisites

This Agent is available exclusively for use with a Weaviate Cloud instance, and a supported version of the Weaviate client library.

Example Usage

Pass an instance of the Weaviate client to the Query Agent, and the Query Agent will extract the necessary information from the client to perform the query.

import os
import weaviate
from weaviate.classes.init import Auth
from weaviate.agents.query import QueryAgent

headers = {
# Provide your required API key(s), e.g. Cohere, OpenAI, etc. for the configured vectorizer(s)
"X-INFERENCE-PROVIDER-API-KEY": os.environ.get("YOUR_INFERENCE_PROVIDER_KEY", ""),
}

client = weaviate.connect_to_weaviate_cloud(
cluster_url=os.environ.get("WCD_URL"),
auth_credentials=Auth.api_key(os.environ.get("WCD_API_KEY")),
headers=headers,
)

# Instantiate a new agent object, and specify the collections to query
qa = QueryAgent(
client=client, collections=["ecommerce", "financial_contracts", "weather"]
)

Then, provide a natural language query input. The Query Agent will process the query, perform the necessary searches in Weaviate, and return the answer.

# Perform a query
response = qa.run(
"I like vintage clothes and and nice shoes. Recommend some of each below $60."
)

# Print the response
response.display()

The Query Agent can even handle follow-up queries, using the previous response as additional context.

# Perform a follow-up query
following_response = qa.run(
"I like the vintage clothes options, can you do the same again but above $200?",
context=response,
)

# Print the response
response.display()

Further Documentation

For more detailed information on how to use this Agent, refer to the Usage page.

Questions and feedback

Changelog and feedback

The official changelog for Weaviate Agents can be found here. If you have feedback, such as feature requests, bug reports or questions, please submit them here, where you will be able to see the status of your feedback and vote on others' feedback.

If you have any questions or feedback, let us know in the user forum.