davsclaus commented on code in PR #27850:
URL: https://github.com/apache/camel/pull/27850#discussion_r4279077694


##########
components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIDecisionsProducer.java:
##########
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.openai;
+
+import com.openai.models.decisions.DecisionCreateParams;
+import org.apache.camel.Exchange;
+import org.apache.camel.support.DefaultProducer;
+
+/** Sends native Decisions requests without executing tools or applying 
decision policy. */
+public class OpenAIDecisionsProducer extends DefaultProducer {
+    public OpenAIDecisionsProducer(OpenAIEndpoint endpoint) {
+        super(endpoint);
+    }
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        if (!(exchange.getMessage().getBody() instanceof DecisionCreateParams 
request)) {
+            throw new IllegalArgumentException("Decisions requires a 
DecisionCreateParams body");
+        }
+        exchange.getMessage().setBody(((OpenAIEndpoint) 
getEndpoint()).decide(request));

Review Comment:
   The other `camel-openai` producers (`OpenAIProducer`, 
`OpenAIResponsesProducer`, `OpenAIEmbeddingsProducer`, 
`OpenAIModerationProducer`) wrap the call in a GenAI observation through 
`OpenAIGenAiProducerSupport`. This producer does not, so Decisions calls do not 
show up in the shared GenAI spans and metrics.
   
   `Decision` returns `model()` and `usage()` (input/output tokens), so a 
success can be recorded with `GenAiUsage.of(inputTokens, outputTokens, null, 
response.model())`. There is no matching `GenAiOperationName` yet. The enum 
already has Camel-specific values such as `MODERATION`, so a `DECISIONS` value 
would fit the same pattern.
   
   The Semantic adapter path goes through `decide()` without an `Exchange`, so 
wiring the producer first (and maybe the adapter later) would already close 
most of the gap. Could @luigidemasi add this here, or open a follow-up JIRA?



##########
components/camel-ai/camel-openai/src/main/docs/openai-component.adoc:
##########
@@ -30,6 +30,41 @@ Maven users will need to add the following dependency to 
their `pom.xml` for thi
 </dependency>
 ----
 
+== Decisions
+
+`openai:decisions` (also `llm:decisions`) accepts a native
+`com.openai.models.decisions.DecisionCreateParams` body and returns a
+`com.openai.models.decisions.Decision` body. It uses the endpoint's managed 
OpenAI client,
+including credentials, base URL, TLS, proxy, timeout and retry settings.
+Decisions does not initialize configured MCP servers or route tools.

Review Comment:
   The request body carries its own model, and `decide()` does not apply the 
endpoint `model` option. The Semantic adapter does the opposite and uses only 
the endpoint `model`. Maybe say this explicitly:
   
   ```suggestion
   Decisions does not initialize configured MCP servers or route tools.
   The model is taken from the `DecisionCreateParams` body; the endpoint 
`model` option is not applied to this operation.
   ```



##########
components/camel-ai/camel-semantic-openai/src/main/docs/semantic-openai.adoc:
##########
@@ -0,0 +1,215 @@
+= Semantic OpenAI Component
+:doctitle: Semantic OpenAI
+:shortname: semantic-openai
+:artifactid: camel-semantic-openai
+:description: Assess text and images with typed OpenAI Decisions through 
Semantic experts
+:since: 4.24
+:supportlevel: Preview
+:tabs-sync-option:
+
+*Since Camel {since}*
+
+This module supplies an explicit expert for the 
xref:languages:semantic-language.adoc[Semantic language].
+It asks the https://developers.openai.com/api/docs/guides/decisions[OpenAI 
Decisions API]
+for an assessment. The Camel route decides what action to take with that 
assessment.
+It has no routing endpoint of its own. It depends on `camel-semantic` and 
`camel-openai`;
+`camel-openai` remains independently usable and does not depend on Semantic.
+
+[source,xml]
+----
+<dependency>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-semantic-openai</artifactId>
+    <version>x.x.x</version>
+</dependency>
+----
+
+== Register an expert
+
+The adapter uses an `openai:decisions` endpoint's managed client, credentials, 
base URL,
+proxy, TLS, timeout and retry configuration. Configure the component as 
described in
+xref:ROOT:openai-component.adoc[OpenAI]. It does not create a second HTTP 
client or
+initialize route tools or MCP connections for Decisions calls.
+
+[source,properties]
+----
+camel.component.openai.api-key={{env:OPENAI_API_KEY}}
+----
+
+[source,yaml]
+----
+- beans:
+    - name: vision
+      type: org.apache.camel.semantic.openai.OpenAIDecisionsSemanticAdapter
+      properties:
+        endpointUri: "openai:decisions?model=gpt-6-luna"
+        maxImageBytes: 10000000
+- semantic:
+    evaluation:
+      damaged:
+        expert: vision
+        operation: boolean
+        state: "${body}"
+        parameters:
+          instructions: Is the package visibly damaged?
+          threshold: 0.5
+          uncertainty: 0.1
+          uncertaintyPolicy: fail
+- route:
+    from:
+      uri: direct:inspect
+      steps:
+        - setVariable:
+            name: damaged
+            simple: "${semantic('damaged')}"

Review Comment:
   Nit: new YAML examples should use the canonical form with the explicit 
`expression:` wrapper rather than the classic shorthand:
   
   ```suggestion
               expression:
                 simple:
                   expression: "${semantic('damaged')}"
   ```



-- 
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