fix(OpenAiAPIService): Throw UserFacingProcessingException if service is not responding properly#380
Conversation
… is not responding properly Signed-off-by: Marcel Klehr <mklehr@gmx.net>
3724466 to
7bef1b3
Compare
There was a problem hiding this comment.
The UserFacingProcessingException is caught in the providers and RuntimeException is thrown instead. Check the catch block at the end of TextToTextProvider for example. We should probably make a special case and let UserFacingProcessingException propagate to the upper level.
Naive fix:
} catch (Exception $e) {
if ($e instanceof UserFacingProcessingException) {
throw $e;
}
throw new RuntimeException('OpenAI/LocalAI request failed: ' . $e->getMessage());
}|
or maybe } catch (UserFacingProcessingException $e) {
throw $e;
} catch (Exception $e) {
throw new RuntimeException('OpenAI/LocalAI request failed: ' . $e->getMessage());
} |
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
|
I'm not bothering to fix psalm. Julien's PR does that already. |
| throw new RuntimeException('Too many files given. Max is 500'); | ||
| throw new ProcessingException('Too many files given. Max is 500'); |
There was a problem hiding this comment.
maybe qualifies for UserFacingProcessingException
There was a problem hiding this comment.
Can be a different PR, let's try to not bloat up this one too much
| throw new RuntimeException('Filesize of input files too large. Max is 50MB'); | ||
| throw new ProcessingException('Filesize of input files too large. Max is 50MB'); |
| throw new RuntimeException('Invalid input file type ' . $fileType); | ||
| throw new ProcessingException('Invalid input file type ' . $fileType); |
There was a problem hiding this comment.
not too sure about this one, but could be harmless if the user sees it anyway
| throw new RuntimeException('Invalid input file type for OpenAI ' . $fileType); | ||
| throw new ProcessingException('Invalid input file type for OpenAI ' . $fileType); |
There was a problem hiding this comment.
this too perhaps if the above is done
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
🤖 AI (if applicable)