added new module 'ai_factory'

This commit is contained in:
juk0de 2023-09-05 23:24:20 +02:00
parent 1b52643367
commit 484e16de4d

View File

@ -0,0 +1,20 @@
"""
Creates different AI instances, based on the given configuration.
"""
import argparse
from .configuration import Config
from .ai import AI, AIError
from .ais.openai import OpenAI
def create_ai(args: argparse.Namespace, config: Config) -> AI:
"""
Creates an AI subclass instance from the given args and configuration.
"""
if args.ai == 'openai':
# FIXME: create actual 'OpenAIConfig' and set values from 'args'
# FIXME: use actual name from config
return OpenAI("openai", config.openai)
else:
raise AIError(f"AI '{args.ai}' is not supported")