Update engine.py
This commit is contained in:
@@ -92,16 +92,52 @@ class AIEngine:
|
|||||||
model_config = get_model_config(function_name, account=self.account)
|
model_config = get_model_config(function_name, account=self.account)
|
||||||
model = model_config.get('model')
|
model = model_config.get('model')
|
||||||
|
|
||||||
|
# Read model straight from IntegrationSettings for visibility
|
||||||
|
model_from_integration = None
|
||||||
|
if self.account:
|
||||||
|
try:
|
||||||
|
from igny8_core.modules.system.models import IntegrationSettings
|
||||||
|
openai_settings = IntegrationSettings.objects.filter(
|
||||||
|
integration_type='openai',
|
||||||
|
account=self.account,
|
||||||
|
is_active=True
|
||||||
|
).first()
|
||||||
|
if openai_settings and openai_settings.config:
|
||||||
|
model_from_integration = openai_settings.config.get('model')
|
||||||
|
except Exception as integration_error:
|
||||||
|
logger.warning(
|
||||||
|
"[AIEngine] Unable to read model from IntegrationSettings: %s",
|
||||||
|
integration_error,
|
||||||
|
exc_info=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Track configured model information so it shows in the progress modal
|
||||||
|
self.step_tracker.add_request_step(
|
||||||
|
"PREP",
|
||||||
|
"success",
|
||||||
|
f"AI model in settings: {model_from_integration or 'Not set'}"
|
||||||
|
)
|
||||||
|
self.step_tracker.add_request_step(
|
||||||
|
"PREP",
|
||||||
|
"success",
|
||||||
|
f"AI model selected for request: {model or 'default'}"
|
||||||
|
)
|
||||||
|
|
||||||
# Debug logging: Show model configuration
|
# Debug logging: Show model configuration
|
||||||
logger.info(f"[AIEngine] Model Configuration for {function_name}:")
|
logger.info(f"[AIEngine] Model Configuration for {function_name}:")
|
||||||
logger.info(f" - Model from get_model_config: {model}")
|
logger.info(f" - Model from get_model_config: {model}")
|
||||||
logger.info(f" - Full model_config: {model_config}")
|
logger.info(f" - Full model_config: {model_config}")
|
||||||
self.console_tracker.ai_call(f"Model from settings: {model}")
|
self.console_tracker.ai_call(f"Model from settings: {model_from_integration or 'Not set'}")
|
||||||
|
self.console_tracker.ai_call(f"Model selected for request: {model or 'default'}")
|
||||||
self.console_tracker.ai_call(f"Calling {model or 'default'} model with {len(prompt)} char prompt")
|
self.console_tracker.ai_call(f"Calling {model or 'default'} model with {len(prompt)} char prompt")
|
||||||
self.console_tracker.ai_call(f"Function ID: {function_id}")
|
self.console_tracker.ai_call(f"Function ID: {function_id}")
|
||||||
|
|
||||||
# Track AI call start
|
# Track AI call start
|
||||||
self.step_tracker.add_response_step("AI_CALL", "success", f"Calling {model or 'default'} model...")
|
self.step_tracker.add_response_step(
|
||||||
|
"AI_CALL",
|
||||||
|
"success",
|
||||||
|
f"Calling {model or 'default'} model..."
|
||||||
|
)
|
||||||
self.tracker.update("AI_CALL", 30, f"Sending to {model or 'default'}...", meta=self.step_tracker.get_meta())
|
self.tracker.update("AI_CALL", 30, f"Sending to {model or 'default'}...", meta=self.step_tracker.get_meta())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user