Skip to content

Commit

Permalink
Fix aiter & anext implementations.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkDaoust committed Dec 15, 2023
1 parent 7f1e165 commit 3cd1d8b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions google/generativeai/types/generation_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@
if sys.version_info < (3, 10):

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

async def anext(obj, default=None):
try:
return obj.__anext__()
return await obj.__anext__()
except StopAsyncIteration:
if default is not None:
return default
else:
raise StopAsyncIteration("stop iteration") from None
except Exception as e:
return obj.__next__()
raise


class BlockedPromptException(Exception):
Expand Down

0 comments on commit 3cd1d8b

Please sign in to comment.