diff --git a/arey/platform/console.py b/arey/platform/console.py index 2857644..fd8ce30 100644 --- a/arey/platform/console.py +++ b/arey/platform/console.py @@ -9,7 +9,6 @@ from rich.console import Console from rich.theme import Theme -from wurlitzer import pipes theme = Theme( { @@ -51,7 +50,13 @@ def __exit__(self, exc_type, exc_value, traceback): def capture_stderr() -> Generator[StringIO, None, None]: """Capture stderr for both python and c-functions.""" stderr = io.StringIO() - with redirect_stderr(stderr) as err, pipes( - stdout=0, stderr=stderr, encoding="utf-8" - ): - yield err + try: + from wurlitzer import pipes + + with redirect_stderr(stderr) as err, pipes( + stdout=0, stderr=stderr, encoding="utf-8" + ): + yield err + except Exception: + # Not supported on Windows. Disable stderr capture. + yield stderr diff --git a/arey/play.py b/arey/play.py index 1022738..8bc7105 100644 --- a/arey/play.py +++ b/arey/play.py @@ -14,7 +14,7 @@ from arey.platform.assets import get_asset_path from arey.platform.llama import LlamaBaseModel from arey.platform.console import capture_stderr -from typing import Dict, Optional, Iterator +from typing import Dict, Optional, Iterator, cast config = get_config() @@ -72,8 +72,8 @@ def get_play_file(file_path: str) -> PlayFile: play_file = frontmatter.load(f) # FIXME validate settings - model_config = config.models[play_file.metadata["model"]] - model_settings = play_file.metadata["settings"] + model_config = config.models[cast(str, play_file.metadata["model"])] + model_settings: dict = cast(dict, play_file.metadata.get("settings", {})) return PlayFile( file_path=play_file_path, model_config=model_config,