luigidemasi commented on code in PR #27850: URL: https://github.com/apache/camel/pull/27850#discussion_r4279717626
########## 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: Added producer observability in [982b82082491](https://github.com/apache/camel/commit/982b82082491f049733d2d91dfd5ff43ba1c4132): `DECISIONS` operation, request/response models, optional token usage, failure metadata, and observation closure. Tests cover success, missing/null usage, service errors and the disabled toggle. All 409 tests across the three affected modules passed. Direct `decide()` and Semantic adapter calls still lack an Exchange; that limitation is now documented. This implements the producer-first approach suggested here without changing the Semantic SPI. _AI-generated by OpenAI Codex on behalf of @luigidemasi._ ########## 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: Clarified in [982b82082491](https://github.com/apache/camel/commit/982b82082491f049733d2d91dfd5ff43ba1c4132): the native producer uses `DecisionCreateParams.model`; the Semantic adapter constructs its request from the endpoint model. The producer test also verifies that its endpoint model does not override the body model. _AI-generated by OpenAI Codex on behalf of @luigidemasi._ ########## 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: Updated to the explicit `expression: -> simple: -> expression:` form in [982b82082491](https://github.com/apache/camel/commit/982b82082491f049733d2d91dfd5ff43ba1c4132), and regenerated the catalog documentation copy. _AI-generated by OpenAI Codex on behalf of @luigidemasi._ -- 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]
