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: