Repository navigation
docs: rewrite the README in Markdown #2202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
g-despot
wants to merge
5
commits into
main
Choose a base branch
from
docs/readme
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
73d18f0
docs: rewrite the README in Markdown
g-despot b7b1e87
docs: fix the README badges, logo and PyPI links
g-despot d0872b7
Merge branch 'main' into docs/readme
g-despot d7bfc27
Merge branch 'main' into docs/readme
g-despot ead9a58
docs: align the README with the TypeScript client README
g-despot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,183 @@ | ||
| # Weaviate Python client <img alt='Weaviate logo' src='https://weaviate.io/img/site/weaviate-logo-light.png' width='148' align='right' /> | ||
|
|
||
| The official Python client for [Weaviate](https://weaviate.io), the open-source vector database. | ||
|
|
||
| [](https://pypi.org/project/weaviate-client/) | ||
| [](https://github.com/weaviate/weaviate-python-client/actions/workflows/main.yaml) | ||
| [](https://weaviate-python-client.readthedocs.io/en/latest/) | ||
| [](https://github.com/weaviate/weaviate-python-client/blob/main/LICENSE) | ||
|
|
||
| ## Packages | ||
|
|
||
| | Package | Use it for | Runtime | | ||
| | --- | --- | --- | | ||
| | [`weaviate-client`](https://pypi.org/project/weaviate-client/) | Apps, scripts and data ingestion. Has a sync client and an async client. Talks to Weaviate over REST and gRPC. | CPython | | ||
| | [`weaviate-client-web`](https://pypi.org/project/weaviate-client-web/) | Running the async client in a browser page, a marimo notebook or a Web Worker. Talks to Weaviate over REST and gRPC-Web. Install it through the `grpc-web` extra. | Pyodide (WebAssembly) | | ||
|
|
||
| ## Install | ||
|
|
||
| ```bash | ||
| pip install -U weaviate-client | ||
| # or: uv add weaviate-client | ||
| ``` | ||
|
|
||
| For Weaviate Agents such as the Query Agent, install the `agents` extra instead: `pip install -U "weaviate-client[agents]"`. It adds the companion package [`weaviate-agents`](https://pypi.org/project/weaviate-agents/). | ||
|
|
||
| `weaviate-client` needs Python 3.11 or later. | ||
|
|
||
| ## Quickstart | ||
|
|
||
| This example needs a local Weaviate with no vectorizer module. See [Run Weaviate with Docker](https://docs.weaviate.io/deploy/installation-guides/docker-installation). The example brings its own vectors and searches with `near_vector`. | ||
|
|
||
| ```python | ||
| import weaviate | ||
| from weaviate.classes.config import Configure, DataType, Property | ||
| from weaviate.classes.data import DataObject | ||
| from weaviate.classes.query import MetadataQuery | ||
|
|
||
| with weaviate.connect_to_local() as client: | ||
| if client.collections.exists("Article"): | ||
| client.collections.delete("Article") | ||
|
|
||
| articles = client.collections.create( | ||
| name="Article", | ||
| properties=[Property(name="title", data_type=DataType.TEXT)], | ||
| vector_config=Configure.Vectors.self_provided(), | ||
| ) | ||
|
|
||
| articles.data.insert_many([ | ||
| DataObject(properties={"title": "Intro to vector search"}, vector=[0.1, 0.9, 0.2]), | ||
| DataObject(properties={"title": "Tuning HNSW indexes"}, vector=[0.8, 0.1, 0.3]), | ||
| ]) | ||
|
|
||
| result = articles.query.near_vector( | ||
| near_vector=[0.2, 0.8, 0.1], | ||
| limit=1, | ||
| return_metadata=MetadataQuery(distance=True), | ||
| ) | ||
|
|
||
| for obj in result.objects: | ||
| print(obj.properties["title"], obj.metadata.distance) | ||
| ``` | ||
|
|
||
| To connect to Weaviate Cloud, replace the `connect_to_local()` call. Set `WEAVIATE_URL` and `WEAVIATE_API_KEY` in your environment first. | ||
|
|
||
| ```python | ||
| import os | ||
|
|
||
| import weaviate | ||
| from weaviate.classes.init import Auth | ||
|
|
||
| with weaviate.connect_to_weaviate_cloud( | ||
| cluster_url=os.environ["WEAVIATE_URL"], | ||
| auth_credentials=Auth.api_key(os.environ["WEAVIATE_API_KEY"]), | ||
| ) as client: | ||
| print(client.is_ready()) | ||
| ``` | ||
|
|
||
| ## Async | ||
|
|
||
| The client also has an async API. The `use_async_with_*` helpers create an async client, and `async with` connects it and closes it. This example queries the collection from the quickstart. | ||
|
|
||
| ```python | ||
| import asyncio | ||
|
|
||
| import weaviate | ||
|
|
||
|
|
||
| async def main(): | ||
| async with weaviate.use_async_with_local() as client: | ||
| articles = client.collections.use("Article") | ||
| result = await articles.query.near_vector(near_vector=[0.2, 0.8, 0.1], limit=1) | ||
| for obj in result.objects: | ||
| print(obj.properties["title"]) | ||
|
|
||
|
|
||
| asyncio.run(main()) | ||
| ``` | ||
|
|
||
| See the [async client docs](https://docs.weaviate.io/weaviate/client-libraries/python/async). | ||
|
|
||
| ## Embedded Weaviate | ||
|
|
||
| Embedded Weaviate downloads a Weaviate binary and starts it from your Python process. It runs on Linux and macOS. It does not run on Windows. | ||
|
|
||
| ```python | ||
| import weaviate | ||
|
|
||
| with weaviate.connect_to_embedded() as client: | ||
| print(client.is_ready()) | ||
| ``` | ||
|
|
||
| See [Embedded Weaviate](https://docs.weaviate.io/deploy/installation-guides/embedded). | ||
|
|
||
| ## Use in the browser (Pyodide) | ||
|
|
||
| `weaviate-client-web` runs the async client under [Pyodide](https://pyodide.org), a Python runtime for the browser. Use it in browser pages, marimo notebooks and Web Workers. Install it through the `grpc-web` extra of `weaviate-client`, as in the example below. For details, see the [web client docs](https://docs.weaviate.io/weaviate/client-libraries/python/web-client). | ||
|
|
||
| ```python | ||
| import micropip | ||
|
|
||
| await micropip.install("weaviate-client[grpc-web]") | ||
|
|
||
| import weaviate | ||
|
|
||
| client = weaviate.use_async_with_local(port=8080) # The HTTP port. gRPC-Web uses it too. | ||
| await client.connect() | ||
| await client.close() | ||
| ``` | ||
|
|
||
| The example uses top-level `await`, which Pyodide supports. Run it in a marimo notebook cell or in another Pyodide environment. It does not run under CPython. | ||
|
|
||
| Keep these points in mind: | ||
|
|
||
| - `weaviate-client-web` needs Weaviate 1.38.3 or later. | ||
| - gRPC requests use gRPC-Web on the HTTP host and port, at the `/v1/grpc-web` path. You do not configure a separate gRPC port. If you use `use_async_with_custom()`, set its gRPC host, port and secure values to the same values as the HTTP ones. The client replaces other values with the HTTP ones and shows a warning. | ||
| - Only the async client works. The sync client and Embedded Weaviate are not available. | ||
| - Server-side batching is not available. `client.batch.stream()` and `collection.batch.stream()` raise an error. Use `collection.data.insert_many()` instead. | ||
| - Anyone who loads your page can read the keys in its code. Never ship an admin key to a browser. Use a read-only API key that has only the [RBAC](https://docs.weaviate.io/deploy/configuration/authorization) permissions your app needs. | ||
| - Browser requests are subject to CORS, so the Weaviate server must allow your page's origin. On Weaviate Cloud, turn on the `Allow all CORS origins` setting for the database. See [default settings](https://docs.weaviate.io/cloud/manage-clusters/default-settings). | ||
|
|
||
| ## Compatibility | ||
|
|
||
| This client works with Weaviate 1.32.0 and later. It raises an error when you connect to an older server. To check which Weaviate versions a client release supports, see the [version table](https://docs.weaviate.io/weaviate/client-libraries/python#releases) in the docs. | ||
|
|
||
| ## Migrating from an older version | ||
|
|
||
| If you are moving from the v3 client (`weaviate.Client`), follow the [v3 to v4 migration guide](https://archive.docs.weaviate.io/weaviate/client-libraries/python/v3_v4_migration). | ||
|
|
||
| ## Documentation | ||
|
|
||
| - [Python client docs](https://docs.weaviate.io/weaviate/client-libraries/python) | ||
| - [API reference](https://weaviate-python-client.readthedocs.io/en/latest/) | ||
| - [Changelog](https://github.com/weaviate/weaviate-python-client/blob/main/docs/changelog.rst) | ||
|
|
||
| ## Support | ||
|
|
||
| - [Weaviate Forum](https://forum.weaviate.io) for questions. | ||
| - [GitHub Issues](https://github.com/weaviate/weaviate-python-client/issues) for bugs and feature requests. | ||
|
|
||
| ## Contributing | ||
|
|
||
| Read the [contributing guide](https://github.com/weaviate/weaviate-python-client/blob/main/CONTRIBUTING.md) before you open a pull request. | ||
|
|
||
| To set up a development environment and run the tests: | ||
|
|
||
| ```bash | ||
| pip install -r requirements-devel.txt -r requirements-test.txt | ||
| pip install -e . | ||
|
|
||
| # Unit and mock tests. These need no Weaviate. | ||
| pytest test mock_tests | ||
|
|
||
| # Integration tests. These start the test stack in Docker, run the tests, then stop the stack. | ||
| # <version> is a Weaviate release without the leading "v". | ||
| # Starts several containers on ports 8075-8093, 9999, 10000, 48001, 48003 and 50051-50065 | ||
| ./ci/start_weaviate.sh <version> | ||
| pytest -n auto --dist loadgroup integration | ||
| ./ci/stop_weaviate.sh <version> | ||
| ``` | ||
|
|
||
| ## License | ||
|
|
||
| BSD-3-Clause. See [LICENSE](https://github.com/weaviate/weaviate-python-client/blob/main/LICENSE). | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.