Add model alias for legacy gpt-5 database entries
Focus groups created before the gpt-5.2 rename have llm_model='gpt-5' stored in MongoDB. Without an alias, the backend falls through to the Gemini provider and fails with an aiohttp AssertionError. Adds MODEL_ALIASES mapping and _resolve_model() helper so gpt-5 is transparently resolved to gpt-5.2. Also updates all llm_model checks to accept both values. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
82b06c5ea2
commit
b1be8f8c38
4 changed files with 33 additions and 14 deletions
|
|
@ -189,8 +189,8 @@ Be genuine and specific in your feedback, drawing on your personal experiences a
|
|||
conversation_context=multimodal_context['conversation_context'],
|
||||
temperature=temperature,
|
||||
model_name=llm_model,
|
||||
reasoning_effort=reasoning_effort if llm_model == 'gpt-5.2' else None,
|
||||
verbosity=verbosity if llm_model == 'gpt-5.2' else None
|
||||
reasoning_effort=reasoning_effort if llm_model in ('gpt-5', 'gpt-5.2') else None,
|
||||
verbosity=verbosity if llm_model in ('gpt-5', 'gpt-5.2') else None
|
||||
)
|
||||
else:
|
||||
print(f"💬 Using standard response generation (no visual context)")
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ async def generate_persona_response(
|
|||
print(f"🎭 Generating persona response for {persona.get('name', 'Unknown')}")
|
||||
print(f" - focus_group_id: {focus_group_id}")
|
||||
print(f" - current_topic: {current_topic[:50]}...")
|
||||
if llm_model == 'gpt-5.2':
|
||||
if llm_model in ('gpt-5', 'gpt-5.2'):
|
||||
print(f" - llm_model: {llm_model} (reasoning_effort: {reasoning_effort or 'medium'}, verbosity: {verbosity or 'medium'}) [using Responses API]")
|
||||
else:
|
||||
print(f" - llm_model: {llm_model or 'default (gemini-3-pro-preview)'}")
|
||||
|
|
|
|||
|
|
@ -53,6 +53,11 @@ SUPPORTED_MODELS = {
|
|||
'gpt-5.2': 'openai'
|
||||
}
|
||||
|
||||
# Aliases for renamed/legacy model IDs stored in the database
|
||||
MODEL_ALIASES = {
|
||||
'gpt-5': 'gpt-5.2',
|
||||
}
|
||||
|
||||
class LLMServiceError(Exception):
|
||||
"""Exception raised for errors in LLM operations."""
|
||||
pass
|
||||
|
|
@ -91,18 +96,32 @@ class LLMService:
|
|||
|
||||
return result.strip()
|
||||
|
||||
@staticmethod
|
||||
def _resolve_model(model_name: Optional[str] = None) -> str:
|
||||
"""
|
||||
Resolve a model name, applying aliases for legacy/renamed models.
|
||||
|
||||
Args:
|
||||
model_name: Optional model name to use. Defaults to the default model.
|
||||
|
||||
Returns:
|
||||
The resolved model name
|
||||
"""
|
||||
actual_model = model_name or DEFAULT_MODEL
|
||||
return MODEL_ALIASES.get(actual_model, actual_model)
|
||||
|
||||
@staticmethod
|
||||
def _get_model_provider(model_name: Optional[str] = None) -> str:
|
||||
"""
|
||||
Get the provider for a given model name.
|
||||
|
||||
|
||||
Args:
|
||||
model_name: Optional model name to use. Defaults to the default model.
|
||||
|
||||
|
||||
Returns:
|
||||
The provider name ('gemini' or 'openai')
|
||||
"""
|
||||
actual_model = model_name or DEFAULT_MODEL
|
||||
actual_model = LLMService._resolve_model(model_name)
|
||||
return SUPPORTED_MODELS.get(actual_model, 'gemini')
|
||||
|
||||
|
||||
|
|
@ -180,7 +199,7 @@ class LLMService:
|
|||
max_retries = 3
|
||||
last_error = None
|
||||
|
||||
actual_model = model_name or DEFAULT_MODEL
|
||||
actual_model = LLMService._resolve_model(model_name)
|
||||
provider = LLMService._get_model_provider(model_name)
|
||||
|
||||
for attempt in range(max_retries):
|
||||
|
|
@ -492,10 +511,10 @@ class LLMService:
|
|||
logger = logging.getLogger(__name__)
|
||||
max_retries = 3
|
||||
last_error = None
|
||||
|
||||
actual_model = model_name or DEFAULT_MODEL
|
||||
|
||||
actual_model = LLMService._resolve_model(model_name)
|
||||
provider = LLMService._get_model_provider(model_name)
|
||||
|
||||
|
||||
logger.info(f"Generating multimodal content with {len(image_paths)} image(s) using {provider} provider")
|
||||
|
||||
for attempt in range(max_retries):
|
||||
|
|
@ -727,9 +746,9 @@ class LLMService:
|
|||
if image_parts:
|
||||
print(f"🎨 Using multimodal generation with {len(image_parts)} images")
|
||||
|
||||
actual_model = model_name or DEFAULT_MODEL
|
||||
actual_model = LLMService._resolve_model(model_name)
|
||||
provider = LLMService._get_model_provider(model_name)
|
||||
|
||||
|
||||
max_retries = 3
|
||||
last_error = None
|
||||
|
||||
|
|
|
|||
|
|
@ -188,8 +188,8 @@ class PersonaModificationService:
|
|||
prompt=final_prompt,
|
||||
temperature=0.3, # Lower temperature for consistent modifications
|
||||
model_name=llm_model,
|
||||
reasoning_effort=reasoning_effort if llm_model == 'gpt-5.2' else None,
|
||||
verbosity=verbosity if llm_model == 'gpt-5.2' else None
|
||||
reasoning_effort=reasoning_effort if llm_model in ('gpt-5', 'gpt-5.2') else None,
|
||||
verbosity=verbosity if llm_model in ('gpt-5', 'gpt-5.2') else None
|
||||
)
|
||||
|
||||
# Parse JSON response
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue