added new module 'ai_factory'
This commit is contained in:
parent
1b52643367
commit
484e16de4d
20
chatmastermind/ai_factory.py
Normal file
20
chatmastermind/ai_factory.py
Normal 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")
|
||||||
Loading…
x
Reference in New Issue
Block a user