fix(factory.py): refactor factory to use httpx client

This commit is contained in:
Krrish Dholakia 2024-07-19 15:32:01 -07:00
parent c56456be64
commit 4c4f032a75

View file

@ -14,6 +14,7 @@ import litellm
import litellm.types import litellm.types
import litellm.types.llms import litellm.types.llms
import litellm.types.llms.vertex_ai import litellm.types.llms.vertex_ai
from litellm.llms.custom_httpx.http_handler import HTTPHandler
from litellm.types.completion import ( from litellm.types.completion import (
ChatCompletionFunctionMessageParam, ChatCompletionFunctionMessageParam,
ChatCompletionMessageParam, ChatCompletionMessageParam,
@ -1989,8 +1990,9 @@ def get_image_details(image_url) -> Tuple[str, str]:
try: try:
import base64 import base64
client = HTTPHandler(concurrent_limit=1)
# Send a GET request to the image URL # Send a GET request to the image URL
response = requests.get(image_url) response = client.get(image_url)
response.raise_for_status() # Raise an exception for HTTP errors response.raise_for_status() # Raise an exception for HTTP errors
# Check the response's content type to ensure it is an image # Check the response's content type to ensure it is an image