Skip to content

Commit

Permalink
Add type hints for generators
Browse files Browse the repository at this point in the history
  • Loading branch information
jackmpcollins committed May 16, 2024
1 parent 9ad92c2 commit 5ca0246
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/magentic/chat_model/openai_chat_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def _create_usage_pointer(
"""Returns a pointer to a Usage object that is created at the end of the response."""
usage_pointer = []

def generator():
def generator() -> Iterator[ChatCompletionChunk]:
for chunk in response:
if chunk.usage:
usage = Usage(
Expand All @@ -325,7 +325,7 @@ def _acreate_usage_pointer(
"""Async version of `_create_usage_pointer`."""
usage_pointer = []

async def generator():
async def generator() -> AsyncIterator[ChatCompletionChunk]:
async for chunk in response:
if chunk.usage:
usage = Usage(
Expand Down

0 comments on commit 5ca0246

Please sign in to comment.