mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-27 04:49:47 +01:00
17 lines
No EOL
655 B
Python
17 lines
No EOL
655 B
Python
import os
|
|
import sys
|
|
from config.logger import setup_logging
|
|
import importlib
|
|
|
|
logger = setup_logging()
|
|
|
|
|
|
def create_instance(class_name, *args, **kwargs):
|
|
# Create intent instance
|
|
if os.path.exists(os.path.join('core', 'providers', 'intent', class_name, f'{class_name}.py')):
|
|
lib_name = f'core.providers.intent.{class_name}.{class_name}'
|
|
if lib_name not in sys.modules:
|
|
sys.modules[lib_name] = importlib.import_module(f'{lib_name}')
|
|
return sys.modules[lib_name].IntentProvider(*args, **kwargs)
|
|
|
|
raise ValueError(f"Unsupported intent type: {class_name}, please check if the type in config is set correctly") |