1"use strict";(globalThis.webpackChunkmy_website=globalThis.webpackChunkmy_website||[]).push([[3187],{1352(e,t,n){n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>l,default:()=>g,frontMatter:()=>r,metadata:()=>a,toc:()=>h});var a=n(91089),s=n(74848),i=n(28453),o=n(15768);const r={title:"Introducing the Weaviate Query Agent",slug:"query-agent",authors:["charles-pierse","tuana","alvin"],date:new Date("2025-03-05T00:00:00.000Z"),tags:["concepts","agents","release"],image:"./img/hero.png",description:"Learn about the Query Agent, our new agentic search service that redefines how you interact with Weaviate\u2019s database!"},l=void 0,c={image:n(37100).A,authorsImageUrls:[void 0,void 0,void 0]},h=[{value:"What is the Weaviate Query Agent",id:"what-is-the-weaviate-query-agent",level:2},{value:"Routing to Search vs Aggregations",id:"routing-to-search-vs-aggregations",level:3},{value:"Creating Query Agents",id:"creating-query-agents",level:2},{value:"Giving Access to Collections",id:"giving-access-to-collections",level:3},{value:"Running the Query Agent",id:"running-the-query-agent",level:3},{value:"Running a Follow Up Query",id:"running-a-follow-up-query",level:3},{value:"Modifying the System Prompt",id:"modifying-the-system-prompt",level:3},{value:"Summary",id:"summary",level:2},...o.RM];function d(e){const t={a:"a",admonition:"admonition",code:"code",em:"em",h2:"h2",h3:"h3",img:"img",li:"li",mdxAdmonitionTitle:"mdxAdmonitionTitle",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{alt:"Introducing the Weaviate Query Agent",src:n(41417).A+"",width:"1800",height:"945"})}),"\n",(0,s.jsxs)(t.p,{children:["We\u2019re incredibly excited to announce that we\u2019ve released a brand new service for our ",(0,s.jsx)(t.a,{href:"https://weaviate.io/deployment/serverless",children:"Serverless Weaviate Cloud"})," users (including free Sandbox users) to preview, currently in Alpha: the ",(0,s.jsx)(t.em,{children:(0,s.jsx)(t.strong,{children:"Weaviate Query Agent!"})})," Ready to use now, this new feature provides a simple interface for users to ask complex multi-stage questions about your data in Weaviate, using powerful foundation LLMs. In this blog, learn more about what the Weaviate Query Agent is, and discover how you can build your own!"]}),"\n",(0,s.jsx)(t.p,{children:"Let\u2019s get started."}),"\n",(0,s.jsxs)(t.admonition,{type:"note",children:[(0,s.jsx)(t.mdxAdmonitionTitle,{}),(0,s.jsxs)(t.p,{children:["This blog comes with an accompanying ",(0,s.jsx)(t.a,{href:"https://github.com/weaviate/recipes/tree/main/weaviate-services/agents/query-agent-get-started.ipynb",children:"recipe"})," for those of you who\u2019d like to get started."]})]}),"\n",(0,s.jsx)(t.h2,{id:"what-is-the-weaviate-query-agent",children:"What is the Weaviate Query Agent"}),"\n",(0,s.jsx)(t.p,{children:"AI Agents are semi- or fully- autonomous systems that make use of LLMs as the brain of the operation. This allows you to build applications that are able to handle complex user queries that may need to access multiple data sources. And, over the past few years we\u2019ve started to build such applications thanks to more and more powerful LLMs capable of function calling, frameworks that simplify the development process and more."}),"\n",(0,s.jsxs)(t.admonition,{type:"note",children:[(0,s.jsx)(t.mdxAdmonitionTitle,{}),(0,s.jsxs)(t.p,{children:["To learn more about what AI Agents are, read our blog ",(0,s.jsx)(t.a,{href:"https://weaviate.io/blog/ai-agents",children:"\u201dAgents Simplified: What we mean in the context of AI\u201d"}),"."]})]}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"With the Query Agent, we aim to provide an agent that is inherently capable of handling complex queries over multiple Weaviate collections."})," The agent understands the structure of all of your collections, so knows when to run searches, aggregations or even both at the same time for you."]}),"\n",(0,s.jsx)(t.p,{children:"Often, AI agents are described as LLMs that have access to various tools (adding more to its capabilities), which are also able to make a plan, and reason about the response."}),"\n",(0,s.jsx)(t.p,{children:"Our Query Agent is an AI agent that is provided access to multiple Weaviate collections within a cluster. Depending on the user\u2019s query, it will be able to decide which collection or collections to perform searches on. So, you can think of the Weaviate Query Agent as an AI agent that has tools in the form of Weaviate Collections."}),"\n",(0,s.jsx)(t.p,{children:"In addition to access to multiple collections, the Weaviate Query Agent also has access to two internal agentic search workflows:"}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsxs)(t.li,{children:["Regular ",(0,s.jsx)(t.a,{href:"/blog/vector-search-explained",children:"semantic search"})," with optional filters"]}),"\n",(0,s.jsx)(t.li,{children:"Aggregations"}),"\n"]}),"\n",(0,s.jsx)(t.p,{children:"In essence, we\u2019ve released a multi-agent system that can route queries to one or the other and synthesise a final answer for the user."}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{alt:"Query Agent",src:n(89801).A+"",width:"1720",height:"790"})}),"\n",(0,s.jsx)(t.h3,{id:"routing-to-search-vs-aggregations",children:"Routing to Search vs Aggregations"}),"\n",(0,s.jsxs)(t.p,{children:["Not all queries are the same. While some may require us to do semantic search using embeddings over a dataset, other queries may require us to make ",(0,s.jsx)(t.a,{href:"https://docs.weaviate.io/weaviate/api/gra
1phql/aggregate",children:"aggregations"})," (such as counting objects, calculating the average value of a property and so on). We can demonstrate the difference with a simple example. Think of two queries assuming we have a dataset containing the ",(0,s.jsx)(t.a,{href:"https://weaviate.io/blog",children:"Weaviate Blog"}),":"]}),"\n",(0,s.jsxs)(t.ol,{children:["\n",(0,s.jsx)(t.li,{children:"What are the components of an AI agent discussed in the \u201cAgents Simplified\u201d blog?"}),"\n",(0,s.jsx)(t.li,{children:"How many blog posts has Leonie published?"}),"\n"]}),"\n",(0,s.jsx)(t.p,{children:"For question 1, we may need to filter to the \u201cAgents Simplified\u201d blog and search for \u201cAI agent components\u201d. Whereas for question 2, the task is closer to a counting task. We have to count how many blogs appear for the author Leonie."}),"\n",(0,s.jsxs)(t.p,{children:["Weaviate is a ",(0,s.jsx)(t.a,{href:"/blog/what-is-a-vector-database",children:"vector database"}),", meaning for case 1, we have ",(0,s.jsx)(t.a,{href:"/blog/vector-embeddings-explained",children:"embeddings"})," stored on which we can perform regular semantic search on. However, for case 2, we need to create an ",(0,s.jsx)(t.a,{href:"https://docs.weaviate.io/weaviate/api/graphql/aggregate",children:"Aggregation Query"}),"."]}),"\n",(0,s.jsx)(t.p,{children:"The good news is, the Weaviate Query Agent is capable of handling both. Depending on the user query, the agent will generate a search query, or an aggregation query, or in some cases both."}),"\n",(0,s.jsx)(t.h2,{id:"creating-query-agents",children:"Creating Query Agents"}),"\n",(0,s.jsxs)(t.admonition,{type:"note",children:[(0,s.jsx)(t.mdxAdmonitionTitle,{}),(0,s.jsxs)(t.p,{children:["\ud83d\udc69\u200d\ud83c\udf73 For this announcement, we\u2019ve also released an accompanying ",(0,s.jsx)(t.a,{href:"https://colab.research.google.com/github/weaviate/recipes/blob/main/weaviate-services/agents/query-agent-get-started.ipynb",children:"recipe"})," to help you get started. Read on for key points on how to use the Query Agent, or alternatively follow along with the recipe itself. For questions or feedback, you can ",(0,s.jsx)(t.a,{href:"https://forum.weaviate.io/c/agents/10",children:"join the \u2018Agents\u2019 topic in the Weaviate Forum"}),"."]})]}),"\n",(0,s.jsxs)(t.p,{children:["The ",(0,s.jsx)(t.code,{children:"QueryAgent"})," and all upcoming agents we will release for preview will be available via the Weaviate Python Client:"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-bash",children:"pip install weaviate-client[agents] \n"})}),"\n",(0,s.jsxs)(t.p,{children:["To initialize a new ",(0,s.jsx)(t.code,{children:"QueryAgent"}),", we have to take a few simple steps:"]}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsxs)(t.li,{children:["We give it access to our serverless cluster via ",(0,s.jsx)(t.code,{children:"client"}),"."]}),"\n",(0,s.jsxs)(t.li,{children:["We provide it with a list of ",(0,s.jsx)(t.code,{children:"collections"})," which we grant it access to perform searches on."]}),"\n",(0,s.jsxs)(t.li,{children:["Optionally, we may also provide our own custom ",(0,s.jsx)(t.code,{children:"system_prompt"})," to provide it instructions on how to generate responses."]}),"\n"]}),"\n",(0,s.jsxs)(t.admonition,{type:"note",children:[(0,s.jsx)(t.mdxAdmonitionTitle,{}),(0,s.jsxs)(t.p,{children:["For the time being, the ",(0,s.jsx)(t.code,{children:"QueryAgent"})," is freely available to all Weaviate Cloud Serverless and Sandbox users, however there is a rate limit of 100 queries per day on an organization basis."]})]}),"\n",(0,s.jsx)(t.h3,{id:"giving-access-to-collections",children:"Giving Access to Collections"}),"\n",(0,s.jsx)(t.p,{children:"For this intro, we\u2019ve created a recipe which uses 2 collections (and we\u2019ve added an extra 2 for you to optionally play around in the recipe)."}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsx)(t.li,{children:"E-commerce: A collection that has a list of clothes, their brands and prices."}),"\n",(0,s.jsx)(t.li,{children:"Brands: A collection that lists more information on brands, their country of origin, parent brands and so on."}),"\n"]}),"\n",(0,s.jsx)(t.p,{children:"We\u2019ll use these datasets to create an \u2018e-commerce assistant\u2019 agent"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-python",children:'from weaviate.agents.query import QueryAgent\n\nagent = QueryAgent(client=your_client, collections=["Ecommerce", "Brands"])\n'})}),"\n",(0,s.jsx)(t.h3,{id:"running-the-query-agent",children:"Running the Query Agent"}),"\n",(0,s.jsxs)(t.p,{children:["Once initialized, the ",(0,s.jsx)(t.code,{children:"QueryAgent"})," can accept user queries. The response is then returned within a ",(0,s.jsx)(t.code,{children:"QueryAgentResponse"})," object which includes information on what searches or aggregations were performed, which collections were used, and even whether the agent has concluded if the answer is complete or not."]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-python",children:'response = agent.run("I like the vintage clothes, can you list me some options that are less than $200?")\n'})}),"\n",(0,s.jsxs)(t.p,{children:["The example above may return the following ",(0,s.jsx)(t.code,{children:"QueryAgentResponse"}),":"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-bash",children:"original_query='I like the vintage clothes, can you list me some options that are less than $200?' \ncollection_names=['Ecommerce'] \nsearches=[[QueryResultWithCollection(queries=['vintage clothes'], filters=[[IntegerPropertyFilter(property_name='price', operator=<ComparisonOperator.LESS_THAN: '<'>, value=200.0)]], filter_operators='AND', collection='Ecommerce')]] \naggregations=[]\nsources= [Source(object_id='5e9c5298-5b3a-4d80-b226-64b2ff6689b7', collection='Ecommerce'), Source(object_id='48896222-d098....', collection='Ecommerce')...]\nusage=Usage(requests=3, request_tokens=7689, response_tokens=1488, total_tokens=9177, details=None) \ntotal_time=13.9723\naggregation_answer=None \nhas_aggregation_answer=False \nhas_search_answer=True \nis_partial_answer=False \nmissing_information=[] \nfinal_answer=\"Here are some vintage-style clothing options under $200 that you might like:\\\\n\\\\n1. **Vintage Philosopher Midi Dress** -...\"\n"})}),"\n",(0,s.jsxs)(t.p,{children:["The ",(0,s.jsx)(t.code,{children:"QueryAgentResponse"})," aims to be as interpretable as possible. We include the ",(0,s.jsx)(t.code,{children:"searches"})," and ",(0,s.jsx)(t.code,{children:"aggregations"})," so that you can understand the actions carried out. You can check ",(0,s.jsx)(t.code,{children:"sources"})," to see which exact objects were used to generate answers from. We also include ",(0,s.jsx)(t.code,{children:"missing_information"})," to allow the agent to inform you when it\u2019s incapable of answering the original query."]}),"\n",(0,s.jsxs)(t.p,{children:["For example, with the response above we can see that the ",(0,s.jsx)(t.code,{children:"QueryAgent"})," has performed a search on the Ecommerce collection. Not only that, but we\u2019re also able to see what the search is, as well as what filters were used:"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-bash",children:"searches=[[QueryResultWithCollection(queries=['vintage clothes'], filters=[[IntegerPropertyFilter(property_name='price', operator=<ComparisonOperator.LESS_THAN: '<'>, value=200.0)]], filter_operators='AND', collection='Ecommerce')]] \n"})}),"\n",(0,s.jsx)(t.h3,{id:"running-a-follow-up-query",children:"Running a Follow Up Query"}),"\n",(0,s.jsxs)(t.p,{children:["Optionally, you may also chose to provide the response from the previous interaction as context to the next one. This way, you\u2019re always able to ask follow up questions and the ",(0,s.jsx)(t.code,{children:"QueryAgent"})," is able to infer what some of the missing information might be. For example, as a follow up to the previous question we may run the code below:"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-python",children:'new_response = agent.run("What about some nice shoes, same budget as before?", context=response)\n'})}),"\n",(0,s.jsxs)(t.p,{children:["In this case, you can observe that the ",(0,s.jsx)(t.code,{children:"new_response"})," includes the following ",(0,s.jsx)(t.code,{children:"searches"})," and ",(0,s.jsx)(t.code,{children:"final_answer"}),". Notice that although we didn\u2019t provide the budget in the query, the agent was able to infer that we still want to adhere to the budget of $200."]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-bash",children:"searches=[[QueryResultWithCollection(queries=['nice shoes'], filters=[[IntegerPropertyFilter(property_name='price', operator=<ComparisonOperator.LESS_THAN: '<'>, value=200.0)]], filter_operators='AND', collection='Ecommerce')]]\nfinal_answer=\"Here are some nice shoe options under $200 - 1. **Parchment Boots by Nova Nest** - $145 ...\"\n"})}),"\n",(0,s.jsx)(t.h3,{id:"modifying-the-system-prompt",children:"Modifying the System Prompt"}),"\n",(0,s.jsxs)(t.p,{children:["In addition to deciding which of your collections the ",(0,s.jsx)(t.code,{children:"QueryAgent"})," has access to, you may also chose to provide a custom ",(0,s.jsx)(t.code,{children:"system_prompt"}),". This allows you to provide the agent with instructions on how it should behave. For example, below we provide a system prompt which instructs the agent to always respond in the users language:"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-python",children:'multi_lingual_agent = QueryAgent(\n client=client, collections=["Ecommerce", "Brands"],\n system_prompt="You are a helpful assistant that always generated the final response in the users language."\n " You may have to translate the user query to perform searches. But you must always respond to the user in their own language."\n
1)\n'})}),"\n",(0,s.jsx)(t.h2,{id:"summary",children:"Summary"}),"\n",(0,s.jsx)(t.p,{children:"The Weaviate Query Agent represents a significant step forward in making vector databases more accessible and powerful. By combining the capabilities of LLMs with Weaviate's own search and aggregation features, we've created a tool that can handle complex queries across multiple collections while maintaining context and supporting multiple languages. The resulting agent can be used on its own, as well as within a larger agentic or multi-agent application."}),"\n",(0,s.jsx)(t.p,{children:"Whether you're building applications that require semantic search, complex aggregations, or both, the Query Agent simplifies the development process while providing the flexibility to customize its behavior through system prompts. As we continue to develop and enhance this feature, we look forward to seeing how our community will leverage it to build even more powerful AI-driven applications."}),"\n",(0,s.jsxs)(t.p,{children:["Ready to get started? Check out our ",(0,s.jsx)(t.a,{href:"https://colab.research.google.com/github/weaviate/recipes/blob/main/weaviate-services/agents/query-agent-get-started.ipynb",children:"recipe"}),", join the discussion in our forum, and start building with the Weaviate Query Agent today!"]}),"\n","\n",(0,s.jsx)(o.Ay,{})]})}function g(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},37100(e,t,n){n.d(t,{A:()=>a});const a=n.p+"assets/images/hero-a5f7ef21d917363530fc75329b0091c9.png"},41417(e,t,n){n.d(t,{A:()=>a});const a=n.p+"assets/images/hero-a5f7ef21d917363530fc75329b0091c9.png"},89801(e,t,n){n.d(t,{A:()=>a});const a=n.p+"assets/images/query-agent-971a9c529e85f62b0b5433341be66272.png"},91089(e){e.exports=JSON.parse('{"permalink":"/blog/query-agent","editUrl":"https://github.com/weaviate/weaviate-io/tree/main/blog/2025-03-15-query-agent/index.mdx","source":"@site/blog/2025-03-15-query-agent/index.mdx","title":"Introducing the Weaviate Query Agent","description":"Learn about the Query Agent, our new agentic search service that redefines how you interact with Weaviate\u2019s database!","date":"2025-03-05T00:00:00.000Z","tags":[{"inline":true,"label":"concepts","permalink":"/blog/tags/concepts"},{"inline":true,"label":"agents","permalink":"/blog/tags/agents"},{"inline":true,"label":"release","permalink":"/blog/tags/release"}],"readingTime":8.24,"hasTruncateMarker":false,"authors":[{"name":"Charles Pierse","title":"Head of Weaviate Labs","url":"https://github.com/cdpierse","imageURL":"/img/people/icon/charles-pierse.jpg","key":"charles-pierse","page":null},{"name":"Tuana \xc7elik","title":"Developer Relations Engineer","url":"https://linkedin.com/in/tuanacelik","imageURL":"/img/people/icon/tuana.jpg","key":"tuana","page":null},{"name":"Alvin Richards","title":"VP of Product","url":"mailto:[email protected]","imageURL":"/img/people/icon/alvin.jpg","key":"alvin","page":null}],"frontMatter":{"title":"Introducing the Weaviate Query Agent","slug":"query-agent","authors":["charles-pierse","tuana","alvin"],"date":"2025-03-05T00:00:00.000Z","tags":["concepts","agents","release"],"image":"./img/hero.png","description":"Learn about the Query Agent, our new agentic search service that redefines how you interact with Weaviate\u2019s database!"},"unlisted":false,"prevItem":{"title":"What Are Agentic Workflows? Patterns, Memory, Use Cases, and Examples","permalink":"/blog/what-are-agentic-workflows"},"nextItem":{"title":"Welcome to the Next Era of Data and AI: Meet Weaviate Agents","permalink":"/blog/weaviate-agents"}}')}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.