From 797b17833add5d2092d2bf8b3bb02b2e8907fa2b Mon Sep 17 00:00:00 2001 From: hlohaus <983577+hlohaus@users.noreply.github.com> Date: Sat, 1 Feb 2025 12:15:46 +0100 Subject: Fix response type of reasoning in UI --- g4f/image.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'g4f/image.py') diff --git a/g4f/image.py b/g4f/image.py index e265242f..a99b1169 100644 --- a/g4f/image.py +++ b/g4f/image.py @@ -242,13 +242,15 @@ def ensure_images_dir(): os.makedirs(images_dir, exist_ok=True) def get_image_extension(image: str) -> str: - if match := re.search(r"(\.(?:jpe?g|png|webp))[$?&]", image): - return match.group(1) + match = re.search(r"\.(?:jpe?g|png|webp)", image) + if match: + return match.group(0) return ".jpg" async def copy_images( images: list[str], cookies: Optional[Cookies] = None, + headers: Optional[dict] = None, proxy: Optional[str] = None, alt: str = None, add_url: bool = True, @@ -260,7 +262,8 @@ async def copy_images( ensure_images_dir() async with ClientSession( connector=get_connector(proxy=proxy), - cookies=cookies + cookies=cookies, + headers=headers, ) as session: async def copy_image(image: str, target: str = None) -> str: if target is None or len(images) > 1: -- cgit v1.2.3