From 54e0b29079f0b30db61db36730f5f3a7fdd2d166 Mon Sep 17 00:00:00 2001 From: David Manouchehri Date: Mon, 8 Jul 2024 05:31:32 +0000 Subject: [PATCH] feat(httpx): Send litellm version upstream. --- litellm/llms/custom_httpx/http_handler.py | 11 +++++++++++ litellm/llms/custom_httpx/httpx_handler.py | 11 ++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/litellm/llms/custom_httpx/http_handler.py b/litellm/llms/custom_httpx/http_handler.py index ef79b487f..ddffe9ad8 100644 --- a/litellm/llms/custom_httpx/http_handler.py +++ b/litellm/llms/custom_httpx/http_handler.py @@ -7,6 +7,15 @@ import httpx import litellm +try: + from litellm._version import version +except: + version = "0.0.0" + +headers = { + "User-Agent": f"litellm/{version}", +} + # https://www.python-httpx.org/advanced/timeouts _DEFAULT_TIMEOUT = httpx.Timeout(timeout=5.0, connect=5.0) @@ -44,6 +53,7 @@ class AsyncHTTPHandler: ), verify=ssl_verify, cert=cert, + headers=headers, ) async def close(self): @@ -159,6 +169,7 @@ class HTTPHandler: ), verify=ssl_verify, cert=cert, + headers=headers, ) else: self.client = client diff --git a/litellm/llms/custom_httpx/httpx_handler.py b/litellm/llms/custom_httpx/httpx_handler.py index 3f3bd09ba..513b0adad 100644 --- a/litellm/llms/custom_httpx/httpx_handler.py +++ b/litellm/llms/custom_httpx/httpx_handler.py @@ -1,6 +1,14 @@ from typing import Optional import httpx +try: + from litellm._version import version +except: + version = "0.0.0" + +headers = { + "User-Agent": f"litellm/{version}", +} class HTTPHandler: def __init__(self, concurrent_limit=1000): @@ -9,7 +17,8 @@ class HTTPHandler: limits=httpx.Limits( max_connections=concurrent_limit, max_keepalive_connections=concurrent_limit, - ) + ), + headers=headers, ) async def close(self):