From 690937a3809fa9b32f6d8f48400ac6c04abf8331 Mon Sep 17 00:00:00 2001 From: Roger Wang Date: Tue, 17 Sep 2024 22:47:22 -0700 Subject: [PATCH] add headers --- src/mistral_common/multimodal.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mistral_common/multimodal.py b/src/mistral_common/multimodal.py index a167a77..7829612 100644 --- a/src/mistral_common/multimodal.py +++ b/src/mistral_common/multimodal.py @@ -7,11 +7,13 @@ from pydantic import BeforeValidator, PlainSerializer, SerializationInfo from typing_extensions import Annotated +from mistral_common import __version__ def download_image(url: str) -> Image.Image: + headers = {"User-Agent": f"mistral-common/{__version__}"} try: # Make a request to download the image - response = requests.get(url) + response = requests.get(url, headers=headers) response.raise_for_status() # Raise an error for bad responses (4xx, 5xx) # Convert the image content to a PIL Image