Refactor AI framework to use IntegrationSettings exclusively for model configuration

- Removed hardcoded model defaults and the MODEL_CONFIG dictionary.
- Updated get_model_config() to require an account parameter and raise clear errors if IntegrationSettings are not configured.
- Eliminated unused helper functions: get_model(), get_max_tokens(), and get_temperature().
- Improved error handling to provide specific messages for missing account or model configurations.
- Cleaned up orphan exports in __init__.py to maintain a streamlined codebase.
This commit is contained in:
IGNY8 VPS (Salman)
2025-11-16 12:23:43 +00:00
parent 8908c11c86
commit 3a41ba99bb
6 changed files with 440 additions and 1629 deletions

View File

@@ -48,6 +48,15 @@ Each entry follows this format:
- **API Documentation**: Updated Swagger/ReDoc description to include all public endpoints
- Added `/api/v1/system/ping/` to public endpoints list
- Updated schema extensions to properly tag ping endpoint
- **AI Framework Refactoring**: Removed hardcoded model defaults, IntegrationSettings is now the single source of truth
- Removed `MODEL_CONFIG` dictionary with hardcoded defaults
- Removed Django settings `DEFAULT_AI_MODEL` fallback
- `get_model_config()` now requires `account` parameter and raises clear errors if IntegrationSettings not configured
- All AI functions now require account-specific model configuration
- Removed orphan code: `get_model()`, `get_max_tokens()`, `get_temperature()` helper functions
- Removed unused exports from `__init__.py`: `register_function`, `list_functions`, `get_model`, `get_max_tokens`, `get_temperature`
- **Impact**: Each account must configure their own AI models in IntegrationSettings
- **Documentation**: See `backend/igny8_core/ai/REFACTORING-IMPLEMENTED.md` for complete details
### Fixed
- Keyword edit form now correctly populates existing values
@@ -59,10 +68,22 @@ Each entry follows this format:
- `generate_image()`, `create()`, `save_settings()` methods now use unified format
- `get_image_generation_settings()` and `task_progress()` methods now use unified format
- All error responses now include `request_id` and follow unified format
- Fixed OpenAI integration endpoint error handling - invalid API keys now return 400 (Bad Request) instead of 401 (Unauthorized)
- **Frontend Components**: Updated to work with unified format
- `ValidationCard.tsx` - Removed dual-format handling, now works with extracted data
- `Integration.tsx` - Simplified to work with unified format
- `ImageGenerationCard.tsx` - Updated to work with extracted data format
- **Frontend Authentication**: Fixed `getAuthToken is not defined` error in `authStore.ts`
- Updated `refreshUser()` to use `fetchAPI()` instead of manual fetch with `getAuthToken()`
- Removed error throwing from catch block to prevent error accumulation
- **Frontend Error Handling**: Fixed console error accumulation
- `ResourceDebugOverlay.tsx` now silently ignores 404 errors for request-metrics endpoint
- Removed error throwing from `refreshUser()` catch block to prevent error spam
- **AI Framework Error Handling**: Improved error messages and exception handling
- `AIEngine._handle_error()` now preserves exception types for better error messages
- All AI function errors now include proper `error_type` (ConfigurationError, AccountNotFound, etc.)
- Fixed "Task failed - exception details unavailable" by improving error type preservation
- Error messages now clearly indicate when IntegrationSettings are missing or misconfigured
---