36  Typing

36.1 TypedDict

TypedDict

from typing import TypedDict

class Movie(TypedDict):
    name: str
    year: int
movie: Movie = {'name': 'Blade Runner',
                'year': 1982}
def record_movie(movie: Movie) -> None: ...

record_movie({'name': 'Blade Runner', 'year': 1982})

36.1.1 Example

class BaseGenerateResponse(TypedDict):
  model: str
  'Model used to generate response.'

  created_at: str
  'Time when the request was created.'

  done: bool
  'True if response is complete, otherwise False. Useful for streaming to detect the final response.'