Skip to content

Commit

Permalink
Add New API to Docs (#361)
Browse files Browse the repository at this point in the history
* * chore(.gitignore): add docs/source/examples/*/*/* to ignore list

* * feat(docs): add new modules and subpackages to qdrant_client documentation

* * docs(qdrant_client): update QdrantClient documentation to include information about async versions

* * docs(index.rst): update link to complete client API docs

* * chore(pyproject.toml): remove unused dependencies from dev group
* feat(pyproject.toml): add dependencies for documentation group

* * chore(pyproject.toml): update ipython dependency version to 8
* fix(pyproject.toml): fix typo in Pygments dependency version

* * chore(generate_docs_netlify.sh): remove unnecessary pip installations and fix newline at end of file

* * docs(index.rst): update Qdrant Client Documentation title to include [Python]
* docs(index.rst): update Qdrant Client Documentation description to include vector search engine
* docs(index.rst): update recreate_collection code example to include vectors_config parameter

* * docs(index.rst): add code samples for async client support

* * chore(conf.py): exclude grpc and tests directories from documentation build

* * docs(index.rst): fix title of Qdrant Python Client Documentation
* docs(index.rst): remove unnecessary link to test file in async mode section
* docs(index.rst): add missing classes to API Reference section

* * chore(conf.py): exclude local directory from documentation generation

* * docs(quickstart.ipynb): update section title from "Points, Upsert and Search without `fastembed`" to "Qdrant without `fastembed`"

* * chore(conf.py): exclude tests from documentation by updating exclude_patterns
  • Loading branch information
NirantK authored and joein committed Nov 3, 2023
1 parent 82ad21a commit 86b38a1
Show file tree
Hide file tree
Showing 52 changed files with 705 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ dist
local_cache/*/*
.python-version
docs/source/examples/local_cache/*
docs/source/examples/path/to/db/*
docs/source/examples/path/to/db/*
2 changes: 2 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = [
"*qdrant_openapi_client*",
"*grpc*",
"*tests*" # tests are not part of the documentation
]
# -- Options for HTML output -------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions docs/source/examples/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"## Embedding, Inserting and Querying\n",
"\n",
"1. `add` and `query` with fastembed\n",
"2. Points, insert and query without fastembed"
"2. Qdrant without fastembed: Points, upsert and query "
]
},
{
Expand Down Expand Up @@ -183,7 +183,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Points, Upsert and Search without `fastembed`\n",
"## Qdrant without `fastembed`\n",
"\n",
"### Collection\n",
"\n",
Expand Down
112 changes: 69 additions & 43 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.. You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Python Qdrant client library
=============================
Qdrant Python Client Documentation
==================================

Client library for the `Qdrant <https://github.com/qdrant/qdrant>`_ vector search engine.

Expand Down Expand Up @@ -35,34 +35,28 @@ Create a new collection
.. code-block:: python
client.recreate_collection(
collection_name="my_collection",
vector_size=100
collection_name="my_collection",
vectors_config=VectorParams(size=100, distance=Distance.COSINE),
)
Get info about created collection

.. code-block:: python
from qdrant_client._pydantic_compat import to_dict
my_collection_info = client.http.collections_api.get_collection("my_collection")
print(to_dict(my_collection_info))
Insert vectors into a collection

.. code-block:: python
from qdrant_client.http.models import PointStruct
import numpy as np
from qdrant_client.models import PointStruct
vectors = np.random.rand(100, 100)
client.upsert(
collection_name="my_collection",
points=[
PointStruct(
collection_name="my_collection",
points=[
PointStruct(
id=idx,
vector=vector,
)
for idx, vector in enumerate(vectors)
]
vector=vector.tolist(),
payload={"color": "red", "rand_number": idx % 10}
)
for idx, vector in enumerate(vectors)
]
)
Search for similar vectors
Expand All @@ -73,46 +67,74 @@ Search for similar vectors
hits = client.search(
collection_name="my_collection",
query_vector=query_vector,
query_filter=None, # Don't use any filters for now, search across all indexed points
with_payload=True, # Also return a stored payload for found points, true by default
limit=5 # Return 5 closest points
)
Search for similar vectors with filtering condition

.. code-block:: python
from qdrant_client.http.models import Filter, FieldCondition, Range
from qdrant_client.models import Filter, FieldCondition, Range
hits = client.search(
collection_name="my_collection",
query_vector=query_vector,
query_filter=Filter(
must=[ # These conditions are required for search results
collection_name="my_collection",
query_vector=query_vector,
query_filter=Filter(
must=[ # These conditions are required for search results
FieldCondition(
key='rand_number', # Condition based on values of `rand_number` field.
range=Range(
gte=0.5 # Select only those results where `rand_number` >= 0.5
key='rand_number', # Condition based on values of `rand_number` field.
range=Range(
gte=3 # Select only those results where `rand_number` >= 3
)
)
]
),
with_payload=True, # Return payload, true by default
]
),
limit=5 # Return 5 closest points
)
Check out `full example code <https://github.com/qdrant/qdrant-client/blob/master/tests/test_qdrant_client.py>`_
Async Client
============

gRPC
====
Starting from version 1.6.1, all python client methods are available in async version.

gRPC support in Qdrant client is under active development. Basic classes could be found `here <https://github.com/qdrant/qdrant-client/blob/master/qdrant_client/grpc/__init__.py>`_.
.. code-block:: python
To enable (much faster) collection uploading with gRPC, use the following initialization:
from qdrant_client import AsyncQdrantClient, models
import numpy as np
import asyncio
async def main():
# Your async code using QdrantClient might be put here
client = AsyncQdrantClient(url="http://localhost:6333")
await client.create_collection(
collection_name="my_collection",
vectors_config=models.VectorParams(size=10, distance=models.Distance.COSINE),
)
await client.upsert(
collection_name="my_collection",
points=[
models.PointStruct(
id=i,
vector=np.random.rand(10).tolist(),
)
for i in range(100)
],
)
.. code-block:: python
res = await client.search(
collection_name="my_collection",
query_vector=np.random.rand(10).tolist(), # type: ignore
limit=10,
)
from qdrant_client import QdrantClient
print(res)
asyncio.run(main())
client = QdrantClient(host="localhost", grpc_port=6334, prefer_grpc=True)
Both, gRPC and REST API are supported in async mode.

Highlighted Classes
===================
Expand Down Expand Up @@ -141,13 +163,17 @@ Indices and tables

.. toctree::
:maxdepth: 2
:caption: Selected API Reference
:caption: API Reference

Models <qdrant_client.http.models.models>
Exceptions <qdrant_client.http.exceptions>
QdrantClient <qdrant_client.qdrant_client>
AsyncQdrantClient <qdrant_client.async_qdrant_client>
FastEmbed Mixin <qdrant_client.qdrant_fastembed>

.. toctree::
:maxdepth: 1
:caption: Complete Docs

Complete Client API Docs <qdrant_client.qdrant_client>
Complete Client API Docs <qdrant_client>

7 changes: 7 additions & 0 deletions docs/source/qdrant_client.async_client_base.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.async\_client\_base module
=========================================

.. automodule:: qdrant_client.async_client_base
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/qdrant_client.async_qdrant_client.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.async\_qdrant\_client module
===========================================

.. automodule:: qdrant_client.async_qdrant_client
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/qdrant_client.async_qdrant_fastembed.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.async\_qdrant\_fastembed module
==============================================

.. automodule:: qdrant_client.async_qdrant_fastembed
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/qdrant_client.async_qdrant_remote.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.async\_qdrant\_remote module
===========================================

.. automodule:: qdrant_client.async_qdrant_remote
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/qdrant_client.client_base.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.client\_base module
==================================

.. automodule:: qdrant_client.client_base
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/qdrant_client.connection.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.connection module
================================

.. automodule:: qdrant_client.connection
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/qdrant_client.fastembed_common.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.fastembed\_common module
=======================================

.. automodule:: qdrant_client.fastembed_common
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/qdrant_client.grpc.collections_pb2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.grpc.collections\_pb2 module
===========================================

.. automodule:: qdrant_client.grpc.collections_pb2
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/qdrant_client.grpc.collections_pb2_grpc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.grpc.collections\_pb2\_grpc module
=================================================

.. automodule:: qdrant_client.grpc.collections_pb2_grpc
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/qdrant_client.grpc.collections_service_pb2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.grpc.collections\_service\_pb2 module
====================================================

.. automodule:: qdrant_client.grpc.collections_service_pb2
:members:
:undoc-members:
:show-inheritance:
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.grpc.collections\_service\_pb2\_grpc module
==========================================================

.. automodule:: qdrant_client.grpc.collections_service_pb2_grpc
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/qdrant_client.grpc.json_with_int_pb2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.grpc.json\_with\_int\_pb2 module
===============================================

.. automodule:: qdrant_client.grpc.json_with_int_pb2
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/qdrant_client.grpc.json_with_int_pb2_grpc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.grpc.json\_with\_int\_pb2\_grpc module
=====================================================

.. automodule:: qdrant_client.grpc.json_with_int_pb2_grpc
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/qdrant_client.grpc.points_pb2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.grpc.points\_pb2 module
======================================

.. automodule:: qdrant_client.grpc.points_pb2
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/qdrant_client.grpc.points_pb2_grpc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.grpc.points\_pb2\_grpc module
============================================

.. automodule:: qdrant_client.grpc.points_pb2_grpc
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/qdrant_client.grpc.points_service_pb2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.grpc.points\_service\_pb2 module
===============================================

.. automodule:: qdrant_client.grpc.points_service_pb2
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/qdrant_client.grpc.points_service_pb2_grpc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.grpc.points\_service\_pb2\_grpc module
=====================================================

.. automodule:: qdrant_client.grpc.points_service_pb2_grpc
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/qdrant_client.grpc.qdrant_pb2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.grpc.qdrant\_pb2 module
======================================

.. automodule:: qdrant_client.grpc.qdrant_pb2
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/qdrant_client.grpc.qdrant_pb2_grpc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.grpc.qdrant\_pb2\_grpc module
============================================

.. automodule:: qdrant_client.grpc.qdrant_pb2_grpc
:members:
:undoc-members:
:show-inheritance:
21 changes: 21 additions & 0 deletions docs/source/qdrant_client.grpc.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
qdrant\_client.grpc package
===========================

Submodules
----------

.. toctree::
:maxdepth: 4

qdrant_client.grpc.collections_pb2
qdrant_client.grpc.collections_pb2_grpc
qdrant_client.grpc.collections_service_pb2
qdrant_client.grpc.collections_service_pb2_grpc
qdrant_client.grpc.json_with_int_pb2
qdrant_client.grpc.json_with_int_pb2_grpc
qdrant_client.grpc.points_pb2
qdrant_client.grpc.points_pb2_grpc
qdrant_client.grpc.points_service_pb2
qdrant_client.grpc.points_service_pb2_grpc
qdrant_client.grpc.qdrant_pb2
qdrant_client.grpc.qdrant_pb2_grpc
qdrant_client.grpc.snapshots_service_pb2
qdrant_client.grpc.snapshots_service_pb2_grpc

Module contents
---------------

Expand Down
7 changes: 7 additions & 0 deletions docs/source/qdrant_client.grpc.snapshots_service_pb2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
qdrant\_client.grpc.snapshots\_service\_pb2 module
==================================================

.. automodule:: qdrant_client.grpc.snapshots_service_pb2
:members:
:undoc-members:
:show-inheritance:
Loading

0 comments on commit 86b38a1

Please sign in to comment.