[
https://issues.apache.org/jira/browse/CAMEL-26211?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18136918#comment-18136918
]
Claus Ibsen commented on CAMEL-26211:
-------------------------------------
PR: https://github.com/apache/camel/pull/29037
1. The cv and audio predictors use getMandatoryBody, so a body without a
converter fails with "Data type is not supported".
2. The nlp predictors convert the body to String, so a byte[] or InputStream
body works.
3. The custom predictors look up the model and translator once, at the first
message, and a missing bean fails with a NoSuchBeanException that names it.
Open question on 3: the lookup is not done when the producer starts, as
proposed. A route with autoStartup(false) still has its producers started with
the context, and the module's local tests bind the model after the context
started; a lookup at producer start breaks that. I recommend keeping the lookup
at the first message.
_Claude Code on behalf of Claus Ibsen (davsclaus)_
> camel-djl - a cv or audio body without a converter reaches the predictor as
> null, and nlp predictors reject bytes and streams
> -----------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-26211
> URL: https://issues.apache.org/jira/browse/CAMEL-26211
> Project: Camel
> Issue Type: Bug
> Components: camel-ai
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Minor
> Fix For: 4.24.0
>
>
> Found while adding the catalog body types of djl (CAMEL-24961, PR #28401).
> h4. 1. A cv or audio body without a converter reaches the predictor as null
> {{AbstractCvZooPredictor.process}} (main 2a465aa4814c, line 41) and
> {{CustomCvPredictor}} (line 49), and the same code in {{ZooAudioPredictor}}
> and {{CustomAudioPredictor}}, read the body with {{getBody(Image.class)}} /
> {{getBody(Audio.class)}} and catch {{TypeConversionException}}. For a String,
> Map, {{BufferedImage}} or null body there is no converter, {{getBody}}
> returns null and the predictor fails with "Could not process input or output"
> instead of "Data type is not supported". Checked on 4.24.0-SNAPSHOT with the
> zoo mlp image classification model.
> Proposed: use {{getMandatoryBody}} (or check for null) so the "Data type is
> not supported" message is given.
> h4. 2. nlp predictors accept only a String body
> {{AbstractNlpZooPredictor}} (line 38) and {{CustomNlpPredictor}} (line 42)
> check {{getBody() instanceof String}}, so a {{byte[]}} or {{InputStream}}
> text body (from file, HTTP or JMS) fails with "Data type is not supported.
> Body should be String". Checked on 4.24.0-SNAPSHOT with the zoo distilbert
> sentiment model.
> Proposed: convert the body with {{getMandatoryBody(String.class)}}.
> h4. 3. Custom predictors look up the model and translator per message
> {{CustomCvPredictor.predict}} (lines 59-62) and the other
> {{Custom*Predictor}} classes look up {{model}} and {{translator}} in the
> registry for every message; a wrong name gives a {{NullPointerException}} at
> the first message instead of an error at startup. Read in the code, not run.
> Proposed: look them up once when the producer starts and fail there with the
> missing bean name.
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)