Weaviate Python Client
repository·main·Indexed 42 days ago
https://github.com/weaviate/weaviate-python-clientA client library for interacting with Weaviate vector databases. The current major version is v4 (v3 is deprecated). It features a type-safe API via the weaviate.classes and weaviate.collections modules for managing schemas, performing batch operations, and executing vector, hybrid, and keyword searches. Optional integration with Weaviate Agents provides pre-built services like QueryAgent, TransformationAgent, and PersonalizationAgent for LLM tasks via Weaviate Cloud (WCD).
What's inside Weaviate Python Client
- The Weaviate Python client is a native Python library designed for easy interaction with a Weaviate vector database instance. It is compatible with Python 3.9 and higher.
Explore the weaviate.collections.classes module structure
mainThe
weaviate.collections.classesmodule serves as the primary namespace for managing collection-level configurations, operations, and metadata in the Weaviate Python Client. It is organized into several specialized sub-modules that handle different aspects of a collection's lifecycle and functionality:aggregate: Methods for performing aggregation queries on a collection.batch: Tools for performing batch operations (insertions, updates, deletions) on a collection.cluster: Operations related to cluster-level management for the collection.config: Configuration management, including vector index settings, vectorizers, and named vectors.data: Operations related to the underlying data within the collection.filters: Logic and types for constructing complex metadata filters.grpc: Configuration and settings specific to gRPC communication for the collection.orm: Object-Relational Mapping capabilities for interacting with collection objects.tenants: Management of multi-tenancy features, such as creating and deleting tenants.types: Type definitions and schemas used throughout the collection modules.
How the documentation is published
mainThe documentation for the Weaviate Python Client is published via Read the Docs (RTD), not GitHub Actions. RTD is configured to monitor the repository and automatically rebuild the documentation on every push to a tracked branch or tag.
While GitHub Actions (via
.github/workflows/main.yaml) runspython -m sphinx ...as a sanity check, it does not handle the actual publishing process. You can manage and monitor the project via the Read the Docs project dashboard.Explore the weaviate.collections module and subpackages
mainThe
weaviate.collectionsmodule is the primary entry point for interacting with collections (classes) in Weaviate. It provides a structured hierarchy of subpackages to manage different aspects of collection operations, including data manipulation, querying, configuration, and administrative tasks.Key functional areas available through subpackages include:
- Data & Operations:
batchfor high-performance ingestion,datafor CRUD,iteratorfor large-scale data traversal, andormfor object-relational mapping. - Querying & Filtering:
queryfor retrieving objects,filtersfor constructing complex search criteria,aggregationsfor statistical analysis, andgeneratefor generative AI features. - Management & Configuration:
classesfor schema definition,configfor inspecting collection settings,tenantsfor multi-tenancy,backupsfor data persistence, andclusterfor cluster-level operations. - Infrastructure:
grpcfor low-level communication.
- Data & Operations:
Explore Weaviate output data structures
mainThe
weaviate.outputsmodule contains the data models and response structures returned by various Weaviate API operations. Instead of working with raw JSON, the client uses these structured objects to provide type safety and easier access to data. The outputs are organized into sub-modules corresponding to the functional areas of the API:weaviate.outputs.aggregate: Structures for aggregation results.weaviate.outputs.backup: Structures for backup operations and statuses.weaviate.outputs.batch: Structures for batch processing results.weaviate.outputs.cluster: Structures related to cluster health and status.weaviate.outputs.config: Structures for schema and configuration data.weaviate.outputs.data: Structures for core data objects (e.g., objects, properties).weaviate.outputs.query: Structures for search and retrieval results.weaviate.outputs.rbac: Structures for Role-Based Access Control.weaviate.outputs.tenants: Structures for multi-tenancy and tenant management.
Explore Weaviate collection query submodules
mainThe
weaviate.collections.queriesmodule provides access to various query methods for retrieving data from a collection. Depending on your search requirements (keyword, vector, hybrid, or media-based), you will use one of the following specialized submodules:- Keyword/BM25:
weaviate.collections.queries.bm25 - ID-based retrieval:
weaviate.collections.queries.fetch_object_by_idandweaviate.collections.queries.fetch_objects_by_ids - General object retrieval:
weaviate.collections.queries.fetch_objects - Hybrid search:
weaviate.collections.queries.hybrid - Vector/Near-based search:
weaviate.collections.queries.near_vector(search by raw vector)weaviate.collections.queries.near_text(search by text embedding)weaviate.collections.queries.near_object(search by an existing object)
- Media/Image search:
weaviate.collections.queries.near_imageweaviate.collections.queries.near_media
- Keyword/BM25:
Explore the Weaviate Python Client subpackages
mainThe
weaviatepackage is organized into several specialized subpackages that handle different aspects of interacting with a Weaviate instance. Depending on your task, you will use different modules:weaviate.backup: Manage backups and restores.weaviate.classes: High-level object-oriented interfaces for collections and properties.weaviate.cluster: Manage cluster-level operations.weaviate.collections: Interface for interacting with collections (data schemas and objects).weaviate.connect: Connection management and client instantiation.weaviate.debug: Tools for debugging and inspecting Weaviate state.weaviate.gql: Execute raw GraphQL queries.weaviate.outputs: Standardized output formats for client responses.weaviate.rbac: Role-Based Access Control management.weaviate.users: User management operations.weaviate.auth: Authentication mechanisms and credentials.weaviate.config: Configuration settings for the client and connection.weaviate.embedded: Utilities for running Weaviate in embedded mode.
Explore the weaviate.classes module hierarchy
mainThe
weaviate.classesmodule serves as the primary namespace for high-level, type-safe classes used to interact with Weaviate. Instead of using raw dictionaries or strings for complex operations, you use these specialized classes to construct queries, manage configurations, and handle data.Key sub-modules include:
weaviate.classes.query: For constructing advanced search and retrieval queries.weaviate.classes.data: For managing object data and properties.weaviate.classes.config: For defining and modifying collection schemas and configurations.weaviate.classes.batch: For performing high-performance bulk data operations.weaviate.classes.aggregate: For performing statistical aggregations over collections.weaviate.classes.backup: For managing database backups.weaviate.classes.tenants: For managing multi-tenancy features.weaviate.classes.rbac: For Role-Based Access Control configurations.weaviate.classes.init: For initialization-related logic.weaviate.classes.debug: For debugging and diagnostic purposes.weaviate.classes.generics: For generic type definitions used within the client.
Supported Client Versions
mainThe client maintains two major version tracks:
- 4.X: The current actively supported version.
- 3.X: Deprecated. This version receives only critical bug fixes and dependency updates.
What are Weaviate Agents?
mainWeaviate Agents are agentic pre-built services designed to simplify common LLM-related tasks using your Weaviate data. They include:
- QueryAgent: For agentic querying.
- TransformationAgent: For data transformation tasks.
- PersonalizationAgent: For personalizing responses based on Weaviate data.
These agents require a connection to Weaviate Cloud (WCD) and are not compatible with local Weaviate instances.
Perform aggregations in Weaviate using collections.aggregations
mainThe
weaviate.collections.aggregationsmodule provides various aggregation types that can be used to perform statistical analysis and grouped queries on data within a collection. Aggregations allow you to summarize data across specific properties or based on vector similarity.Available aggregation types include:
aggregate: General aggregation capabilities.hybrid: Hybrid search-based aggregations.near_image: Aggregations based on image vector similarity.near_object: Aggregations based on object similarity.near_text: Aggregations based on text vector similarity.near_vector: Aggregations based on specific vector proximity.over_all: Aggregations performed over the entire collection.
How the weaviate-agents-python-client is integrated into docs
mainThe
weaviate-agents-python-clientdocumentation is integrated into the main Weaviate Python Client documentation site. This is achieved by cloning the agents repository during the RTDpre_buildphase and adding it to the Sphinx path.Integration Mechanism:
.readthedocs.yaml: Uses apre_buildhook togit clonethemainbranch of the agents repo intodocs/weaviate-agents-python-clientand installs it in editable mode.docs/conf.py: Inserts the cloned directory intosys.pathso Sphinx can resolve the modules.
Key Behaviors:
- The agents docs are pulled from the
mainbranch of the agents repository. - Changes in the agents repository are not automatically reflected in the published docs immediately; they update when a new release of
weaviate-python-clientis cut or when a manual rebuild is triggered in RTD. - Sphinx picks up the agents' documentation because its
.rstfiles reside within the cloned directory structure under the main source tree.
# .readthedocs.yaml snippet build: jobs: pre_build: - git clone -b main --depth=1 https://github.com/weaviate/weaviate-agents-python-client.git docs/weaviate-agents-python-client - python -m pip install -e ./docs/weaviate-agents-python-client# docs/conf.py snippet sys.path.insert(0, os.path.abspath("weaviate-agents-python-client"))