diff --git a/lib/Controller/ChattyLLMController.php b/lib/Controller/ChattyLLMController.php index 3d4c337a..0772d325 100644 --- a/lib/Controller/ChattyLLMController.php +++ b/lib/Controller/ChattyLLMController.php @@ -550,7 +550,7 @@ public function regenerateForSession(int $sessionId, int $messageId): JSONRespon * * @param int $taskId The message generation task ID * @param int $sessionId The chat session ID - * @return JSONResponse|JSONResponse|numeric|string>|null}, array{}>|JSONResponse + * @return JSONResponse|JSONResponse|numeric|string>|null}, array{}>|JSONResponse|JSONResponse * @throws MultipleObjectsReturnedException * @throws \OCP\DB\Exception * @@ -610,7 +610,11 @@ public function checkMessageGenerationTask(int $taskId, int $sessionId): JSONRes } return new JSONResponse($responsePayload, Http::STATUS_EXPECTATION_FAILED); } elseif ($task->getstatus() === Task::STATUS_FAILED || $task->getstatus() === Task::STATUS_CANCELLED) { - return new JSONResponse(['error' => 'task_failed_or_canceled', 'task_status' => $task->getstatus()], Http::STATUS_BAD_REQUEST); + return new JSONResponse([ + 'error' => 'task_failed_or_canceled', + 'task_status' => $task->getstatus(), + 'userFacingErrorMessage' => $task->getUserFacingErrorMessage(), + ], Http::STATUS_BAD_REQUEST); } return new JSONResponse(['error' => 'unknown_error', 'task_status' => $task->getstatus()], Http::STATUS_BAD_REQUEST); } diff --git a/openapi.json b/openapi.json index 37de5735..2bc9573a 100644 --- a/openapi.json +++ b/openapi.json @@ -5052,6 +5052,32 @@ } } }, + "400": { + "description": "Task processing failed", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "string" + }, + "task_status": { + "type": "integer", + "format": "int64" + }, + "userFacingErrorMessage": { + "type": "string", + "nullable": true + } + } + } + } + } + }, "500": { "description": "", "content": { @@ -5118,24 +5144,6 @@ } } }, - "400": { - "description": "Task processing failed", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "error" - ], - "properties": { - "error": { - "type": "string" - } - } - } - } - } - }, "404": { "description": "Session was not found", "content": { diff --git a/src/components/ChattyLLM/ChattyLLMInputForm.vue b/src/components/ChattyLLM/ChattyLLMInputForm.vue index da2b310c..51cda77f 100644 --- a/src/components/ChattyLLM/ChattyLLMInputForm.vue +++ b/src/components/ChattyLLM/ChattyLLMInputForm.vue @@ -529,7 +529,7 @@ export default { } } catch (error) { console.error('checkGenerationTask error:', error) - showError(t('assistant', 'Error generating a response')) + showError(error?.response?.data?.userFacingErrorMessage ?? t('assistant', 'Error generating a response')) } this.streamingMessage = null this.userScrolled = false @@ -945,7 +945,7 @@ export default { } } catch (error) { console.error('scheduleGenerationTask error:', error) - showError(t('assistant', 'Error generating a response')) + showError(error?.response?.data?.userFacingErrorMessage ?? t('assistant', 'Error generating a response')) } finally { this.loading.llmGeneration = false this.loading.llmRunning = false @@ -973,7 +973,7 @@ export default { } } catch (error) { console.error('scheduleRegenerationTask error:', error) - showError(t('assistant', 'Error regenerating a response')) + showError(error?.response?.data?.userFacingErrorMessage ?? t('assistant', 'Error regenerating a response')) } finally { this.loading.llmGeneration = false this.loading.llmRunning = false @@ -1052,7 +1052,7 @@ export default { if (error.response?.status !== 417) { console.error('checkTaskPolling error', error) clearInterval(this.pollMessageGenerationTimerId) - reject(new Error('Message generation task check failed')) + reject(error) } else { console.debug('checkTaskPolling, task is still scheduled or running') this.slowPickup = error.response.data.slow_pickup