Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
build: 2.4.10 after qa
Browse files Browse the repository at this point in the history
  • Loading branch information
dsdanielpark committed Apr 29, 2024
1 parent 22dc276 commit 8cf2978
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
3 changes: 1 addition & 2 deletions gemini/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
except ImportError as e:
pass

gemini_api_key = environ.get("GEMINI_COOKIES")

__version__ = "2.4.9"
__version__ = "2.4.10"
__author__ = (
"daniel park <parkminwoo1991@gmail.com>, antonio cheang <teapotv8@proton.me>, "
"HanaokaYuzu, CBoYXD, veonua, thewh1teagle, jjkoh95, yihong0618, nishantchauhan949, MeemeeLab, kota113, "
Expand Down
6 changes: 4 additions & 2 deletions gemini/src/model/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ async def fetch_bytes(
Optional[bytes]: The bytes of the image, or None if fetching fails.
"""
try:
async with httpx.AsyncClient(follow_redirects=True, cookies=cookies, proxies=proxies) as client:
async with httpx.AsyncClient(
follow_redirects=True, cookies=cookies, proxies=proxies
) as client:
response = await client.get(str(url))
response.raise_for_status()
return response.content
Expand Down Expand Up @@ -220,4 +222,4 @@ def save_images_sync(
filepath.write_bytes(data)
except:
pass
print(f"Saved {title} to {save_path}")
print(f"Saved {title} to {save_path}")
29 changes: 23 additions & 6 deletions tests/gemini_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,42 @@
from pydantic import HttpUrl
from ..gemini import GeminiImage


def parse_args():
parser = argparse.ArgumentParser(description="Test the GeminiImage class functionality")
parser.add_argument("--url", type=str, required=True, help="URL of the image to test", default="https://upload.wikimedia.org/wikipedia/commons/c/cf/Harvard_Yard_in_autumn%2C_Boston%2C_Massachusetts%2C_2015.jpg")
parser.add_argument("--title", type=str, default="[Image]", help="Title of the image")
parser.add_argument("--save_path", type=str, default="cached", help="Directory to save the images")
parser.add_argument("--async", action="store_true", help="Use asynchronous methods for testing")
parser = argparse.ArgumentParser(
description="Test the GeminiImage class functionality"
)
parser.add_argument(
"--url",
type=str,
required=True,
help="URL of the image to test",
default="https://upload.wikimedia.org/wikipedia/commons/c/cf/Harvard_Yard_in_autumn%2C_Boston%2C_Massachusetts%2C_2015.jpg",
)
parser.add_argument(
"--title", type=str, default="[Image]", help="Title of the image"
)
parser.add_argument(
"--save_path", type=str, default="cached", help="Directory to save the images"
)
parser.add_argument(
"--async", action="store_true", help="Use asynchronous methods for testing"
)
return parser.parse_args()


async def test_async(url, title, save_path, cookies):
images = [GeminiImage(url=HttpUrl(url), title=title)]
await GeminiImage.save(images, save_path, cookies)


def test_sync(url, title, save_path, cookies):
images = [GeminiImage(url=HttpUrl(url), title=title)]
GeminiImage.save_sync(images, cookies, save_path)


if __name__ == "__main__":
args = parse_args()

test_sync(args.url, args.title, args.save_path)
test_async(args.url, args.title, args.save_path)

0 comments on commit 8cf2978

Please sign in to comment.