Croway opened a new pull request, #30450:
URL: https://github.com/apache/camel/pull/30450

   [CAMEL-27245](https://issues.apache.org/jira/browse/CAMEL-27245)
   
   ## Description
   
   Spring AI 2.1.0 adds the `DecisionModel` API: it answers yes/no, choice and 
score questions about an input and reports the probability of each answer 
(`OpenAiDecisionModel`, `OllamaDecisionModel` with `d1-omni:600m`, 
`SystemOneDecisionModel`). It is faster and cheaper than asking a chat model, 
and the probabilities let the route decide how sure the model must be. That 
fits routing: classify a message for a Content-Based Router, or stop a prompt 
injection before it reaches a chat model.
   
   New component `spring-ai-decision` (producer, preview, 
`camel-spring-ai-decision` under `camel-spring-parent/camel-spring-ai`):
   
   - `spring-ai-decision:name` with an autowired `decisionModel`. The name is 
the name of the question.
   - One question from the options: `questionType` (`YES_NO`, the default, 
`CHOICE` or `SCORE`), `question`, `choices`, `levels`, `whenYes`, `whenNo`; 
`threshold` (default 0.5) for a yes; `decisionQuestion` for a question built in 
code, with descriptions of its options or levels; `model`. The options are 
checked when the producer starts.
   - The body is the input: text, a `Map` of named fields, a `List` of messages 
or of message parts (images), or a `DecisionInput`. A `DecisionPrompt` body is 
sent as it is, for several questions.
   - The body is left unchanged. The answer goes in 
`CamelSpringAiDecisionAnswer` (`Boolean` for yes/no, the name of the option or 
level), its probability in `CamelSpringAiDecisionProbability`, all 
probabilities in `CamelSpringAiDecisionProbabilities`, and the response in 
`CamelSpringAiDecisionResponse`, so a route can `choice()` on them.
   - A refused question fails the exchange with 
`SpringAiDecisionRefusalException`, so a guardrail never lets a message 
through, as `OpenAIDecisionRefusalException` in camel-openai.
   - Documentation with a routing example and a guardrail example in Java and 
YAML, and the configuration of the Ollama, OpenAI and System One models.
   - Wiring and generated files: module list, `MojoHelper`, parent and BOM, 
`camel-allcomponents`, catalog, camel-main, endpoint and component DSL, docs 
nav.
   
   The camel-spring-boot starter follows in camel-spring-boot.
   
   ## Tests
   
   - `SpringAiDecisionProducerTest` (23), `SpringAiDecisionRouteTest` (4: 
choice routing, the documented guardrail, the probability map, reading each 
answer of a `DecisionPrompt` with Simple), `SpringAiDecisionWithoutModelTest` 
(1), with a stub `DecisionModel`: 28 tests, all passing.
   - `SpringAiDecisionOllamaIT` asks the questions of the Spring AI 
documentation to `d1-omni:600m`. It needs Ollama 0.40.4 or later with that 
model, and was not run locally.
   
   _Claude Code on behalf of Croway_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to