Skip to content

Commit

Permalink
new: send client version in requests
Browse files Browse the repository at this point in the history
  • Loading branch information
tellet-q committed Dec 2, 2024
1 parent baa3e26 commit 495f8bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions qdrant_client/async_qdrant_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#
# ****** WARNING: THIS FILE IS AUTOGENERATED ******

import importlib.metadata
import logging
import math
import warnings
Expand All @@ -28,6 +29,7 @@
import httpx
import numpy as np
from grpc import Compression
from packaging import version
from urllib3.util import Url, parse_url
from qdrant_client import grpc as grpc
from qdrant_client._pydantic_compat import construct
Expand Down Expand Up @@ -116,6 +118,9 @@ def __init__(
warnings.warn("Api key is used with an insecure connection.")
self._rest_headers["api-key"] = api_key
self._grpc_headers.append(("api-key", api_key))
client_version = version.parse(importlib.metadata.version("qdrant-client"))
self._rest_headers["User-Agent"] = f"qdrant-client/{client_version}"
self._grpc_headers.append(("user-agent", f"qdrant-client/{client_version}"))
grpc_compression: Optional[Compression] = kwargs.pop("grpc_compression", None)
if grpc_compression is not None and (not isinstance(grpc_compression, Compression)):
raise TypeError(
Expand Down
6 changes: 6 additions & 0 deletions qdrant_client/qdrant_remote.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import importlib.metadata
import logging
import math
import warnings
Expand All @@ -19,6 +20,7 @@
import httpx
import numpy as np
from grpc import Compression
from packaging import version
from urllib3.util import Url, parse_url

from qdrant_client import grpc as grpc
Expand Down Expand Up @@ -133,6 +135,10 @@ def __init__(
self._rest_headers["api-key"] = api_key
self._grpc_headers.append(("api-key", api_key))

client_version = version.parse(importlib.metadata.version("qdrant-client"))
self._rest_headers["User-Agent"] = f"qdrant-client/{client_version}"
self._grpc_headers.append(("user-agent", f"qdrant-client/{client_version}"))

# GRPC Channel-Level Compression
grpc_compression: Optional[Compression] = kwargs.pop("grpc_compression", None)
if grpc_compression is not None and not isinstance(grpc_compression, Compression):
Expand Down

0 comments on commit 495f8bc

Please sign in to comment.