Refactor AIEngine and registry to improve function ID generation and support legacy names
- Updated AIEngine to normalize function names by replacing underscores with hyphens in generated function IDs for better consistency with frontend tracking. - Enhanced registry to resolve function name aliases, allowing for backward compatibility with legacy function names when retrieving function instances.
This commit is contained in:
@@ -83,7 +83,9 @@ class AIEngine:
|
|||||||
function_name = fn.get_name()
|
function_name = fn.get_name()
|
||||||
|
|
||||||
# Generate function_id for tracking (ai-{function_name}-01)
|
# Generate function_id for tracking (ai-{function_name}-01)
|
||||||
function_id = f"ai-{function_name}-01"
|
# Normalize underscores to hyphens to match frontend tracking IDs
|
||||||
|
function_id_base = function_name.replace('_', '-')
|
||||||
|
function_id = f"ai-{function_id_base}-01"
|
||||||
|
|
||||||
# Get model config from settings (Stage 4 requirement)
|
# Get model config from settings (Stage 4 requirement)
|
||||||
model_config = get_model_config(function_name)
|
model_config = get_model_config(function_name)
|
||||||
|
|||||||
@@ -54,7 +54,15 @@ def list_functions() -> list:
|
|||||||
|
|
||||||
def get_function_instance(name: str) -> Optional[BaseAIFunction]:
|
def get_function_instance(name: str) -> Optional[BaseAIFunction]:
|
||||||
"""Get function instance by name - lazy loads if needed"""
|
"""Get function instance by name - lazy loads if needed"""
|
||||||
fn_class = get_function(name)
|
# Resolve alias first to support legacy function names
|
||||||
|
try:
|
||||||
|
from igny8_core.ai.settings import FUNCTION_ALIASES
|
||||||
|
except ImportError:
|
||||||
|
FUNCTION_ALIASES = {}
|
||||||
|
|
||||||
|
actual_name = FUNCTION_ALIASES.get(name, name)
|
||||||
|
|
||||||
|
fn_class = get_function(actual_name)
|
||||||
if fn_class:
|
if fn_class:
|
||||||
return fn_class()
|
return fn_class()
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user