Skip to content

Commit 274f656

Browse files
loop9xibek
andauthored
camel-openai: remove temperature default and add extra request params (#20735)
Co-authored-by: Ivo Bek <bekivo@gmail.com>
1 parent f67cf93 commit 274f656

File tree

6 files changed

+111
-22
lines changed

6 files changed

+111
-22
lines changed

components/camel-ai/camel-openai/src/generated/java/org/apache/camel/component/openai/OpenAIEndpointConfigurer.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class OpenAIEndpointConfigurer extends PropertyConfigurerSupport implemen
2323
public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
2424
OpenAIEndpoint target = (OpenAIEndpoint) obj;
2525
switch (ignoreCase ? name.toLowerCase() : name) {
26+
case "additionalbodyproperty":
27+
case "additionalBodyProperty": target.getConfiguration().setAdditionalBodyProperty(property(camelContext, java.util.Map.class, value)); return true;
2628
case "apikey":
2729
case "apiKey": target.getConfiguration().setApiKey(property(camelContext, java.lang.String.class, value)); return true;
2830
case "baseurl":
@@ -59,6 +61,8 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj
5961
@Override
6062
public Class<?> getOptionType(String name, boolean ignoreCase) {
6163
switch (ignoreCase ? name.toLowerCase() : name) {
64+
case "additionalbodyproperty":
65+
case "additionalBodyProperty": return java.util.Map.class;
6266
case "apikey":
6367
case "apiKey": return java.lang.String.class;
6468
case "baseurl":
@@ -96,6 +100,8 @@ public Class<?> getOptionType(String name, boolean ignoreCase) {
96100
public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
97101
OpenAIEndpoint target = (OpenAIEndpoint) obj;
98102
switch (ignoreCase ? name.toLowerCase() : name) {
103+
case "additionalbodyproperty":
104+
case "additionalBodyProperty": return target.getConfiguration().getAdditionalBodyProperty();
99105
case "apikey":
100106
case "apiKey": return target.getConfiguration().getApiKey();
101107
case "baseurl":
@@ -128,5 +134,14 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
128134
default: return null;
129135
}
130136
}
137+
138+
@Override
139+
public Object getCollectionValueType(Object target, String name, boolean ignoreCase) {
140+
switch (ignoreCase ? name.toLowerCase() : name) {
141+
case "additionalbodyproperty":
142+
case "additionalBodyProperty": return java.lang.Object.class;
143+
default: return null;
144+
}
145+
}
131146
}
132147

components/camel-ai/camel-openai/src/generated/java/org/apache/camel/component/openai/OpenAIEndpointUriFactory.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ public class OpenAIEndpointUriFactory extends org.apache.camel.support.component
2323
private static final Set<String> SECRET_PROPERTY_NAMES;
2424
private static final Map<String, String> MULTI_VALUE_PREFIXES;
2525
static {
26-
Set<String> props = new HashSet<>(17);
26+
Set<String> props = new HashSet<>(18);
27+
props.add("additionalBodyProperty");
2728
props.add("apiKey");
2829
props.add("baseUrl");
2930
props.add("conversationHistoryProperty");
@@ -45,7 +46,9 @@ public class OpenAIEndpointUriFactory extends org.apache.camel.support.component
4546
Set<String> secretProps = new HashSet<>(1);
4647
secretProps.add("apiKey");
4748
SECRET_PROPERTY_NAMES = Collections.unmodifiableSet(secretProps);
48-
MULTI_VALUE_PREFIXES = Collections.emptyMap();
49+
Map<String, String> prefixes = new HashMap<>(1);
50+
prefixes.put("additionalBodyProperty", "additionalBodyProperty.");
51+
MULTI_VALUE_PREFIXES = Collections.unmodifiableMap(prefixes);
4952
}
5053

5154
@Override

components/camel-ai/camel-openai/src/generated/resources/META-INF/org/apache/camel/component/openai/openai.json

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,22 @@
3232
},
3333
"properties": {
3434
"operation": { "index": 0, "kind": "path", "displayName": "Operation", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation to perform (currently only chat-completion is supported)" },
35-
"apiKey": { "index": 1, "kind": "parameter", "displayName": "Api Key", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "OpenAI API key. Can also be set via OPENAI_API_KEY environment variable." },
36-
"baseUrl": { "index": 2, "kind": "parameter", "displayName": "Base Url", "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": "Base URL for OpenAI API. Defaults to OpenAI's official endpoint. Can be used for local or third-party providers." },
37-
"conversationHistoryProperty": { "index": 3, "kind": "parameter", "displayName": "Conversation History Property", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "CamelOpenAIConversationHistory", "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "Exchange property name for storing conversation history" },
38-
"conversationMemory": { "index": 4, "kind": "parameter", "displayName": "Conversation Memory", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "Enable conversation memory per Exchange" },
39-
"developerMessage": { "index": 5, "kind": "parameter", "displayName": "Developer Message", "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": "Developer message to prepend before user messages" },
40-
"jsonSchema": { "index": 6, "kind": "parameter", "displayName": "Json Schema", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "JSON schema for structured output validation" },
41-
"maxTokens": { "index": 7, "kind": "parameter", "displayName": "Max Tokens", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "Maximum number of tokens to generate" },
42-
"model": { "index": 8, "kind": "parameter", "displayName": "Model", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "gpt-5", "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "The model to use for chat completion" },
43-
"outputClass": { "index": 9, "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" },
44-
"storeFullResponse": { "index": 10, "kind": "parameter", "displayName": "Store Full Response", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "Store the full response in the exchange property 'CamelOpenAIResponse' in non-streaming mode" },
45-
"streaming": { "index": 11, "kind": "parameter", "displayName": "Streaming", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "Enable streaming responses" },
46-
"systemMessage": { "index": 12, "kind": "parameter", "displayName": "System Message", "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": "System message to prepend. When set and conversationMemory is enabled, the conversation history is reset." },
47-
"temperature": { "index": 13, "kind": "parameter", "displayName": "Temperature", "group": "producer", "label": "", "required": false, "type": "number", "javaType": "java.lang.Double", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "1.0", "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "Temperature for response generation (0.0 to 2.0)" },
48-
"topP": { "index": 14, "kind": "parameter", "displayName": "Top P", "group": "producer", "label": "", "required": false, "type": "number", "javaType": "java.lang.Double", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "Top P for response generation (0.0 to 1.0)" },
49-
"userMessage": { "index": 15, "kind": "parameter", "displayName": "User Message", "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": "Default user message text to use when no prompt is provided" },
50-
"lazyStartProducer": { "index": 16, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." }
35+
"additionalBodyProperty": { "index": 1, "kind": "parameter", "displayName": "Additional Body Property", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "java.util.Map<java.lang.String, java.lang.Object>", "prefix": "additionalBodyProperty.", "multiValue": true, "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "Additional JSON properties to include in the request body (e.g. additionalBodyProperty.traceId=123). This is a multi-value option with prefix: additionalBodyProperty." },
36+
"apiKey": { "index": 2, "kind": "parameter", "displayName": "Api Key", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "OpenAI API key. Can also be set via OPENAI_API_KEY environment variable." },
37+
"baseUrl": { "index": 3, "kind": "parameter", "displayName": "Base Url", "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": "Base URL for OpenAI API. Defaults to OpenAI's official endpoint. Can be used for local or third-party providers." },
38+
"conversationHistoryProperty": { "index": 4, "kind": "parameter", "displayName": "Conversation History Property", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "CamelOpenAIConversationHistory", "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "Exchange property name for storing conversation history" },
39+
"conversationMemory": { "index": 5, "kind": "parameter", "displayName": "Conversation Memory", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "Enable conversation memory per Exchange" },
40+
"developerMessage": { "index": 6, "kind": "parameter", "displayName": "Developer Message", "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": "Developer message to prepend before user messages" },
41+
"jsonSchema": { "index": 7, "kind": "parameter", "displayName": "Json Schema", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "JSON schema for structured output validation" },
42+
"maxTokens": { "index": 8, "kind": "parameter", "displayName": "Max Tokens", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "Maximum number of tokens to generate" },
43+
"model": { "index": 9, "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" },
44+
"outputClass": { "index": 10, "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" },
45+
"storeFullResponse": { "index": 11, "kind": "parameter", "displayName": "Store Full Response", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "Store the full response in the exchange property 'CamelOpenAIResponse' in non-streaming mode" },
46+
"streaming": { "index": 12, "kind": "parameter", "displayName": "Streaming", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "Enable streaming responses" },
47+
"systemMessage": { "index": 13, "kind": "parameter", "displayName": "System Message", "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": "System message to prepend. When set and conversationMemory is enabled, the conversation history is reset." },
48+
"temperature": { "index": 14, "kind": "parameter", "displayName": "Temperature", "group": "producer", "label": "", "required": false, "type": "number", "javaType": "java.lang.Double", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "Temperature for response generation (0.0 to 2.0)" },
49+
"topP": { "index": 15, "kind": "parameter", "displayName": "Top P", "group": "producer", "label": "", "required": false, "type": "number", "javaType": "java.lang.Double", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": "configuration", "description": "Top P for response generation (0.0 to 1.0)" },
50+
"userMessage": { "index": 16, "kind": "parameter", "displayName": "User Message", "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": "Default user message text to use when no prompt is provided" },
51+
"lazyStartProducer": { "index": 17, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing." }
5152
}
5253
}

0 commit comments

Comments
 (0)