Skip to content

Andy963 patch 2 #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions google/generativeai/types/generation_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@
"GenerateContentResponse",
]

if sys.version_info < (3, 10):

def aiter(obj):
return obj.__aiter__()

async def anext(obj, default=None):
try:
return await obj.__anext__()
except StopAsyncIteration:
if default is not None:
return default
else:
raise


class BlockedPromptException(Exception):
pass
Expand Down
4 changes: 0 additions & 4 deletions tests/test_generative_models_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ async def test_basic(self):

self.assertEqual(response.text, "world!")

@unittest.skipIf(
sys.version_info.major == 3 and sys.version_info.minor < 10,
"streaming async requires python 3.10+",
)
async def test_streaming(self):
# Generate text from text prompt
model = generative_models.GenerativeModel(model_name="gemini-m")
Expand Down
Loading