Skip to content

Commit 2642a45

Browse files
authored
CAMEL-22778 - Camel-Google-VertexAI: Create Spring Boot starter (#1594)
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
1 parent 6ccc56a commit 2642a45

13 files changed

Lines changed: 975 additions & 5 deletions

File tree

catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ google-secret-manager
134134
google-sheets
135135
google-sheets-stream
136136
google-storage
137+
google-vertexai
137138
grape
138139
graphql
139140
grpc

catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/google-vertexai.json

Lines changed: 91 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one or more
5+
contributor license agreements. See the NOTICE file distributed with
6+
this work for additional information regarding copyright ownership.
7+
The ASF licenses this file to You under the Apache License, Version 2.0
8+
(the "License"); you may not use this file except in compliance with
9+
the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
<parent>
23+
<groupId>org.apache.camel.springboot</groupId>
24+
<artifactId>components-starter</artifactId>
25+
<version>4.17.0-SNAPSHOT</version>
26+
</parent>
27+
<artifactId>camel-google-vertexai-starter</artifactId>
28+
<packaging>jar</packaging>
29+
<name>Camel SB Starters :: google-vertexai</name>
30+
<dependencies>
31+
<dependency>
32+
<groupId>org.springframework.boot</groupId>
33+
<artifactId>spring-boot-starter</artifactId>
34+
<version>${spring-boot-version}</version>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.apache.camel</groupId>
38+
<artifactId>camel-google-vertexai</artifactId>
39+
<version>${camel-version}</version>
40+
<!--START OF GENERATED CODE-->
41+
<exclusions>
42+
<exclusion>
43+
<groupId>commons-logging</groupId>
44+
<artifactId>commons-logging</artifactId>
45+
</exclusion>
46+
</exclusions>
47+
<!--END OF GENERATED CODE-->
48+
</dependency>
49+
<!--START OF GENERATED CODE-->
50+
<dependency>
51+
<groupId>org.apache.camel.springboot</groupId>
52+
<artifactId>camel-core-starter</artifactId>
53+
</dependency>
54+
<!--END OF GENERATED CODE-->
55+
</dependencies>
56+
</project>
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
{
2+
"groups": [
3+
{
4+
"name": "camel.component.google-vertexai",
5+
"type": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration",
6+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration"
7+
},
8+
{
9+
"name": "camel.component.google-vertexai.customizer",
10+
"type": "org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon$CustomizerProperties",
11+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration",
12+
"sourceMethod": "getCustomizer()"
13+
}
14+
],
15+
"properties": [
16+
{
17+
"name": "camel.component.google-vertexai.anthropic-version",
18+
"type": "java.lang.String",
19+
"description": "Anthropic API version for Claude models. Required when publisher is 'anthropic'.",
20+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration",
21+
"defaultValue": "vertex-2023-10-16"
22+
},
23+
{
24+
"name": "camel.component.google-vertexai.autowired-enabled",
25+
"type": "java.lang.Boolean",
26+
"description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.",
27+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration",
28+
"defaultValue": true
29+
},
30+
{
31+
"name": "camel.component.google-vertexai.candidate-count",
32+
"type": "java.lang.Integer",
33+
"description": "Number of candidate responses to generate",
34+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration",
35+
"defaultValue": 1
36+
},
37+
{
38+
"name": "camel.component.google-vertexai.client",
39+
"type": "com.google.genai.Client",
40+
"description": "The Google GenAI client for Vertex AI. The option is a com.google.genai.Client type.",
41+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration"
42+
},
43+
{
44+
"name": "camel.component.google-vertexai.configuration",
45+
"type": "org.apache.camel.component.google.vertexai.GoogleVertexAIConfiguration",
46+
"description": "The component configuration. The option is a org.apache.camel.component.google.vertexai.GoogleVertexAIConfiguration type.",
47+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration"
48+
},
49+
{
50+
"name": "camel.component.google-vertexai.customizer.enabled",
51+
"type": "java.lang.Boolean",
52+
"sourceType": "org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon$CustomizerProperties"
53+
},
54+
{
55+
"name": "camel.component.google-vertexai.enabled",
56+
"type": "java.lang.Boolean",
57+
"description": "Whether to enable auto configuration of the google-vertexai component. This is enabled by default.",
58+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration"
59+
},
60+
{
61+
"name": "camel.component.google-vertexai.health-check-consumer-enabled",
62+
"type": "java.lang.Boolean",
63+
"description": "Used for enabling or disabling all consumer based health checks from this component",
64+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration",
65+
"defaultValue": true
66+
},
67+
{
68+
"name": "camel.component.google-vertexai.health-check-producer-enabled",
69+
"type": "java.lang.Boolean",
70+
"description": "Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer checks globally by setting camel.health.producersEnabled=true.",
71+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration",
72+
"defaultValue": true
73+
},
74+
{
75+
"name": "camel.component.google-vertexai.json-mode",
76+
"type": "java.lang.Boolean",
77+
"description": "Whether to use JSON request\/response format",
78+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration",
79+
"defaultValue": false
80+
},
81+
{
82+
"name": "camel.component.google-vertexai.lazy-start-producer",
83+
"type": "java.lang.Boolean",
84+
"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.",
85+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration",
86+
"defaultValue": false
87+
},
88+
{
89+
"name": "camel.component.google-vertexai.max-output-tokens",
90+
"type": "java.lang.Integer",
91+
"description": "Maximum number of output tokens",
92+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration",
93+
"defaultValue": 1024
94+
},
95+
{
96+
"name": "camel.component.google-vertexai.operation",
97+
"type": "org.apache.camel.component.google.vertexai.GoogleVertexAIOperations",
98+
"description": "Set the operation for the producer",
99+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration"
100+
},
101+
{
102+
"name": "camel.component.google-vertexai.prediction-service-client",
103+
"type": "com.google.cloud.aiplatform.v1.PredictionServiceClient",
104+
"description": "The Google Cloud AI Platform Prediction Service client for rawPredict operations. The option is a com.google.cloud.aiplatform.v1.PredictionServiceClient type.",
105+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration"
106+
},
107+
{
108+
"name": "camel.component.google-vertexai.publisher",
109+
"type": "java.lang.String",
110+
"description": "Publisher name for partner models (e.g., anthropic, meta, mistralai). Required for rawPredict operations.",
111+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration"
112+
},
113+
{
114+
"name": "camel.component.google-vertexai.service-account-key",
115+
"type": "java.lang.String",
116+
"description": "The Service account key that can be used as credentials for the Vertex AI client. It can be loaded by default from classpath, but you can prefix with classpath:, file:, or http: to load the resource from different systems.",
117+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration"
118+
},
119+
{
120+
"name": "camel.component.google-vertexai.stream-output-mode",
121+
"type": "java.lang.String",
122+
"description": "Streaming output mode: complete (default) or chunks",
123+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration",
124+
"defaultValue": "complete"
125+
},
126+
{
127+
"name": "camel.component.google-vertexai.temperature",
128+
"type": "java.lang.Float",
129+
"description": "Temperature parameter for generation (0.0-1.0)",
130+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration"
131+
},
132+
{
133+
"name": "camel.component.google-vertexai.top-k",
134+
"type": "java.lang.Integer",
135+
"description": "Top-K parameter for generation",
136+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration",
137+
"defaultValue": 40
138+
},
139+
{
140+
"name": "camel.component.google-vertexai.top-p",
141+
"type": "java.lang.Float",
142+
"description": "Top-P parameter for nucleus sampling",
143+
"sourceType": "org.apache.camel.component.google.vertexai.springboot.GoogleVertexAIComponentConfiguration"
144+
}
145+
],
146+
"hints": [],
147+
"ignored": {
148+
"properties": []
149+
}
150+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.camel.component.google.vertexai.springboot;
18+
19+
import org.apache.camel.CamelContext;
20+
import org.apache.camel.Component;
21+
import org.apache.camel.component.google.vertexai.GoogleVertexAIComponent;
22+
import org.apache.camel.spi.ComponentCustomizer;
23+
import org.apache.camel.spring.boot.CamelAutoConfiguration;
24+
import org.apache.camel.spring.boot.ComponentConfigurationProperties;
25+
import org.apache.camel.spring.boot.util.CamelPropertiesHelper;
26+
import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans;
27+
import org.apache.camel.spring.boot.util.ConditionalOnHierarchicalProperties;
28+
import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator;
29+
import org.springframework.beans.factory.annotation.Autowired;
30+
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
31+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
32+
import org.springframework.context.ApplicationContext;
33+
import org.springframework.context.annotation.Bean;
34+
import org.springframework.context.annotation.Conditional;
35+
import org.springframework.context.annotation.Configuration;
36+
import org.springframework.context.annotation.Lazy;
37+
38+
/**
39+
* Generated by camel-package-maven-plugin - do not edit this file!
40+
*/
41+
@Configuration(proxyBeanMethods = false)
42+
@Conditional(ConditionalOnCamelContextAndAutoConfigurationBeans.class)
43+
@EnableConfigurationProperties({ComponentConfigurationProperties.class,GoogleVertexAIComponentConfiguration.class})
44+
@ConditionalOnHierarchicalProperties({"camel.component", "camel.component.google-vertexai"})
45+
@AutoConfigureAfter({CamelAutoConfiguration.class, GoogleVertexAIComponentConverter.class})
46+
public class GoogleVertexAIComponentAutoConfiguration {
47+
48+
@Autowired
49+
private ApplicationContext applicationContext;
50+
private final CamelContext camelContext;
51+
@Autowired
52+
private GoogleVertexAIComponentConfiguration configuration;
53+
54+
public GoogleVertexAIComponentAutoConfiguration(
55+
org.apache.camel.CamelContext camelContext) {
56+
this.camelContext = camelContext;
57+
}
58+
59+
@Lazy
60+
@Bean
61+
public ComponentCustomizer configureGoogleVertexAIComponent() {
62+
return new ComponentCustomizer() {
63+
@Override
64+
public void configure(String name, Component target) {
65+
CamelPropertiesHelper.copyProperties(camelContext, configuration, target);
66+
}
67+
@Override
68+
public boolean isEnabled(String name, Component target) {
69+
return HierarchicalPropertiesEvaluator.evaluate(
70+
applicationContext,
71+
"camel.component.customizer",
72+
"camel.component.google-vertexai.customizer")
73+
&& target instanceof GoogleVertexAIComponent;
74+
}
75+
};
76+
}
77+
}

0 commit comments

Comments
 (0)