diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/weaviate.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/weaviate.json index 2de560c82ee0f..ca346ec1e16d0 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/weaviate.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/weaviate.json @@ -26,13 +26,15 @@ "componentProperties": { "apiKey": { "index": 0, "kind": "property", "displayName": "Api Key", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "API Key to authenticate to weaviate with" }, "configuration": { "index": 1, "kind": "property", "displayName": "Configuration", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "deprecated": false, "autowired": false, "secret": false, "description": "The configuration;" }, - "host": { "index": 2, "kind": "property", "displayName": "Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Weaviate server host to connect to" }, - "lazyStartProducer": { "index": 3, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "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." }, - "proxyHost": { "index": 4, "kind": "property", "displayName": "Proxy Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy host to connect to weaviate through" }, - "proxyPort": { "index": 5, "kind": "property", "displayName": "Proxy Port", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy port to connect to weaviate through" }, - "proxyScheme": { "index": 6, "kind": "property", "displayName": "Proxy Scheme", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy scheme to connect to weaviate through" }, - "scheme": { "index": 7, "kind": "property", "displayName": "Scheme", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Scheme used to connect to weaviate" }, - "autowiredEnabled": { "index": 8, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "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." } + "grpcHost": { "index": 2, "kind": "property", "displayName": "Grpc Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "gRPC host for Weaviate server connection" }, + "grpcPort": { "index": 3, "kind": "property", "displayName": "Grpc Port", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 50051, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "gRPC port for Weaviate server connection" }, + "host": { "index": 4, "kind": "property", "displayName": "Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Weaviate server host to connect to" }, + "lazyStartProducer": { "index": 5, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "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." }, + "proxyHost": { "index": 6, "kind": "property", "displayName": "Proxy Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": true, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy host to connect to weaviate through" }, + "proxyPort": { "index": 7, "kind": "property", "displayName": "Proxy Port", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": true, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy port to connect to weaviate through" }, + "proxyScheme": { "index": 8, "kind": "property", "displayName": "Proxy Scheme", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": true, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy scheme to connect to weaviate through" }, + "scheme": { "index": 9, "kind": "property", "displayName": "Scheme", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "http", "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Scheme used to connect to weaviate" }, + "autowiredEnabled": { "index": 10, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "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." } }, "headers": { "CamelWeaviateAction": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "enum": [ "CREATE_COLLECTION", "CREATE", "DELETE_BY_ID", "DELETE_COLLECTION", "QUERY", "QUERY_BY_ID", "UPDATE_BY_ID" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The action to be performed.", "constantName": "org.apache.camel.component.weaviate.WeaviateVectorDbHeaders#ACTION" }, @@ -50,11 +52,13 @@ "properties": { "collection": { "index": 0, "kind": "path", "displayName": "Collection", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The collection Name" }, "apiKey": { "index": 1, "kind": "parameter", "displayName": "Api Key", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "API Key to authenticate to weaviate with" }, - "host": { "index": 2, "kind": "parameter", "displayName": "Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Weaviate server host to connect to" }, - "proxyHost": { "index": 3, "kind": "parameter", "displayName": "Proxy Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy host to connect to weaviate through" }, - "proxyPort": { "index": 4, "kind": "parameter", "displayName": "Proxy Port", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy port to connect to weaviate through" }, - "proxyScheme": { "index": 5, "kind": "parameter", "displayName": "Proxy Scheme", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy scheme to connect to weaviate through" }, - "scheme": { "index": 6, "kind": "parameter", "displayName": "Scheme", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Scheme used to connect to weaviate" }, - "lazyStartProducer": { "index": 7, "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." } + "grpcHost": { "index": 2, "kind": "parameter", "displayName": "Grpc Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "gRPC host for Weaviate server connection" }, + "grpcPort": { "index": 3, "kind": "parameter", "displayName": "Grpc Port", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 50051, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "gRPC port for Weaviate server connection" }, + "host": { "index": 4, "kind": "parameter", "displayName": "Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Weaviate server host to connect to" }, + "proxyHost": { "index": 5, "kind": "parameter", "displayName": "Proxy Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": true, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy host to connect to weaviate through" }, + "proxyPort": { "index": 6, "kind": "parameter", "displayName": "Proxy Port", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": true, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy port to connect to weaviate through" }, + "proxyScheme": { "index": 7, "kind": "parameter", "displayName": "Proxy Scheme", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": true, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy scheme to connect to weaviate through" }, + "scheme": { "index": 8, "kind": "parameter", "displayName": "Scheme", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "http", "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Scheme used to connect to weaviate" }, + "lazyStartProducer": { "index": 9, "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." } } } diff --git a/components/camel-ai/camel-langchain4j-embeddings/src/test/java/org/apache/camel/component/langchain4j/embeddings/LangChain4jEmbeddingsComponentWeaviateTargetIT.java b/components/camel-ai/camel-langchain4j-embeddings/src/test/java/org/apache/camel/component/langchain4j/embeddings/LangChain4jEmbeddingsComponentWeaviateTargetIT.java index f4212d6cf83af..3002383f227ac 100644 --- a/components/camel-ai/camel-langchain4j-embeddings/src/test/java/org/apache/camel/component/langchain4j/embeddings/LangChain4jEmbeddingsComponentWeaviateTargetIT.java +++ b/components/camel-ai/camel-langchain4j-embeddings/src/test/java/org/apache/camel/component/langchain4j/embeddings/LangChain4jEmbeddingsComponentWeaviateTargetIT.java @@ -17,18 +17,15 @@ package org.apache.camel.component.langchain4j.embeddings; import java.util.HashMap; -import java.util.List; import java.util.Map; +import java.util.Optional; import dev.langchain4j.model.embedding.onnx.allminilml6v2.AllMiniLmL6V2EmbeddingModel; -import io.weaviate.client.base.Result; -import io.weaviate.client.v1.data.model.WeaviateObject; -import io.weaviate.client.v1.schema.model.WeaviateClass; +import io.weaviate.client6.v1.api.collections.WeaviateObject; import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.qdrant.QdrantAction; import org.apache.camel.component.weaviate.WeaviateVectorDb; import org.apache.camel.component.weaviate.WeaviateVectorDbAction; import org.apache.camel.component.weaviate.WeaviateVectorDbComponent; @@ -51,7 +48,7 @@ @TestMethodOrder(MethodOrderer.OrderAnnotation.class) public class LangChain4jEmbeddingsComponentWeaviateTargetIT extends CamelTestSupport { public static final long POINT_ID = 8; - public static final String WEAVIATE_URI = "weaviate:embeddings"; + public static final String WEAVIATE_URI = "weaviate:Embeddings"; private static String CREATEID = null; @RegisterExtension @@ -63,7 +60,9 @@ protected CamelContext createCamelContext() throws Exception { var qc = context.getComponent(WeaviateVectorDb.SCHEME, WeaviateVectorDbComponent.class); qc.getConfiguration().setScheme("http"); - qc.getConfiguration().setHost(WEAVIATE.getWeaviateEndpointUrl()); + qc.getConfiguration().setHost(WEAVIATE.getWeaviateHost() + ":" + WEAVIATE.getWeaviatePort()); + qc.getConfiguration().setGrpcHost(WEAVIATE.getWeaviateHost()); + qc.getConfiguration().setGrpcPort(WEAVIATE.getWeaviateGrpcPort()); context.getRegistry().bind("embedding-model", new AllMiniLmL6V2EmbeddingModel()); return context; @@ -73,9 +72,7 @@ protected CamelContext createCamelContext() throws Exception { @Order(1) public void createCollection() { Exchange result = fluentTemplate.to(WEAVIATE_URI) - .withHeader(WeaviateVectorDbHeaders.ACTION, QdrantAction.CREATE_COLLECTION) - .withBody( - WeaviateClass.builder().className("embeddings").build()) + .withHeader(WeaviateVectorDbHeaders.ACTION, WeaviateVectorDbAction.CREATE_COLLECTION) .request(Exchange.class); assertThat(result).isNotNull(); @@ -92,14 +89,14 @@ public void create() { Exchange result = fluentTemplate.to("direct:in") .withHeader(WeaviateVectorDbHeaders.ACTION, WeaviateVectorDbAction.CREATE) .withBody("hi") - .withHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, "embeddings") + .withHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, "Embeddings") .withHeader(WeaviateVectorDbHeaders.PROPERTIES, map) .request(Exchange.class); assertThat(result).isNotNull(); assertThat(result.getException()).isNull(); - Result res = (Result) result.getIn().getBody(); - CREATEID = res.getResult().getId(); + WeaviateObject> res = (WeaviateObject>) result.getIn().getBody(); + CREATEID = res.uuid(); } @Test @@ -113,7 +110,7 @@ public void updateById() { .withHeader(WeaviateVectorDbHeaders.ACTION, WeaviateVectorDbAction.UPDATE_BY_ID) .withBody("hi") .withHeader(WeaviateVectorDbHeaders.INDEX_ID, CREATEID) - .withHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, "embeddings") + .withHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, "Embeddings") .withHeader(WeaviateVectorDbHeaders.PROPERTIES, map) .request(Exchange.class); @@ -131,17 +128,16 @@ public void querybyid() { assertThat(result).isNotNull(); assertThat(result.getException()).isNull(); - Result res = (Result) result.getIn().getBody(); - assertThat(res.hasErrors()).isFalse(); - List list = (List) res.getResult(); - for (WeaviateObject wo : list) { + Optional>> res + = (Optional>>) result.getIn().getBody(); + assertThat(res).isPresent(); - Map map = wo.getProperties(); - assertThat(map).containsKey("sky"); - assertThat(map).containsKey("age"); - assertThat(map).containsKey("dog"); - } + WeaviateObject> wo = res.get(); + Map props = wo.properties(); + assertThat(props).containsKey("sky"); + assertThat(props).containsKey("age"); + assertThat(props).containsKey("dog"); } @Test diff --git a/components/camel-ai/camel-weaviate/pom.xml b/components/camel-ai/camel-weaviate/pom.xml index 0cf6c0c4a3945..5f14170407ed0 100644 --- a/components/camel-ai/camel-weaviate/pom.xml +++ b/components/camel-ai/camel-weaviate/pom.xml @@ -35,7 +35,7 @@ true 4 - + true true @@ -52,10 +52,12 @@ ${langchain4j-version} + io.weaviate - client + client6 ${weaviate-client-version} + all diff --git a/components/camel-ai/camel-weaviate/src/generated/java/org/apache/camel/component/weaviate/WeaviateVectorDbComponentConfigurer.java b/components/camel-ai/camel-weaviate/src/generated/java/org/apache/camel/component/weaviate/WeaviateVectorDbComponentConfigurer.java index 20afb346b3298..7d8103b251068 100644 --- a/components/camel-ai/camel-weaviate/src/generated/java/org/apache/camel/component/weaviate/WeaviateVectorDbComponentConfigurer.java +++ b/components/camel-ai/camel-weaviate/src/generated/java/org/apache/camel/component/weaviate/WeaviateVectorDbComponentConfigurer.java @@ -35,6 +35,10 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj case "autowiredenabled": case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true; case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration.class, value)); return true; + case "grpchost": + case "grpcHost": getOrCreateConfiguration(target).setGrpcHost(property(camelContext, java.lang.String.class, value)); return true; + case "grpcport": + case "grpcPort": getOrCreateConfiguration(target).setGrpcPort(property(camelContext, java.lang.Integer.class, value)); return true; case "host": getOrCreateConfiguration(target).setHost(property(camelContext, java.lang.String.class, value)); return true; case "lazystartproducer": case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true; @@ -57,6 +61,10 @@ public Class getOptionType(String name, boolean ignoreCase) { case "autowiredenabled": case "autowiredEnabled": return boolean.class; case "configuration": return org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration.class; + case "grpchost": + case "grpcHost": return java.lang.String.class; + case "grpcport": + case "grpcPort": return java.lang.Integer.class; case "host": return java.lang.String.class; case "lazystartproducer": case "lazyStartProducer": return boolean.class; @@ -80,6 +88,10 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) { case "autowiredenabled": case "autowiredEnabled": return target.isAutowiredEnabled(); case "configuration": return target.getConfiguration(); + case "grpchost": + case "grpcHost": return getOrCreateConfiguration(target).getGrpcHost(); + case "grpcport": + case "grpcPort": return getOrCreateConfiguration(target).getGrpcPort(); case "host": return getOrCreateConfiguration(target).getHost(); case "lazystartproducer": case "lazyStartProducer": return target.isLazyStartProducer(); diff --git a/components/camel-ai/camel-weaviate/src/generated/java/org/apache/camel/component/weaviate/WeaviateVectorDbConfigurationConfigurer.java b/components/camel-ai/camel-weaviate/src/generated/java/org/apache/camel/component/weaviate/WeaviateVectorDbConfigurationConfigurer.java index 68a021aafce59..bf1ffdac150b4 100644 --- a/components/camel-ai/camel-weaviate/src/generated/java/org/apache/camel/component/weaviate/WeaviateVectorDbConfigurationConfigurer.java +++ b/components/camel-ai/camel-weaviate/src/generated/java/org/apache/camel/component/weaviate/WeaviateVectorDbConfigurationConfigurer.java @@ -25,7 +25,11 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj switch (ignoreCase ? name.toLowerCase() : name) { case "apikey": case "apiKey": target.setApiKey(property(camelContext, java.lang.String.class, value)); return true; - case "client": target.setClient(property(camelContext, io.weaviate.client.WeaviateClient.class, value)); return true; + case "client": target.setClient(property(camelContext, io.weaviate.client6.v1.api.WeaviateClient.class, value)); return true; + case "grpchost": + case "grpcHost": target.setGrpcHost(property(camelContext, java.lang.String.class, value)); return true; + case "grpcport": + case "grpcPort": target.setGrpcPort(property(camelContext, java.lang.Integer.class, value)); return true; case "host": target.setHost(property(camelContext, java.lang.String.class, value)); return true; case "proxyhost": case "proxyHost": target.setProxyHost(property(camelContext, java.lang.String.class, value)); return true; @@ -43,7 +47,11 @@ public Class getOptionType(String name, boolean ignoreCase) { switch (ignoreCase ? name.toLowerCase() : name) { case "apikey": case "apiKey": return java.lang.String.class; - case "client": return io.weaviate.client.WeaviateClient.class; + case "client": return io.weaviate.client6.v1.api.WeaviateClient.class; + case "grpchost": + case "grpcHost": return java.lang.String.class; + case "grpcport": + case "grpcPort": return java.lang.Integer.class; case "host": return java.lang.String.class; case "proxyhost": case "proxyHost": return java.lang.String.class; @@ -63,6 +71,10 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) { case "apikey": case "apiKey": return target.getApiKey(); case "client": return target.getClient(); + case "grpchost": + case "grpcHost": return target.getGrpcHost(); + case "grpcport": + case "grpcPort": return target.getGrpcPort(); case "host": return target.getHost(); case "proxyhost": case "proxyHost": return target.getProxyHost(); diff --git a/components/camel-ai/camel-weaviate/src/generated/java/org/apache/camel/component/weaviate/WeaviateVectorDbEndpointConfigurer.java b/components/camel-ai/camel-weaviate/src/generated/java/org/apache/camel/component/weaviate/WeaviateVectorDbEndpointConfigurer.java index 8f092ec443f37..7050c0bcd73a9 100644 --- a/components/camel-ai/camel-weaviate/src/generated/java/org/apache/camel/component/weaviate/WeaviateVectorDbEndpointConfigurer.java +++ b/components/camel-ai/camel-weaviate/src/generated/java/org/apache/camel/component/weaviate/WeaviateVectorDbEndpointConfigurer.java @@ -25,6 +25,10 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj switch (ignoreCase ? name.toLowerCase() : name) { case "apikey": case "apiKey": target.getConfiguration().setApiKey(property(camelContext, java.lang.String.class, value)); return true; + case "grpchost": + case "grpcHost": target.getConfiguration().setGrpcHost(property(camelContext, java.lang.String.class, value)); return true; + case "grpcport": + case "grpcPort": target.getConfiguration().setGrpcPort(property(camelContext, java.lang.Integer.class, value)); return true; case "host": target.getConfiguration().setHost(property(camelContext, java.lang.String.class, value)); return true; case "lazystartproducer": case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true; @@ -44,6 +48,10 @@ public Class getOptionType(String name, boolean ignoreCase) { switch (ignoreCase ? name.toLowerCase() : name) { case "apikey": case "apiKey": return java.lang.String.class; + case "grpchost": + case "grpcHost": return java.lang.String.class; + case "grpcport": + case "grpcPort": return java.lang.Integer.class; case "host": return java.lang.String.class; case "lazystartproducer": case "lazyStartProducer": return boolean.class; @@ -64,6 +72,10 @@ public Object getOptionValue(Object obj, String name, boolean ignoreCase) { switch (ignoreCase ? name.toLowerCase() : name) { case "apikey": case "apiKey": return target.getConfiguration().getApiKey(); + case "grpchost": + case "grpcHost": return target.getConfiguration().getGrpcHost(); + case "grpcport": + case "grpcPort": return target.getConfiguration().getGrpcPort(); case "host": return target.getConfiguration().getHost(); case "lazystartproducer": case "lazyStartProducer": return target.isLazyStartProducer(); diff --git a/components/camel-ai/camel-weaviate/src/generated/java/org/apache/camel/component/weaviate/WeaviateVectorDbEndpointUriFactory.java b/components/camel-ai/camel-weaviate/src/generated/java/org/apache/camel/component/weaviate/WeaviateVectorDbEndpointUriFactory.java index a6dee2cd935f9..c2b94ad4e21bd 100644 --- a/components/camel-ai/camel-weaviate/src/generated/java/org/apache/camel/component/weaviate/WeaviateVectorDbEndpointUriFactory.java +++ b/components/camel-ai/camel-weaviate/src/generated/java/org/apache/camel/component/weaviate/WeaviateVectorDbEndpointUriFactory.java @@ -24,9 +24,11 @@ public class WeaviateVectorDbEndpointUriFactory extends org.apache.camel.support private static final Set ENDPOINT_IDENTITY_PROPERTY_NAMES; private static final Map MULTI_VALUE_PREFIXES; static { - Set props = new HashSet<>(8); + Set props = new HashSet<>(10); props.add("apiKey"); props.add("collection"); + props.add("grpcHost"); + props.add("grpcPort"); props.add("host"); props.add("lazyStartProducer"); props.add("proxyHost"); diff --git a/components/camel-ai/camel-weaviate/src/generated/resources/META-INF/org/apache/camel/component/weaviate/weaviate.json b/components/camel-ai/camel-weaviate/src/generated/resources/META-INF/org/apache/camel/component/weaviate/weaviate.json index 2de560c82ee0f..ca346ec1e16d0 100644 --- a/components/camel-ai/camel-weaviate/src/generated/resources/META-INF/org/apache/camel/component/weaviate/weaviate.json +++ b/components/camel-ai/camel-weaviate/src/generated/resources/META-INF/org/apache/camel/component/weaviate/weaviate.json @@ -26,13 +26,15 @@ "componentProperties": { "apiKey": { "index": 0, "kind": "property", "displayName": "Api Key", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "API Key to authenticate to weaviate with" }, "configuration": { "index": 1, "kind": "property", "displayName": "Configuration", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "deprecated": false, "autowired": false, "secret": false, "description": "The configuration;" }, - "host": { "index": 2, "kind": "property", "displayName": "Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Weaviate server host to connect to" }, - "lazyStartProducer": { "index": 3, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "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." }, - "proxyHost": { "index": 4, "kind": "property", "displayName": "Proxy Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy host to connect to weaviate through" }, - "proxyPort": { "index": 5, "kind": "property", "displayName": "Proxy Port", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy port to connect to weaviate through" }, - "proxyScheme": { "index": 6, "kind": "property", "displayName": "Proxy Scheme", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy scheme to connect to weaviate through" }, - "scheme": { "index": 7, "kind": "property", "displayName": "Scheme", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Scheme used to connect to weaviate" }, - "autowiredEnabled": { "index": 8, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "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." } + "grpcHost": { "index": 2, "kind": "property", "displayName": "Grpc Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "gRPC host for Weaviate server connection" }, + "grpcPort": { "index": 3, "kind": "property", "displayName": "Grpc Port", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 50051, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "gRPC port for Weaviate server connection" }, + "host": { "index": 4, "kind": "property", "displayName": "Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Weaviate server host to connect to" }, + "lazyStartProducer": { "index": 5, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "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." }, + "proxyHost": { "index": 6, "kind": "property", "displayName": "Proxy Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": true, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy host to connect to weaviate through" }, + "proxyPort": { "index": 7, "kind": "property", "displayName": "Proxy Port", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": true, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy port to connect to weaviate through" }, + "proxyScheme": { "index": 8, "kind": "property", "displayName": "Proxy Scheme", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": true, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy scheme to connect to weaviate through" }, + "scheme": { "index": 9, "kind": "property", "displayName": "Scheme", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "http", "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Scheme used to connect to weaviate" }, + "autowiredEnabled": { "index": 10, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "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." } }, "headers": { "CamelWeaviateAction": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "enum": [ "CREATE_COLLECTION", "CREATE", "DELETE_BY_ID", "DELETE_COLLECTION", "QUERY", "QUERY_BY_ID", "UPDATE_BY_ID" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The action to be performed.", "constantName": "org.apache.camel.component.weaviate.WeaviateVectorDbHeaders#ACTION" }, @@ -50,11 +52,13 @@ "properties": { "collection": { "index": 0, "kind": "path", "displayName": "Collection", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The collection Name" }, "apiKey": { "index": 1, "kind": "parameter", "displayName": "Api Key", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "security": "secret", "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "API Key to authenticate to weaviate with" }, - "host": { "index": 2, "kind": "parameter", "displayName": "Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Weaviate server host to connect to" }, - "proxyHost": { "index": 3, "kind": "parameter", "displayName": "Proxy Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy host to connect to weaviate through" }, - "proxyPort": { "index": 4, "kind": "parameter", "displayName": "Proxy Port", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy port to connect to weaviate through" }, - "proxyScheme": { "index": 5, "kind": "parameter", "displayName": "Proxy Scheme", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy scheme to connect to weaviate through" }, - "scheme": { "index": 6, "kind": "parameter", "displayName": "Scheme", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Scheme used to connect to weaviate" }, - "lazyStartProducer": { "index": 7, "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." } + "grpcHost": { "index": 2, "kind": "parameter", "displayName": "Grpc Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "gRPC host for Weaviate server connection" }, + "grpcPort": { "index": 3, "kind": "parameter", "displayName": "Grpc Port", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 50051, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "gRPC port for Weaviate server connection" }, + "host": { "index": 4, "kind": "parameter", "displayName": "Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Weaviate server host to connect to" }, + "proxyHost": { "index": 5, "kind": "parameter", "displayName": "Proxy Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": true, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy host to connect to weaviate through" }, + "proxyPort": { "index": 6, "kind": "parameter", "displayName": "Proxy Port", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": true, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy port to connect to weaviate through" }, + "proxyScheme": { "index": 7, "kind": "parameter", "displayName": "Proxy Scheme", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": true, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Proxy scheme to connect to weaviate through" }, + "scheme": { "index": 8, "kind": "parameter", "displayName": "Scheme", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "http", "configurationClass": "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration", "configurationField": "configuration", "description": "Scheme used to connect to weaviate" }, + "lazyStartProducer": { "index": 9, "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." } } } diff --git a/components/camel-ai/camel-weaviate/src/main/java/org/apache/camel/component/weaviate/WeaviateVectorDbConfiguration.java b/components/camel-ai/camel-weaviate/src/main/java/org/apache/camel/component/weaviate/WeaviateVectorDbConfiguration.java index ef73757538dfa..b16ed880f2b5f 100644 --- a/components/camel-ai/camel-weaviate/src/main/java/org/apache/camel/component/weaviate/WeaviateVectorDbConfiguration.java +++ b/components/camel-ai/camel-weaviate/src/main/java/org/apache/camel/component/weaviate/WeaviateVectorDbConfiguration.java @@ -16,7 +16,7 @@ */ package org.apache.camel.component.weaviate; -import io.weaviate.client.WeaviateClient; +import io.weaviate.client6.v1.api.WeaviateClient; import org.apache.camel.RuntimeCamelException; import org.apache.camel.spi.Configurer; import org.apache.camel.spi.Metadata; @@ -29,29 +29,42 @@ public class WeaviateVectorDbConfiguration implements Cloneable { @Metadata(label = "producer", description = "Scheme used to connect to weaviate") - @UriParam - private String scheme; + @UriParam(defaultValue = "http") + private String scheme = "http"; @Metadata(label = "producer", description = "Weaviate server host to connect to") @UriParam private String host; + @Deprecated @Metadata(label = "producer", description = "Proxy host to connect to weaviate through") @UriParam private String proxyHost; + @Deprecated @Metadata(label = "producer", description = "Proxy port to connect to weaviate through") @UriParam private Integer proxyPort; + @Deprecated @Metadata(label = "producer", description = "Proxy scheme to connect to weaviate through") @UriParam private String proxyScheme; + @Metadata(label = "producer", + description = "gRPC host for Weaviate server connection") + @UriParam + private String grpcHost; + + @Metadata(label = "producer", + description = "gRPC port for Weaviate server connection", defaultValue = "50051") + @UriParam(defaultValue = "50051") + private Integer grpcPort; + @Metadata(label = "producer", description = "API Key to authenticate to weaviate with", security = "secret") @UriParam @@ -60,6 +73,34 @@ public class WeaviateVectorDbConfiguration implements Cloneable { @Metadata(autowired = true) private WeaviateClient client; + /** + * Get the gRPC host for Weaviate server connection. + */ + public String getGrpcHost() { + return grpcHost; + } + + /** + * Set the gRPC host for Weaviate server connection. + */ + public void setGrpcHost(String grpcHost) { + this.grpcHost = grpcHost; + } + + /** + * Get the gRPC port for Weaviate server connection. + */ + public Integer getGrpcPort() { + return grpcPort; + } + + /** + * Set the gRPC port for Weaviate server connection. + */ + public void setGrpcPort(Integer grpcPort) { + this.grpcPort = grpcPort; + } + /* * Get the api key used to authenticate to weaviate server. */ @@ -106,61 +147,63 @@ public void setHost(String host) { this.host = host; } - /* - * Get the proxy host used for connecting to weaviate. + /** + * @deprecated The Weaviate v6 client does not support proxy configuration. */ + @Deprecated public String getProxyHost() { return proxyHost; } /** - * Set the proxy host used to connect to weaviate. - * - * @param proxyHost proxy host + * @deprecated The Weaviate v6 client does not support proxy configuration. */ + @Deprecated public void setProxyHost(String proxyHost) { this.proxyHost = proxyHost; } - /* - * Get the proxy port used to connect to weaviate. + /** + * @deprecated The Weaviate v6 client does not support proxy configuration. */ + @Deprecated public Integer getProxyPort() { return proxyPort; } - /* - * Set the proxy port used to connect to weaviate. + /** + * @deprecated The Weaviate v6 client does not support proxy configuration. */ + @Deprecated public void setProxyPort(Integer proxyPort) { this.proxyPort = proxyPort; } - /* - * Get the scheme (http/https/etc) used for connecting to proxy. + /** + * @deprecated The Weaviate v6 client does not support proxy configuration. */ + @Deprecated public String getProxyScheme() { return proxyScheme; } /** - * Set the scheme used to for connecting to the proxy. - * - * @param proxyScheme + * @deprecated The Weaviate v6 client does not support proxy configuration. */ + @Deprecated public void setProxyScheme(String proxyScheme) { this.proxyScheme = proxyScheme; } /** - * Get the io.weaviate.client.WeaviateClient. + * Get the io.weaviate.client6.v1.api.WeaviateClient. */ public WeaviateClient getClient() { return client; } /** - * Set the io.weaviate.client.WeaviateClient used. + * Set the io.weaviate.client6.v1.api.WeaviateClient used. * * @param client */ diff --git a/components/camel-ai/camel-weaviate/src/main/java/org/apache/camel/component/weaviate/WeaviateVectorDbEndpoint.java b/components/camel-ai/camel-weaviate/src/main/java/org/apache/camel/component/weaviate/WeaviateVectorDbEndpoint.java index 07d4991483dc9..56393c8aa82e6 100644 --- a/components/camel-ai/camel-weaviate/src/main/java/org/apache/camel/component/weaviate/WeaviateVectorDbEndpoint.java +++ b/components/camel-ai/camel-weaviate/src/main/java/org/apache/camel/component/weaviate/WeaviateVectorDbEndpoint.java @@ -16,11 +16,9 @@ */ package org.apache.camel.component.weaviate; -import io.weaviate.client.Config; -import io.weaviate.client.WeaviateAuthClient; -import io.weaviate.client.WeaviateClient; -import io.weaviate.client.base.Result; -import io.weaviate.client.v1.auth.exception.AuthException; +import io.weaviate.client6.v1.api.Authentication; +import io.weaviate.client6.v1.api.WeaviateClient; +import io.weaviate.client6.v1.api.WeaviateException; import org.apache.camel.Category; import org.apache.camel.Component; import org.apache.camel.Consumer; @@ -55,7 +53,8 @@ public class WeaviateVectorDbEndpoint extends DefaultEndpoint { @UriParam private WeaviateVectorDbConfiguration configuration; - private WeaviateClient client; + private volatile boolean closeClient; + private volatile WeaviateClient client; public WeaviateVectorDbEndpoint( String endpointUri, @@ -77,19 +76,24 @@ public String getCollection() { return collection; } - public WeaviateClient getClient() throws AuthException { - lock.lock(); - try { - if (this.client == null) { - this.client = this.configuration.getClient(); + public WeaviateClient getClient() throws WeaviateException { + if (this.client == null) { + lock.lock(); + try { if (this.client == null) { - this.client = createClient(); + this.client = this.configuration.getClient(); + this.closeClient = false; + + if (this.client == null) { + this.client = createClient(); + this.closeClient = true; + } } + } finally { + lock.unlock(); } - return this.client; - } finally { - lock.unlock(); } + return this.client; } @Override @@ -102,42 +106,48 @@ public Consumer createConsumer(Processor processor) throws Exception { throw new UnsupportedOperationException("Consumer is not implemented for this component"); } - @Override - public void doStart() throws Exception { - super.doStart(); - } - @Override public void doStop() throws Exception { super.doStop(); + if (this.client != null && this.closeClient) { + this.client.close(); + this.client = null; + this.closeClient = false; + } } - private WeaviateClient createClient() throws AuthException { + private WeaviateClient createClient() throws WeaviateException { String scheme = configuration.getScheme(); String host = configuration.getHost(); - Config config = new Config(scheme, host); - - // Configure proxy if we have proxy details within the configuration - if (configuration.getProxyHost() != null - && configuration.getProxyPort() != null - && configuration.getProxyScheme() != null) { - config.setProxy(configuration.getProxyHost(), configuration.getProxyPort().intValue(), - configuration.getProxyScheme()); + if (host == null) { + throw new IllegalArgumentException("Weaviate host must be configured"); } - WeaviateClient weaviate; - - if (configuration.getApiKey() != null) { - weaviate = WeaviateAuthClient.apiKey(config, configuration.getApiKey()); - } else { - weaviate = new WeaviateClient(config); - } - - Result result = weaviate.misc().readyChecker().run(); - if (result.hasErrors()) { - throw new AuthException(result.getError().toString()); + // Parse host:port if port is embedded in the host string + String httpHost = host; + // Weaviate's default HTTP port; overridden below if host contains ":port" + int httpPort = 8080; + if (host.contains(":")) { + String[] parts = host.split(":"); + httpHost = parts[0]; + httpPort = Integer.parseInt(parts[1]); } - return weaviate; + final String resolvedHttpHost = httpHost; + final int resolvedHttpPort = httpPort; + final String grpcHost = configuration.getGrpcHost() != null ? configuration.getGrpcHost() : httpHost; + final int grpcPort = configuration.getGrpcPort() != null ? configuration.getGrpcPort() : 50051; + + return WeaviateClient.connectToCustom(conn -> { + conn.scheme(scheme) + .httpHost(resolvedHttpHost) + .httpPort(resolvedHttpPort) + .grpcHost(grpcHost) + .grpcPort(grpcPort); + if (configuration.getApiKey() != null) { + conn.authentication(Authentication.apiKey(configuration.getApiKey())); + } + return conn; + }); } } diff --git a/components/camel-ai/camel-weaviate/src/main/java/org/apache/camel/component/weaviate/WeaviateVectorDbProducer.java b/components/camel-ai/camel-weaviate/src/main/java/org/apache/camel/component/weaviate/WeaviateVectorDbProducer.java index b04b6ab6a95f0..0e7b75687c4ba 100644 --- a/components/camel-ai/camel-weaviate/src/main/java/org/apache/camel/component/weaviate/WeaviateVectorDbProducer.java +++ b/components/camel-ai/camel-weaviate/src/main/java/org/apache/camel/component/weaviate/WeaviateVectorDbProducer.java @@ -18,19 +18,14 @@ import java.util.HashMap; import java.util.List; -import java.util.concurrent.ExecutorService; - -import io.weaviate.client.WeaviateClient; -import io.weaviate.client.base.Result; -import io.weaviate.client.v1.data.api.ObjectUpdater; -import io.weaviate.client.v1.data.model.WeaviateObject; -import io.weaviate.client.v1.graphql.model.GraphQLResponse; -import io.weaviate.client.v1.graphql.query.argument.NearVectorArgument; -import io.weaviate.client.v1.graphql.query.builder.GetBuilder; -import io.weaviate.client.v1.graphql.query.fields.Field; -import io.weaviate.client.v1.graphql.query.fields.Fields; -import io.weaviate.client.v1.schema.model.WeaviateClass; -import org.apache.camel.CamelContext; +import java.util.Map; +import java.util.Optional; + +import io.weaviate.client6.v1.api.WeaviateClient; +import io.weaviate.client6.v1.api.collections.CollectionHandle; +import io.weaviate.client6.v1.api.collections.Vectors; +import io.weaviate.client6.v1.api.collections.WeaviateObject; +import io.weaviate.client6.v1.api.collections.query.QueryResponse; import org.apache.camel.Exchange; import org.apache.camel.Message; import org.apache.camel.NoSuchHeaderException; @@ -39,7 +34,6 @@ public class WeaviateVectorDbProducer extends DefaultProducer { private WeaviateClient client; - private ExecutorService executor; public WeaviateVectorDbProducer(WeaviateVectorDbEndpoint endpoint) { super(endpoint); @@ -106,44 +100,31 @@ public void process(Exchange exchange) { private void createCollection(Exchange exchange) throws Exception { final Message in = exchange.getMessage(); - String collectionName; - if (in.getHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, String.class) != null) { - collectionName = in.getHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, String.class); - } else { - collectionName = getEndpoint().getCollection(); - } - - WeaviateClass collection = WeaviateClass.builder().className(collectionName).build(); - - Result res = client.misc().readyChecker().run(); - - Result result = client.schema().classCreator().withClass(collection).run(); - populateResponse(result, exchange); + String collectionName = resolveCollectionName(in); + client.collections.create(collectionName); + populateResponse(true, exchange); } private void create(Exchange exchange) throws Exception { final Message in = exchange.getMessage(); List elements = in.getMandatoryBody(List.class); - // Check the headers for a collection name. Use the endpoint's - // collection name by default - String collectionName; - if (in.getHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, String.class) != null) { - collectionName = in.getHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, String.class); - } else { - collectionName = getEndpoint().getCollection(); - } + String collectionName = resolveCollectionName(in); HashMap props = in.getHeader(WeaviateVectorDbHeaders.PROPERTIES, HashMap.class); Float[] vectors = (Float[]) elements.toArray(new Float[0]); + float[] primitiveVectors = toPrimitiveFloatArray(vectors); - Result result = client.data().creator() - .withClassName(collectionName) - .withVector(vectors) - .withProperties(props) - .run(); + CollectionHandle> collection = client.collections.use(collectionName); + + WeaviateObject> result; + if (props != null) { + result = collection.data.insert(props, obj -> obj.vectors(Vectors.of(primitiveVectors))); + } else { + result = collection.data.insert(Map.of(), obj -> obj.vectors(Vectors.of(primitiveVectors))); + } populateResponse(result, exchange); } @@ -153,118 +134,76 @@ private void updateById(Exchange exchange) throws Exception { List elements = in.getMandatoryBody(List.class); String indexId = ExchangeHelper.getMandatoryHeader(exchange, WeaviateVectorDbHeaders.INDEX_ID, String.class); - // Check the headers for a collection name. Use the endpoint's - // collection name by default - String collectionName; - if (in.getHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, String.class) != null) { - collectionName = in.getHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, String.class); - } else { - collectionName = getEndpoint().getCollection(); - } + String collectionName = resolveCollectionName(in); Float[] vectors = (Float[]) elements.toArray(new Float[0]); + float[] primitiveVectors = toPrimitiveFloatArray(vectors); HashMap props = in.getHeader(WeaviateVectorDbHeaders.PROPERTIES, HashMap.class); - ObjectUpdater ou = client.data().updater(); + CollectionHandle> collection = client.collections.use(collectionName); boolean updateWithMerge = in.getHeader(WeaviateVectorDbHeaders.UPDATE_WITH_MERGE, true, Boolean.class); if (updateWithMerge) { - ou.withMerge(); + collection.data.update(indexId, + u -> u.properties(props != null ? props : Map.of()).vectors(Vectors.of(primitiveVectors))); + } else { + collection.data.replace(indexId, + r -> r.properties(props != null ? props : Map.of()).vectors(Vectors.of(primitiveVectors))); } - Result result = ou - .withID(indexId) - .withClassName(collectionName) - .withVector(vectors) - .withProperties(props) - .run(); - - populateResponse(result, exchange); + populateResponse(true, exchange); } private void deleteById(Exchange exchange) throws Exception { final Message in = exchange.getMessage(); String indexId = ExchangeHelper.getMandatoryHeader(exchange, WeaviateVectorDbHeaders.INDEX_ID, String.class); - // Check the headers for a collection name. Use the endpoint's - // collection name by default - String collectionName; - if (in.getHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, String.class) != null) { - collectionName = in.getHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, String.class); - } else { - collectionName = getEndpoint().getCollection(); - } - Result result = this.client.data().deleter() - .withClassName(collectionName) - .withID(indexId) - .run(); - populateResponse(result, exchange); + String collectionName = resolveCollectionName(in); + + CollectionHandle> collection = client.collections.use(collectionName); + boolean deleted = collection.data.deleteById(indexId); + populateResponse(deleted, exchange); } private void deleteCollection(Exchange exchange) throws Exception { final Message in = exchange.getMessage(); - String collectionName; - if (in.getHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, String.class) != null) { - collectionName = in.getHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, String.class); - } else { - collectionName = getEndpoint().getCollection(); - } - - Result result = this.client.schema().classDeleter() - .withClassName(collectionName) - .run(); + String collectionName = resolveCollectionName(in); - populateResponse(result, exchange); + client.collections.delete(collectionName); + populateResponse(true, exchange); } private void query(Exchange exchange) throws Exception { final Message in = exchange.getMessage(); List elements = in.getMandatoryBody(List.class); - // topK default of 10 - int topK = 10; - if (in.getHeader(WeaviateVectorDbHeaders.QUERY_TOP_K, Integer.class) != null) { - topK = in.getHeader(WeaviateVectorDbHeaders.QUERY_TOP_K, Integer.class); - } + int topK = in.getHeader(WeaviateVectorDbHeaders.QUERY_TOP_K, 10, Integer.class); - // Check the headers for a collection name. Use the endpoint's - // collection name by default - String collectionName; - if (in.getHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, String.class) != null) { - collectionName = in.getHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, String.class); - } else { - collectionName = getEndpoint().getCollection(); - } + String collectionName = resolveCollectionName(in); Float[] vectors = (Float[]) elements.toArray(new Float[0]); + float[] primitiveVectors = toPrimitiveFloatArray(vectors); + + CollectionHandle> collection = client.collections.use(collectionName); - NearVectorArgument nearVectorArg = NearVectorArgument.builder() - .vector(vectors) - .build(); + final int limit = topK; - Fields fields; + QueryResponse> result; if (in.getHeader(WeaviateVectorDbHeaders.FIELDS, HashMap.class) != null) { HashMap fieldToSearch = in.getHeader(WeaviateVectorDbHeaders.FIELDS, HashMap.class); + String[] returnProps = fieldToSearch.keySet().toArray(new String[0]); - Field[] fieldArray - = fieldToSearch.keySet().stream().map(k -> Field.builder().name(k).build()).toArray(Field[]::new); - fields = Fields.builder().fields(fieldArray).build(); - + result = collection.query.nearVector( + primitiveVectors, + nv -> nv.limit(limit).returnProperties(returnProps)); } else { - fields = Fields.builder().fields(new Field[0]).build(); + result = collection.query.nearVector( + primitiveVectors, + nv -> nv.limit(limit)); } - String query = GetBuilder.builder() - .className(collectionName) - .fields(fields) - .withNearVectorFilter(nearVectorArg) - .limit(topK) - .build() - .buildQuery(); - - Result result = client.graphQL().raw().withQuery(query).run(); populateResponse(result, exchange); } @@ -272,19 +211,11 @@ private void queryById(Exchange exchange) throws Exception { final Message in = exchange.getMessage(); String indexId = ExchangeHelper.getMandatoryHeader(exchange, WeaviateVectorDbHeaders.INDEX_ID, String.class); - // Check the headers for a collection name. Use the endpoint's - // collection name by default - String collectionName; - if (in.getHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, String.class) != null) { - collectionName = in.getHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, String.class); - } else { - collectionName = getEndpoint().getCollection(); - } + String collectionName = resolveCollectionName(in); + + CollectionHandle> collection = client.collections.use(collectionName); - Result> result = client.data().objectsGetter() - .withClassName(collectionName) - .withID(indexId) - .run(); + Optional>> result = collection.query.fetchObjectById(indexId); populateResponse(result, exchange); } @@ -295,12 +226,26 @@ private void queryById(Exchange exchange) throws Exception { // // *************************************** - private CamelContext getCamelContext() { - return getEndpoint().getCamelContext(); + private String resolveCollectionName(Message in) { + if (in.getHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, String.class) != null) { + return in.getHeader(WeaviateVectorDbHeaders.COLLECTION_NAME, String.class); + } + return getEndpoint().getCollection(); } - private void populateResponse(Result r, Exchange exchange) { + private void populateResponse(Object r, Exchange exchange) { Message out = exchange.getMessage(); out.setBody(r); } + + private static float[] toPrimitiveFloatArray(Float[] boxed) { + float[] result = new float[boxed.length]; + for (int i = 0; i < boxed.length; i++) { + if (boxed[i] == null) { + throw new IllegalArgumentException("Vector element at index " + i + " is null"); + } + result[i] = boxed[i]; + } + return result; + } } diff --git a/components/camel-ai/camel-weaviate/src/test/java/org/apache/camel/component/weaviate/WeaviateComponentConfigurationTest.java b/components/camel-ai/camel-weaviate/src/test/java/org/apache/camel/component/weaviate/WeaviateComponentConfigurationTest.java index 0520eadc0b461..d5e272673e40c 100644 --- a/components/camel-ai/camel-weaviate/src/test/java/org/apache/camel/component/weaviate/WeaviateComponentConfigurationTest.java +++ b/components/camel-ai/camel-weaviate/src/test/java/org/apache/camel/component/weaviate/WeaviateComponentConfigurationTest.java @@ -38,13 +38,15 @@ void createEndpointWithMinimalConfiguration() throws Exception { WeaviateVectorDbComponent component = context.getComponent("weaviate", WeaviateVectorDbComponent.class); WeaviateVectorDbEndpoint endpoint = (WeaviateVectorDbEndpoint) component .createEndpoint( - "weaviate://test-collection?host=localhost:7979&scheme=http&proxyHost=localhost&proxyPort=7777&proxyScheme=https&apiKey=foobar123"); + "weaviate://test-collection?host=localhost:7979&scheme=http&proxyHost=localhost&proxyPort=7777&proxyScheme=https&apiKey=foobar123&grpcHost=localhost&grpcPort=50052"); assertEquals("localhost:7979", endpoint.getConfiguration().getHost()); assertEquals("http", endpoint.getConfiguration().getScheme()); assertEquals("localhost", endpoint.getConfiguration().getProxyHost()); assertEquals(7777, endpoint.getConfiguration().getProxyPort()); assertEquals("https", endpoint.getConfiguration().getProxyScheme()); assertEquals("foobar123", endpoint.getConfiguration().getApiKey()); + assertEquals("localhost", endpoint.getConfiguration().getGrpcHost()); + assertEquals(50052, endpoint.getConfiguration().getGrpcPort()); } @Test diff --git a/components/camel-ai/camel-weaviate/src/test/java/org/apache/camel/component/weaviate/WeaviateTestSupport.java b/components/camel-ai/camel-weaviate/src/test/java/org/apache/camel/component/weaviate/WeaviateTestSupport.java index b393158defc73..9d656bde01421 100644 --- a/components/camel-ai/camel-weaviate/src/test/java/org/apache/camel/component/weaviate/WeaviateTestSupport.java +++ b/components/camel-ai/camel-weaviate/src/test/java/org/apache/camel/component/weaviate/WeaviateTestSupport.java @@ -34,6 +34,8 @@ protected CamelContext createCamelContext() throws Exception { WeaviateVectorDbComponent component = context.getComponent("weaviate", WeaviateVectorDbComponent.class); component.getConfiguration().setHost(WEAVIATE.getWeaviateHost() + ":" + WEAVIATE.getWeaviatePort()); + component.getConfiguration().setGrpcHost(WEAVIATE.getWeaviateHost()); + component.getConfiguration().setGrpcPort(WEAVIATE.getWeaviateGrpcPort()); return context; } diff --git a/components/camel-ai/camel-weaviate/src/test/java/org/apache/camel/component/weaviate/it/WeaviateContainerIT.java b/components/camel-ai/camel-weaviate/src/test/java/org/apache/camel/component/weaviate/it/WeaviateContainerIT.java index e94fcfb03b47b..f487fb156a05a 100644 --- a/components/camel-ai/camel-weaviate/src/test/java/org/apache/camel/component/weaviate/it/WeaviateContainerIT.java +++ b/components/camel-ai/camel-weaviate/src/test/java/org/apache/camel/component/weaviate/it/WeaviateContainerIT.java @@ -20,10 +20,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; -import io.weaviate.client.base.Result; -import io.weaviate.client.v1.data.model.WeaviateObject; -import io.weaviate.client.v1.graphql.model.GraphQLResponse; +import io.weaviate.client6.v1.api.collections.WeaviateObject; +import io.weaviate.client6.v1.api.collections.query.QueryResponse; import org.apache.camel.Exchange; import org.apache.camel.component.weaviate.WeaviateTestSupport; import org.apache.camel.component.weaviate.WeaviateVectorDbAction; @@ -60,10 +60,9 @@ public void createCollection() { .request(Exchange.class); assertThat(result).isNotNull(); - Result res = (Result) result.getIn().getBody(); - assertThat(res.hasErrors()).isFalse(); - assertThat(res.getResult()).isTrue(); assertThat(result.getException()).isNull(); + Boolean res = result.getIn().getBody(Boolean.class); + assertThat(res).isTrue(); } @Test @@ -85,12 +84,13 @@ public void create() { .request(Exchange.class); assertThat(result).isNotNull(); + assertThat(result.getException()).isNull(); - Result res = (Result) result.getIn().getBody(); - CREATEID = res.getResult().getId(); + WeaviateObject> res = (WeaviateObject>) result.getIn().getBody(); + CREATEID = res.uuid(); - assertThat(res.hasErrors()).isFalse(); assertThat(res).isNotNull(); + assertThat(CREATEID).isNotNull(); } @Test @@ -111,11 +111,10 @@ public void updateById() { .request(Exchange.class); assertThat(result).isNotNull(); - - Result res = (Result) result.getIn().getBody(); - assertThat(res.hasErrors()).isFalse(); - assertThat(res.getResult()).isTrue(); assertThat(result.getException()).isNull(); + + Boolean res = result.getIn().getBody(Boolean.class); + assertThat(res).isTrue(); } @Test @@ -130,18 +129,16 @@ public void queryById() { assertThat(result).isNotNull(); assertThat(result.getException()).isNull(); - Result res = (Result) result.getIn().getBody(); - assertThat(res.hasErrors()).isFalse(); - - List list = (List) res.getResult(); - for (WeaviateObject wo : list) { - Map map = wo.getProperties(); - assertThat(map).containsKey("sky"); - assertThat(map).containsKey("age"); - assertThat(map).containsKey("dog"); - } + Optional>> res + = (Optional>>) result.getIn().getBody(); + assertThat(res).isPresent(); + WeaviateObject> wo = res.get(); + Map props = wo.properties(); + assertThat(props).containsKey("sky"); + assertThat(props).containsKey("age"); + assertThat(props).containsKey("dog"); } @SuppressWarnings("unchecked") @@ -165,9 +162,12 @@ public void queryByVector() { .request(Exchange.class); assertThat(result).isNotNull(); - GraphQLResponse qlResponse = (GraphQLResponse) result.getIn().getBody(Result.class).getResult(); - var dataMap = (Map>>>) qlResponse.getData(); - assertThat(dataMap.get("Get").get(COLLECTION).get(0)).containsEntry("sky", "blue"); + assertThat(result.getException()).isNull(); + + QueryResponse> queryResponse + = (QueryResponse>) result.getIn().getBody(); + assertThat(queryResponse.objects()).isNotEmpty(); + assertThat(queryResponse.objects().get(0).properties()).containsEntry("sky", "blue"); } @Test @@ -182,11 +182,9 @@ public void deleteById() { .request(Exchange.class); assertThat(result).isNotNull(); - Result res = (Result) result.getIn().getBody(); - - assertThat(res.hasErrors()).isFalse(); - assertThat(res.getResult()).isTrue(); assertThat(result.getException()).isNull(); + Boolean res = result.getIn().getBody(Boolean.class); + assertThat(res).isTrue(); } @Test @@ -199,10 +197,9 @@ public void deleteCollection() { .request(Exchange.class); assertThat(result).isNotNull(); - Result res = (Result) result.getIn().getBody(); - assertThat(res.hasErrors()).isFalse(); - assertThat(res.getResult()).isTrue(); assertThat(result.getException()).isNull(); + Boolean res = result.getIn().getBody(Boolean.class); + assertThat(res).isTrue(); } private String getUri() { diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_22.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_22.adoc index d6671ed93817a..a22eb51610b08 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_22.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_22.adoc @@ -94,3 +94,63 @@ payloads, enable stream caching on the route. * The `bufferSize` option has been removed. It only configured the previous streaming implementation and no longer has any effect with authenticated encryption. + +=== camel-weaviate - potential breaking change + +The Weaviate Java client has been upgraded from v5 (`io.weaviate:client`) to v6 (`io.weaviate:client6`). +This is a major upgrade with several breaking changes. + +==== Scheme default value + +The `scheme` endpoint option now defaults to `http`. Previously it had no default. Routes that relied on the old +behavior (passing no scheme) should explicitly set `scheme=http` or `scheme=https` as appropriate. + +==== Collection name case sensitivity + +Weaviate v6 requires collection names to start with an uppercase letter (PascalCase). Existing routes using lowercase +collection names (e.g., `weaviate:myCollection`) must be updated to use PascalCase (e.g., `weaviate:MyCollection`). + +==== New gRPC configuration options + +The v6 client requires a gRPC connection in addition to the HTTP connection. +Two new endpoint options have been added: `grpcHost` (defaults to the HTTP host) and `grpcPort` (defaults to `50051`). +When connecting to a Weaviate server that exposes gRPC on a non-default host or port, these options must be set explicitly. + +==== Response body types changed + +The exchange body returned by the producer no longer uses `io.weaviate.client.base.Result` wrappers. +Code that casts the response body must be updated: + +[cols="1,2,2", options="header"] +|=== +| Action | Old body type | New body type + +| `CREATE_COLLECTION` | `Result` | `Boolean` +| `CREATE` | `Result` | `WeaviateObject>` +| `UPDATE_BY_ID` | `Result` | `Boolean` +| `DELETE_BY_ID` | `Result` | `Boolean` +| `DELETE_COLLECTION` | `Result` | `Boolean` +| `QUERY` | `Result` | `QueryResponse>` +| `QUERY_BY_ID` | `Result>` | `Optional>>` +|=== + +The `WeaviateObject` class has also moved from `io.weaviate.client.v1.data.model` to `io.weaviate.client6.v1.api.collections` +and uses accessor methods (`uuid()`, `properties()`) instead of getter methods (`getId()`, `getProperties()`). + +==== Client type changed + +The autowired client type has changed from `io.weaviate.client.WeaviateClient` to `io.weaviate.client6.v1.api.WeaviateClient`. +Routes that inject a custom `WeaviateClient` instance must update the import and construction to use the v6 API +(e.g., `WeaviateClient.connectToCustom(...)` instead of `new WeaviateClient(config)`). + +==== Readiness check removed + +The v5 client performed a readiness check (`misc().readyChecker()`) during client creation and threw an exception +if the Weaviate server was not ready. The v6 client no longer performs this check at startup. Errors will now +surface on the first operation instead of during endpoint initialization. + +==== Proxy configuration deprecated + +The v6 client no longer supports HTTP proxy configuration. +The `proxyHost`, `proxyPort`, and `proxyScheme` endpoint options are deprecated and have no effect. +They will be removed in a future release. diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/WeaviateComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/WeaviateComponentBuilderFactory.java index 0b8bf19cafd2f..659bbd09cf1e9 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/WeaviateComponentBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/WeaviateComponentBuilderFactory.java @@ -81,6 +81,38 @@ default WeaviateComponentBuilder configuration(org.apache.camel.component.weavia return this; } + /** + * gRPC host for Weaviate server connection. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: producer + * + * @param grpcHost the value to set + * @return the dsl builder + */ + default WeaviateComponentBuilder grpcHost(java.lang.String grpcHost) { + doSetProperty("grpcHost", grpcHost); + return this; + } + + + /** + * gRPC port for Weaviate server connection. + * + * The option is a: <code>java.lang.Integer</code> type. + * + * Default: 50051 + * Group: producer + * + * @param grpcPort the value to set + * @return the dsl builder + */ + default WeaviateComponentBuilder grpcPort(java.lang.Integer grpcPort) { + doSetProperty("grpcPort", grpcPort); + return this; + } + /** * Weaviate server host to connect to. * @@ -131,6 +163,7 @@ default WeaviateComponentBuilder lazyStartProducer(boolean lazyStartProducer) { * @param proxyHost the value to set * @return the dsl builder */ + @Deprecated default WeaviateComponentBuilder proxyHost(java.lang.String proxyHost) { doSetProperty("proxyHost", proxyHost); return this; @@ -146,6 +179,7 @@ default WeaviateComponentBuilder proxyHost(java.lang.String proxyHost) { * @param proxyPort the value to set * @return the dsl builder */ + @Deprecated default WeaviateComponentBuilder proxyPort(java.lang.Integer proxyPort) { doSetProperty("proxyPort", proxyPort); return this; @@ -161,16 +195,19 @@ default WeaviateComponentBuilder proxyPort(java.lang.Integer proxyPort) { * @param proxyScheme the value to set * @return the dsl builder */ + @Deprecated default WeaviateComponentBuilder proxyScheme(java.lang.String proxyScheme) { doSetProperty("proxyScheme", proxyScheme); return this; } + /** * Scheme used to connect to weaviate. * * The option is a: <code>java.lang.String</code> type. * + * Default: http * Group: producer * * @param scheme the value to set @@ -225,6 +262,8 @@ protected boolean setPropertyOnComponent( switch (name) { case "apiKey": getOrCreateConfiguration((WeaviateVectorDbComponent) component).setApiKey((java.lang.String) value); return true; case "configuration": ((WeaviateVectorDbComponent) component).setConfiguration((org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration) value); return true; + case "grpcHost": getOrCreateConfiguration((WeaviateVectorDbComponent) component).setGrpcHost((java.lang.String) value); return true; + case "grpcPort": getOrCreateConfiguration((WeaviateVectorDbComponent) component).setGrpcPort((java.lang.Integer) value); return true; case "host": getOrCreateConfiguration((WeaviateVectorDbComponent) component).setHost((java.lang.String) value); return true; case "lazyStartProducer": ((WeaviateVectorDbComponent) component).setLazyStartProducer((boolean) value); return true; case "proxyHost": getOrCreateConfiguration((WeaviateVectorDbComponent) component).setProxyHost((java.lang.String) value); return true; diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/WeaviateVectorDbEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/WeaviateVectorDbEndpointBuilderFactory.java index c8f2614c3a7b4..2d913352efa45 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/WeaviateVectorDbEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/WeaviateVectorDbEndpointBuilderFactory.java @@ -58,6 +58,51 @@ default WeaviateVectorDbEndpointBuilder apiKey(String apiKey) { doSetProperty("apiKey", apiKey); return this; } + /** + * gRPC host for Weaviate server connection. + * + * The option is a: java.lang.String type. + * + * Group: producer + * + * @param grpcHost the value to set + * @return the dsl builder + */ + default WeaviateVectorDbEndpointBuilder grpcHost(String grpcHost) { + doSetProperty("grpcHost", grpcHost); + return this; + } + /** + * gRPC port for Weaviate server connection. + * + * The option is a: java.lang.Integer type. + * + * Default: 50051 + * Group: producer + * + * @param grpcPort the value to set + * @return the dsl builder + */ + default WeaviateVectorDbEndpointBuilder grpcPort(Integer grpcPort) { + doSetProperty("grpcPort", grpcPort); + return this; + } + /** + * gRPC port for Weaviate server connection. + * + * The option will be converted to a java.lang.Integer + * type. + * + * Default: 50051 + * Group: producer + * + * @param grpcPort the value to set + * @return the dsl builder + */ + default WeaviateVectorDbEndpointBuilder grpcPort(String grpcPort) { + doSetProperty("grpcPort", grpcPort); + return this; + } /** * Weaviate server host to connect to. * @@ -82,6 +127,7 @@ default WeaviateVectorDbEndpointBuilder host(String host) { * @param proxyHost the value to set * @return the dsl builder */ + @Deprecated default WeaviateVectorDbEndpointBuilder proxyHost(String proxyHost) { doSetProperty("proxyHost", proxyHost); return this; @@ -96,6 +142,7 @@ default WeaviateVectorDbEndpointBuilder proxyHost(String proxyHost) { * @param proxyPort the value to set * @return the dsl builder */ + @Deprecated default WeaviateVectorDbEndpointBuilder proxyPort(Integer proxyPort) { doSetProperty("proxyPort", proxyPort); return this; @@ -111,6 +158,7 @@ default WeaviateVectorDbEndpointBuilder proxyPort(Integer proxyPort) { * @param proxyPort the value to set * @return the dsl builder */ + @Deprecated default WeaviateVectorDbEndpointBuilder proxyPort(String proxyPort) { doSetProperty("proxyPort", proxyPort); return this; @@ -125,6 +173,7 @@ default WeaviateVectorDbEndpointBuilder proxyPort(String proxyPort) { * @param proxyScheme the value to set * @return the dsl builder */ + @Deprecated default WeaviateVectorDbEndpointBuilder proxyScheme(String proxyScheme) { doSetProperty("proxyScheme", proxyScheme); return this; @@ -134,6 +183,7 @@ default WeaviateVectorDbEndpointBuilder proxyScheme(String proxyScheme) { * * The option is a: java.lang.String type. * + * Default: http * Group: producer * * @param scheme the value to set diff --git a/parent/pom.xml b/parent/pom.xml index 706b90a8ce7b4..bb5bddce19b0f 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -517,7 +517,7 @@ 3.1 2.4.1 4.5.28 - 5.5.0 + 6.2.1 5.0.0 4.10.0 3.13.2 diff --git a/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/common/WeaviateProperties.java b/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/common/WeaviateProperties.java index 8e7e81c237401..28b8ebfc4c75b 100644 --- a/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/common/WeaviateProperties.java +++ b/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/common/WeaviateProperties.java @@ -21,6 +21,7 @@ public final class WeaviateProperties { public static final String WEAVIATE_ENDPOINT_URL = "weaviate.endpoint.url"; public static final String WEAVIATE_ENDPOINT_HOST = "weaviate.endpoint.host"; public static final String WEAVIATE_ENDPOINT_PORT = "weaviate.endpoint.port"; + public static final String WEAVIATE_ENDPOINT_GRPC_PORT = "weaviate.endpoint.grpc.port"; public static final String WEAVIATE_CONTAINER = "weaviate.container"; private WeaviateProperties() { diff --git a/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateInfraService.java b/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateInfraService.java index c7ab38adf5e7b..ff69da5b832c7 100644 --- a/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateInfraService.java +++ b/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateInfraService.java @@ -28,4 +28,6 @@ public interface WeaviateInfraService extends InfrastructureService { String getWeaviateHost(); int getWeaviatePort(); + + int getWeaviateGrpcPort(); } diff --git a/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateLocalContainerInfraService.java b/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateLocalContainerInfraService.java index 89cb225940e89..ac73c7768688e 100644 --- a/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateLocalContainerInfraService.java +++ b/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateLocalContainerInfraService.java @@ -75,6 +75,7 @@ public void registerProperties() { System.setProperty(WeaviateProperties.WEAVIATE_ENDPOINT_URL, getWeaviateEndpointUrl()); System.setProperty(WeaviateProperties.WEAVIATE_ENDPOINT_HOST, getWeaviateHost()); System.setProperty(WeaviateProperties.WEAVIATE_ENDPOINT_PORT, String.valueOf(getWeaviatePort())); + System.setProperty(WeaviateProperties.WEAVIATE_ENDPOINT_GRPC_PORT, String.valueOf(getWeaviateGrpcPort())); } @Override @@ -123,4 +124,9 @@ public int getWeaviatePort() { } return url.getPort(); } + + @Override + public int getWeaviateGrpcPort() { + return container.getMappedPort(50051); + } } diff --git a/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateRemoteInfraService.java b/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateRemoteInfraService.java index 8a7a8157e6f55..23d8f990de100 100644 --- a/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateRemoteInfraService.java +++ b/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateRemoteInfraService.java @@ -49,4 +49,9 @@ public String getWeaviateHost() { public int getWeaviatePort() { return Integer.parseInt(System.getProperty(WeaviateProperties.WEAVIATE_ENDPOINT_PORT)); } + + @Override + public int getWeaviateGrpcPort() { + return Integer.parseInt(System.getProperty(WeaviateProperties.WEAVIATE_ENDPOINT_GRPC_PORT, "50051")); + } } diff --git a/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateServiceFactory.java b/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateServiceFactory.java index fcc6e8b376c80..1e57ee82322c1 100644 --- a/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateServiceFactory.java +++ b/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateServiceFactory.java @@ -44,6 +44,11 @@ public String getWeaviateHost() { public int getWeaviatePort() { return getService().getWeaviatePort(); } + + @Override + public int getWeaviateGrpcPort() { + return getService().getWeaviateGrpcPort(); + } } public static SimpleTestServiceBuilder builder() {