Update AI model defaults and tiers
This commit is contained in:
@@ -11,6 +11,7 @@ from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy import and_, select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.core.config import get_settings
|
||||
from app.database import get_db
|
||||
from app.models.item import Item
|
||||
from app.schemas.ai import (
|
||||
@@ -21,6 +22,7 @@ from app.schemas.ai import (
|
||||
AIStatsResponse,
|
||||
)
|
||||
from app.services.ai_generation import (
|
||||
SUPPORTED_MODELS,
|
||||
generate_question,
|
||||
get_ai_stats,
|
||||
save_ai_question,
|
||||
@@ -28,6 +30,7 @@ from app.services.ai_generation import (
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
settings = get_settings()
|
||||
|
||||
router = APIRouter(prefix="/admin/ai", tags=["admin", "ai-generation"])
|
||||
|
||||
@@ -63,14 +66,15 @@ async def generate_preview(
|
||||
|
||||
- **basis_item_id**: ID of the sedang-level question to base generation on
|
||||
- **target_level**: Target difficulty (mudah/sulit)
|
||||
- **ai_model**: OpenRouter model to use (default: qwen/qwen-2.5-coder-32b-instruct)
|
||||
- **ai_model**: OpenRouter model to use (default: qwen/qwen2.5-32b-instruct)
|
||||
"""
|
||||
# Validate AI model
|
||||
if not validate_ai_model(request.ai_model):
|
||||
supported = ", ".join(SUPPORTED_MODELS.keys())
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"Unsupported AI model: {request.ai_model}. "
|
||||
f"Supported models: qwen/qwen-2.5-coder-32b-instruct, meta-llama/llama-3.3-70b-instruct",
|
||||
f"Supported models: {supported}",
|
||||
)
|
||||
|
||||
# Fetch basis item
|
||||
@@ -279,14 +283,19 @@ async def list_models() -> dict:
|
||||
return {
|
||||
"models": [
|
||||
{
|
||||
"id": "qwen/qwen-2.5-coder-32b-instruct",
|
||||
"name": "Qwen 2.5 Coder 32B",
|
||||
"description": "Fast and efficient model for question generation",
|
||||
"id": settings.OPENROUTER_MODEL_CHEAP,
|
||||
"name": "Mistral Small 4",
|
||||
"description": "Cheap and fast option for routine variant generation",
|
||||
},
|
||||
{
|
||||
"id": "meta-llama/llama-3.3-70b-instruct",
|
||||
"id": settings.OPENROUTER_MODEL_QWEN,
|
||||
"name": "Qwen 2.5 32B Instruct",
|
||||
"description": "Balanced default for structured soal generation",
|
||||
},
|
||||
{
|
||||
"id": settings.OPENROUTER_MODEL_LLAMA,
|
||||
"name": "Llama 3.3 70B",
|
||||
"description": "High-quality model with better reasoning",
|
||||
"description": "Premium fallback when you want better quality over cost",
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user