Fix httpx deprecation warning during LLM API calls (#9261)

Co-authored-by: Rohit Malhotra <rohitvinodmalhotra@gmail.com>
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Xingyao Wang
2025-06-20 14:36:31 -04:00
committed by GitHub
parent ba885cd04c
commit 078534c2ab
3 changed files with 14 additions and 28 deletions

View File

@@ -288,7 +288,20 @@ class LLM(RetryMixin, DebugMixin):
# Record start time for latency measurement
start_time = time.time()
# we don't support streaming here, thus we get a ModelResponse
resp: ModelResponse = self._completion_unwrapped(*args, **kwargs)
# Suppress httpx deprecation warnings during LiteLLM calls
# This prevents the "Use 'content=<...>' to upload raw bytes/text content" warning
# that appears when LiteLLM makes HTTP requests to LLM providers
with warnings.catch_warnings():
warnings.filterwarnings(
'ignore', category=DeprecationWarning, module='httpx.*'
)
warnings.filterwarnings(
'ignore',
message=r'.*content=.*upload.*',
category=DeprecationWarning,
)
resp: ModelResponse = self._completion_unwrapped(*args, **kwargs)
# Calculate and record latency
latency = time.time() - start_time