From a7345cbc419b302aa0a3bbccd8b16d580e0c4d90 Mon Sep 17 00:00:00 2001 From: juk0de Date: Wed, 13 Sep 2023 07:52:05 +0200 Subject: [PATCH] ai_factory: fixed argument parsing bug --- chatmastermind/ai_factory.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chatmastermind/ai_factory.py b/chatmastermind/ai_factory.py index a3cf9c3..36a987b 100644 --- a/chatmastermind/ai_factory.py +++ b/chatmastermind/ai_factory.py @@ -17,7 +17,7 @@ def create_ai(args: argparse.Namespace, config: Config) -> AI: # noqa: 11 is not found, it uses the first AI in the list. """ ai_conf: AIConfig - if 'AI' in args and args.AI: + if hasattr(args, 'AI') and args.AI: try: ai_conf = config.ais[args.AI] except KeyError: @@ -32,11 +32,11 @@ def create_ai(args: argparse.Namespace, config: Config) -> AI: # noqa: 11 if ai_conf.name == 'openai': ai = OpenAI(cast(OpenAIConfig, ai_conf)) - if 'model' in args and args.model: + if hasattr(args, 'model') and args.model: ai.config.model = args.model - if 'max_tokens' in args and args.max_tokens: + if hasattr(args, 'max_tokens') and args.max_tokens: ai.config.max_tokens = args.max_tokens - if 'temperature' in args and args.temperature: + if hasattr(args, 'temperature') and args.temperature: ai.config.temperature = args.temperature return ai else: