This is an automated email from the ASF dual-hosted git repository.
apupier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new b69bb4cdc8c5 CAMEL-23749 - replace deprecated methods in openai
component
b69bb4cdc8c5 is described below
commit b69bb4cdc8c563459174bfe6f7a91eac0d7299ff
Author: Aurélien Pupier <[email protected]>
AuthorDate: Tue Jun 16 15:46:29 2026 +0200
CAMEL-23749 - replace deprecated methods in openai component
it remains 2 calls to deprecated methods but it is linked to a specific
option provided in component (sse transportType). Now mentioning that it
is deprecated at Camel component level to be able to remove it later on.
Signed-off-by: Aurélien Pupier <[email protected]>
---
.../apache/camel/catalog/components/openai.json | 2 +-
.../org/apache/camel/component/openai/openai.json | 2 +-
.../src/main/docs/openai-component.adoc | 2 +-
.../component/openai/OpenAIConfiguration.java | 2 +-
.../camel/component/openai/OpenAIEndpoint.java | 2 +-
.../camel/component/openai/OpenAIProducer.java | 2 +-
.../component/openai/McpToolConverterTest.java | 29 ++++++++--------------
.../openai/OpenAIProducerMcpMockTest.java | 6 ++---
.../ROOT/pages/camel-4x-upgrade-guide-4_21.adoc | 2 ++
.../endpoint/dsl/OpenAIEndpointBuilderFactory.java | 20 +++++++--------
10 files changed, 30 insertions(+), 39 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/openai.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/openai.json
index 41ec05197acd..f6ebf020cefe 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/openai.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/openai.json
@@ -99,7 +99,7 @@
"maxToolIterations": { "index": 20, "kind": "parameter", "displayName":
"Max Tool Iterations", "group": "producer", "label": "", "required": false,
"type": "integer", "javaType": "int", "deprecated": false, "deprecationNote":
"", "autowired": false, "secret": false, "defaultValue": 50,
"configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration",
"configurationField": "configuration", "description": "Maximum number of tool
call loop iterations to prevent infinite loops" },
"mcpProtocolVersions": { "index": 21, "kind": "parameter", "displayName":
"Mcp Protocol Versions", "group": "producer", "label": "", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false,
"configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration",
"configurationField": "configuration", "description": "Comma-separated list of
MCP protocol versions to advertise when connect [...]
"mcpReconnect": { "index": 22, "kind": "parameter", "displayName": "Mcp
Reconnect", "group": "producer", "label": "", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "defaultValue": true,
"configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration",
"configurationField": "configuration", "description": "Automatically reconnect
to MCP servers when a tool call fails due to a t [...]
- "mcpServer": { "index": 23, "kind": "parameter", "displayName": "Mcp
Server", "group": "producer", "label": "", "required": false, "type": "object",
"javaType": "java.util.Map<java.lang.String, java.lang.Object>", "prefix":
"mcpServer.", "multiValue": true, "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField":
"configuration", "description": "MCP (Model Cont [...]
+ "mcpServer": { "index": 23, "kind": "parameter", "displayName": "Mcp
Server", "group": "producer", "label": "", "required": false, "type": "object",
"javaType": "java.util.Map<java.lang.String, java.lang.Object>", "prefix":
"mcpServer.", "multiValue": true, "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField":
"configuration", "description": "MCP (Model Cont [...]
"mcpTimeout": { "index": 24, "kind": "parameter", "displayName": "Mcp
Timeout", "group": "producer", "label": "", "required": false, "type":
"integer", "javaType": "int", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "defaultValue": 20, "configurationClass":
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField":
"configuration", "description": "Timeout in seconds for MCP tool call requests.
Applies to all MCP operations inclu [...]
"model": { "index": 25, "kind": "parameter", "displayName": "Model",
"group": "producer", "label": "", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField":
"configuration", "description": "The model to use for chat completion" },
"outputClass": { "index": 26, "kind": "parameter", "displayName": "Output
Class", "group": "producer", "label": "", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField":
"configuration", "description": "Fully qualified class name for structured
output using response format" },
diff --git
a/components/camel-ai/camel-openai/src/generated/resources/META-INF/org/apache/camel/component/openai/openai.json
b/components/camel-ai/camel-openai/src/generated/resources/META-INF/org/apache/camel/component/openai/openai.json
index 41ec05197acd..f6ebf020cefe 100644
---
a/components/camel-ai/camel-openai/src/generated/resources/META-INF/org/apache/camel/component/openai/openai.json
+++
b/components/camel-ai/camel-openai/src/generated/resources/META-INF/org/apache/camel/component/openai/openai.json
@@ -99,7 +99,7 @@
"maxToolIterations": { "index": 20, "kind": "parameter", "displayName":
"Max Tool Iterations", "group": "producer", "label": "", "required": false,
"type": "integer", "javaType": "int", "deprecated": false, "deprecationNote":
"", "autowired": false, "secret": false, "defaultValue": 50,
"configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration",
"configurationField": "configuration", "description": "Maximum number of tool
call loop iterations to prevent infinite loops" },
"mcpProtocolVersions": { "index": 21, "kind": "parameter", "displayName":
"Mcp Protocol Versions", "group": "producer", "label": "", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false,
"configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration",
"configurationField": "configuration", "description": "Comma-separated list of
MCP protocol versions to advertise when connect [...]
"mcpReconnect": { "index": 22, "kind": "parameter", "displayName": "Mcp
Reconnect", "group": "producer", "label": "", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "defaultValue": true,
"configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration",
"configurationField": "configuration", "description": "Automatically reconnect
to MCP servers when a tool call fails due to a t [...]
- "mcpServer": { "index": 23, "kind": "parameter", "displayName": "Mcp
Server", "group": "producer", "label": "", "required": false, "type": "object",
"javaType": "java.util.Map<java.lang.String, java.lang.Object>", "prefix":
"mcpServer.", "multiValue": true, "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField":
"configuration", "description": "MCP (Model Cont [...]
+ "mcpServer": { "index": 23, "kind": "parameter", "displayName": "Mcp
Server", "group": "producer", "label": "", "required": false, "type": "object",
"javaType": "java.util.Map<java.lang.String, java.lang.Object>", "prefix":
"mcpServer.", "multiValue": true, "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField":
"configuration", "description": "MCP (Model Cont [...]
"mcpTimeout": { "index": 24, "kind": "parameter", "displayName": "Mcp
Timeout", "group": "producer", "label": "", "required": false, "type":
"integer", "javaType": "int", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "defaultValue": 20, "configurationClass":
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField":
"configuration", "description": "Timeout in seconds for MCP tool call requests.
Applies to all MCP operations inclu [...]
"model": { "index": 25, "kind": "parameter", "displayName": "Model",
"group": "producer", "label": "", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField":
"configuration", "description": "The model to use for chat completion" },
"outputClass": { "index": 26, "kind": "parameter", "displayName": "Output
Class", "group": "producer", "label": "", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField":
"configuration", "description": "Fully qualified class name for structured
output using response format" },
diff --git
a/components/camel-ai/camel-openai/src/main/docs/openai-component.adoc
b/components/camel-ai/camel-openai/src/main/docs/openai-component.adoc
index 4e6a7379f358..d1f4f64dec47 100644
--- a/components/camel-ai/camel-openai/src/main/docs/openai-component.adoc
+++ b/components/camel-ai/camel-openai/src/main/docs/openai-component.adoc
@@ -954,7 +954,7 @@ from("direct:chat")
+ "&mcpServer.api.url=http://localhost:9090/mcp");
----
-==== SSE Transport
+==== SSE Transport (Deprecated)
[source,java]
----
diff --git
a/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIConfiguration.java
b/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIConfiguration.java
index 076996c226a9..3671f524b27d 100644
---
a/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIConfiguration.java
+++
b/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIConfiguration.java
@@ -118,7 +118,7 @@ public class OpenAIConfiguration implements Cloneable {
@UriParam(prefix = "mcpServer.", multiValue = true)
@Metadata(description = "MCP (Model Context Protocol) server
configurations. "
- + "Define servers using prefix notation:
mcpServer.<name>.transportType=stdio|sse|streamableHttp, "
+ + "Define servers using prefix notation:
mcpServer.<name>.transportType=stdio|sse|streamableHttp, (Note that sse is
deprecated) "
+ "mcpServer.<name>.command=<cmd> (stdio),
mcpServer.<name>.args=<comma-separated> (stdio), "
+ "mcpServer.<name>.url=<url>
(sse/streamableHttp), "
+ "mcpServer.<name>.oauthProfile=<profile> (OAuth
profile for HTTP auth, requires camel-oauth)")
diff --git
a/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIEndpoint.java
b/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIEndpoint.java
index 530bd5794042..b81d54ccff36 100644
---
a/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIEndpoint.java
+++
b/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIEndpoint.java
@@ -352,7 +352,7 @@ public class OpenAIEndpoint extends DefaultEndpoint {
}
McpSchema.CallToolResult callTool(McpSyncClient mcpClient, String
toolName, Map<String, Object> argsMap) {
- McpSchema.CallToolRequest request = new
McpSchema.CallToolRequest(toolName, argsMap);
+ McpSchema.CallToolRequest request = new
McpSchema.CallToolRequest(toolName, argsMap, null);
try {
return mcpClient.callTool(request);
} catch (McpTransportException e) {
diff --git
a/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIProducer.java
b/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIProducer.java
index ea86feb2923c..ab9cf76665e9 100644
---
a/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIProducer.java
+++
b/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIProducer.java
@@ -153,7 +153,7 @@ public class OpenAIProducer extends DefaultAsyncProducer {
paramsBuilder.topP(topP);
}
if (maxTokens != null) {
- paramsBuilder.maxTokens(maxTokens.longValue());
+ paramsBuilder.maxCompletionTokens(maxTokens.longValue());
}
// Structured output handling
diff --git
a/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/McpToolConverterTest.java
b/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/McpToolConverterTest.java
index 8c9883f5c403..d496fdfad10b 100644
---
a/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/McpToolConverterTest.java
+++
b/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/McpToolConverterTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.openai;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -31,14 +32,11 @@ class McpToolConverterTest {
@Test
void convertFullSchema() {
- McpSchema.Tool tool = McpSchema.Tool.builder()
- .name("get_weather")
+ McpSchema.Tool tool = McpSchema.Tool.builder("get_weather",
+ Map.of("type", "object",
+ "properties", Map.of("city", Map.of("type", "string",
"description", "City name"),
+ "required", List.of("city"))))
.description("Get the weather for a location")
- .inputSchema(new McpSchema.JsonSchema(
- "object",
- Map.of("city", Map.of("type", "string", "description",
"City name")),
- List.of("city"),
- null, null, null))
.build();
List<ChatCompletionFunctionTool> result =
McpToolConverter.convert(List.of(tool));
@@ -53,8 +51,7 @@ class McpToolConverterTest {
@Test
void convertWithoutInputSchema() {
- McpSchema.Tool tool = McpSchema.Tool.builder()
- .name("no_params_tool")
+ McpSchema.Tool tool = McpSchema.Tool.builder("no_params_tool",
Collections.emptyMap())
.description("A tool with no parameters")
.build();
@@ -67,9 +64,8 @@ class McpToolConverterTest {
@Test
void convertWithoutDescription() {
- McpSchema.Tool tool = McpSchema.Tool.builder()
+ McpSchema.Tool tool = McpSchema.Tool.builder("bare_tool",
Map.of("type", "object"))
.name("bare_tool")
- .inputSchema(new McpSchema.JsonSchema("object", null, null,
null, null, null))
.build();
List<ChatCompletionFunctionTool> result =
McpToolConverter.convert(List.of(tool));
@@ -80,18 +76,13 @@ class McpToolConverterTest {
@Test
void convertMultipleTools() {
- McpSchema.Tool tool1 = McpSchema.Tool.builder()
- .name("tool_a")
+ McpSchema.Tool tool1 = McpSchema.Tool.builder("tool_a",
Collections.emptyMap())
.description("First tool")
.build();
- McpSchema.Tool tool2 = McpSchema.Tool.builder()
- .name("tool_b")
+ McpSchema.Tool tool2 = McpSchema.Tool
+ .builder("tool_b", Map.of("type", "object", "properties",
Map.of("x", Map.of("type", "number"))))
.description("Second tool")
- .inputSchema(new McpSchema.JsonSchema(
- "object",
- Map.of("x", Map.of("type", "number")),
- null, null, null, null))
.build();
List<ChatCompletionFunctionTool> result =
McpToolConverter.convert(List.of(tool1, tool2));
diff --git
a/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/OpenAIProducerMcpMockTest.java
b/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/OpenAIProducerMcpMockTest.java
index 5f24e1327e5e..ecbd39dd1c5b 100644
---
a/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/OpenAIProducerMcpMockTest.java
+++
b/components/camel-ai/camel-openai/src/test/java/org/apache/camel/component/openai/OpenAIProducerMcpMockTest.java
@@ -99,7 +99,7 @@ public class OpenAIProducerMcpMockTest extends
CamelTestSupport {
private McpSyncClient createMockMcpClient(String toolName, String
resultText) {
McpSyncClient client = mock(McpSyncClient.class);
McpSchema.CallToolResult result = McpSchema.CallToolResult.builder()
- .content(List.of(new McpSchema.TextContent(resultText)))
+ .content(List.of(new McpSchema.TextContent(null, resultText,
null)))
.isError(false)
.build();
when(client.callTool(any(McpSchema.CallToolRequest.class))).thenReturn(result);
@@ -124,10 +124,8 @@ public class OpenAIProducerMcpMockTest extends
CamelTestSupport {
// Convert tool names to OpenAI function tools via McpToolConverter
List<McpSchema.Tool> mcpTools = toolClients.keySet().stream()
- .map(name -> McpSchema.Tool.builder()
- .name(name)
+ .map(name -> McpSchema.Tool.builder(name, Map.of("type",
"object"))
.description("Mock tool: " + name)
- .inputSchema(new McpSchema.JsonSchema("object", null,
null, null, null, null))
.build())
.toList();
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc
index 7f6cb3af3851..4c3d8e5d43a1 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc
@@ -573,6 +573,8 @@ fail to detect the type on some platforms. A `byte[]` or
`InputStream` body whos
sent to the model as a base64-encoded image instead of being converted to
text; bodies without image MIME type metadata
keep the previous text behavior. XML and JSON files (`application/xml`,
`application/json`) are treated as text prompts.
+The `sse` `transportType` is deprecated. it is recommended to switch to
`streamableHttp`.
+
=== camel-stomp removal
Camel stomp was deprecated with Camel 4.17. The stomp library didn't have any
activities in the last 10 years. The component is now removed.
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/OpenAIEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/OpenAIEndpointBuilderFactory.java
index c708946d7d32..3385218d96e3 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/OpenAIEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/OpenAIEndpointBuilderFactory.java
@@ -550,11 +550,11 @@ public interface OpenAIEndpointBuilderFactory {
/**
* MCP (Model Context Protocol) server configurations. Define servers
* using prefix notation:
- * mcpServer..transportType=stdiossestreamableHttp, mcpServer..command=
- * (stdio), mcpServer..args= (stdio), mcpServer..url=
- * (sse/streamableHttp), mcpServer..oauthProfile= (OAuth profile for
- * HTTP auth, requires camel-oauth). This is a multi-value option with
- * prefix: mcpServer.
+ * mcpServer..transportType=stdiossestreamableHttp, (Note that sse is
+ * deprecated) mcpServer..command= (stdio), mcpServer..args= (stdio),
+ * mcpServer..url= (sse/streamableHttp), mcpServer..oauthProfile=
(OAuth
+ * profile for HTTP auth, requires camel-oauth). This is a multi-value
+ * option with prefix: mcpServer.
*
* The option is a: <code>java.util.Map<java.lang.String,
* java.lang.Object></code> type.
@@ -575,11 +575,11 @@ public interface OpenAIEndpointBuilderFactory {
/**
* MCP (Model Context Protocol) server configurations. Define servers
* using prefix notation:
- * mcpServer..transportType=stdiossestreamableHttp, mcpServer..command=
- * (stdio), mcpServer..args= (stdio), mcpServer..url=
- * (sse/streamableHttp), mcpServer..oauthProfile= (OAuth profile for
- * HTTP auth, requires camel-oauth). This is a multi-value option with
- * prefix: mcpServer.
+ * mcpServer..transportType=stdiossestreamableHttp, (Note that sse is
+ * deprecated) mcpServer..command= (stdio), mcpServer..args= (stdio),
+ * mcpServer..url= (sse/streamableHttp), mcpServer..oauthProfile=
(OAuth
+ * profile for HTTP auth, requires camel-oauth). This is a multi-value
+ * option with prefix: mcpServer.
*
* The option is a: <code>java.util.Map<java.lang.String,
* java.lang.Object></code> type.