Query Agent As A Tool
gemini-cookbookgemini-apiexamplesgeminiweaviate
Export
Copyright 2025 Google LLC.
[ ]
This notebook will show you how to define the Weaviate Query Agent as a tool through the Gemini API.
Requirements
- Weaviate Cloud instance (WCD): The Weaviate Query Agent is only accessible through WCD at the moment. You can create a serverless cluster or a free 14-day sandbox here.
- Have a GCP project and Gemini API key (generate one here)
- Install the Google Gen AI SDK with
pip install --upgrade --quiet google-genai - Install the Weaviate Python client and the agents sub-package with
pip install weaviate-client[agents] - You'll need a Weaviate cluster with data. If you don't have one, check out this notebook to import the Weaviate Blogs.
Connect with us and let us know if you have any questions!
Erika's accounts:
Patrick's accounts:
Connor's accounts:
Install libraries
[ ]
Import libraries and keys
[ ]
Set you API keys and Weaviate URL
[ ]
Create API client
[ ]
Define Query Agent function
[ ]
Configure Tool
[ ]
Query Time
[ ]
/usr/local/lib/python3.11/site-packages/pydantic/main.py:426: UserWarning: Pydantic serializer warnings: Expected `enum` but got `str` with value `'STRING'` - serialized value may not be as expected return self.__pydantic_serializer__.to_python(
To deploy Weaviate with Docker, you need to:
1. Install Docker and Docker Compose.
2. Obtain the Weaviate Docker image using:
```bash
docker pull cr.weaviate.io/semitechnologies/weaviate:latest
```
3. Prepare a `docker-compose.yml` file, which you can generate using the Weaviate configuration tool or example files from the documentation.
4. Start Weaviate using either:
* Directly with Docker:
```bash
docker run -p 8080:8080 -p 50051:50051 cr.weaviate.io/semitechnologies/weaviate:latest
```
* Using Docker Compose:
```bash
docker-compose up -d
```
5. Access Weaviate at `http://localhost:8080` and configure as needed.
6. Check if Weaviate is ready by hitting the readiness endpoint:
```bash
curl localhost:8080/v1/.well-known/ready
```