yuxiqian commented on code in PR #4507: URL: https://github.com/apache/flink-cdc/pull/4507#discussion_r3800904054
########## flink-cdc-pipeline-model/flink-cdc-pipeline-model-openai-compatible/pom.xml: ########## @@ -0,0 +1,140 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.apache.flink</groupId> + <artifactId>flink-cdc-pipeline-model-parent</artifactId> + <version>${revision}</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + + <artifactId>flink-cdc-pipeline-model-openai-compatible</artifactId> + <packaging>jar</packaging> + + <properties> + <jackson.version>2.18.2</jackson.version> + <openai-java.version>4.32.0</openai-java.version> + <okhttp.version>4.12.0</okhttp.version> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.flink</groupId> + <artifactId>flink-cdc-common</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>com.openai</groupId> + <artifactId>openai-java</artifactId> + <version>${openai-java.version}</version> + </dependency> + + <dependency> + <groupId>com.squareup.okhttp3</groupId> + <artifactId>mockwebserver</artifactId> + <version>${okhttp.version}</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <executions> + <execution> + <id>shade-flink</id> + <configuration> + <artifactSet> + <includes combine.children="append"> + <include>com.fasterxml:*</include> + <include>com.fasterxml.jackson.core:*</include> + <include>com.fasterxml.jackson.datatype:*</include> + <include>com.fasterxml.jackson.module:*</include> + <include>com.github.victools:*</include> + <include>com.google.errorprone:*</include> + <include>com.openai:*</include> + <include>com.squareup.okhttp3:*</include> + <include>com.squareup.okio:*</include> + <include>io.swagger.core.v3:*</include> + <include>org.jetbrains:*</include> + <include>org.jetbrains.kotlin:*</include> + </includes> + </artifactSet> + <filters combine.children="append"> + <filter> + <artifact>*:*</artifact> + <excludes> + <exclude>META-INF/versions/**/module-info.class</exclude> + </excludes> + </filter> + </filters> + <transformers> + <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> + </transformers> + <relocations> + <relocation> + <pattern>com.fasterxml</pattern> + <shadedPattern>org.apache.flink.cdc.models.openai.shaded.com.fasterxml</shadedPattern> + </relocation> + <relocation> + <pattern>com.github.victools</pattern> + <shadedPattern>org.apache.flink.cdc.models.openai.shaded.com.github.victools</shadedPattern> + </relocation> + <relocation> + <pattern>com.google.errorprone</pattern> + <shadedPattern>org.apache.flink.cdc.models.openai.shaded.com.google.errorprone</shadedPattern> + </relocation> + <relocation> + <pattern>com.openai</pattern> + <shadedPattern>org.apache.flink.cdc.models.openai.shaded.com.openai</shadedPattern> + </relocation> + <relocation> + <pattern>io.swagger</pattern> + <shadedPattern>org.apache.flink.cdc.models.openai.shaded.io.swagger</shadedPattern> + </relocation> + <relocation> Review Comment: We may not relocate Kotlin and OpenAI library or the following exception may occur: ``` Caused by: java.lang.IllegalStateException: Resource not found in classpath: org/apache/flink/cdc/models/openai/shaded/kotlin/org.apache.flink.cdc.models.openai.shaded.kotlin.org.apache.flink.cdc.models.openai.shaded.kotlin_builtins at org.apache.flink.cdc.models.openai.shaded.kotlin.reflect.jvm.internal.impl.serialization.deserialization.builtins.BuiltInsLoaderImpl.createBuiltInPackageFragmentProvider(BuiltInsLoaderImpl.kt:59) at org.apache.flink.cdc.models.openai.shaded.kotlin.reflect.jvm.internal.impl.serialization.deserialization.builtins.BuiltInsLoaderImpl.createPackageFragmentProvider(BuiltInsLoaderImpl.kt:35) at org.apache.flink.cdc.models.openai.shaded.kotlin.reflect.jvm.internal.impl.builtins.KotlinBuiltIns.createBuiltInsModule(KotlinBuiltIns.java:105) at org.apache.flink.cdc.models.openai.shaded.kotlin.reflect.jvm.internal.impl.builtins.DefaultBuiltIns.<init>(DefaultBuiltIns.kt:24) at org.apache.flink.cdc.models.openai.shaded.kotlin.reflect.jvm.internal.impl.builtins.DefaultBuiltIns.<init>(DefaultBuiltIns.kt:21) at org.apache.flink.cdc.models.openai.shaded.kotlin.reflect.jvm.internal.impl.builtins.DefaultBuiltIns.<clinit>(DefaultBuiltIns.kt:31) ... 89 more ``` ``` Caused by: java.lang.ClassNotFoundException: com.openai.core.JsonField at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:476) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:594) at org.apache.flink.util.FlinkUserCodeClassLoader.loadClassWithoutExceptionHandling(FlinkUserCodeClassLoader.java:67) at org.apache.flink.util.ChildFirstClassLoader.loadClassWithoutExceptionHandling(ChildFirstClassLoader.java:74) at org.apache.flink.util.FlinkUserCodeClassLoader.loadClass(FlinkUserCodeClassLoader.java:51) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:527) at kotlin.reflect.jvm.internal.KDeclarationContainerImpl.parseType(KDeclarationContainerImpl.kt:273) at kotlin.reflect.jvm.internal.KDeclarationContainerImpl.loadParameterTypes(KDeclarationContainerImpl.kt:264) at kotlin.reflect.jvm.internal.KDeclarationContainerImpl.findConstructorBySignature(KDeclarationContainerImpl.kt:226) at kotlin.reflect.jvm.internal.KFunctionImpl$caller$2.invoke(KFunctionImpl.kt:66) at kotlin.reflect.jvm.internal.KFunctionImpl$caller$2.invoke(KFunctionImpl.kt:61) at kotlin.reflect.jvm.internal.ReflectProperties$LazyVal.invoke(ReflectProperties.java:63) at kotlin.reflect.jvm.internal.ReflectProperties$Val.getValue(ReflectProperties.java:32) at kotlin.reflect.jvm.internal.KFunctionImpl.getCaller(KFunctionImpl.kt:61) at kotlin.reflect.jvm.ReflectJvmMapping.getJavaConstructor(ReflectJvmMapping.kt:71) at kotlin.reflect.jvm.ReflectJvmMapping.getKotlinFunction(ReflectJvmMapping.kt:146) at org.apache.flink.cdc.models.openai.shaded.com.fasterxml.jackson.module.kotlin.ReflectionCacheKt.valueClassAwareKotlinFunction(ReflectionCache.kt:160) at org.apache.flink.cdc.models.openai.shaded.com.fasterxml.jackson.module.kotlin.ReflectionCacheKt.access$valueClassAwareKotlinFunction(ReflectionCache.kt:1) at org.apache.flink.cdc.models.openai.shaded.com.fasterxml.jackson.module.kotlin.ReflectionCache.kotlinFromJava(ReflectionCache.kt:66) at org.apache.flink.cdc.models.openai.shaded.com.fasterxml.jackson.module.kotlin.KotlinNamesAnnotationIntrospector.findDefaultCreator(KotlinNamesAnnotationIntrospector.kt:111) at org.apache.flink.cdc.models.openai.shaded.com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair.findDefaultCreator(AnnotationIntrospectorPair.java:746) at org.apache.flink.cdc.models.openai.shaded.com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector._addCreators(POJOPropertiesCollector.java:669) at org.apache.flink.cdc.models.openai.shaded.com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector.collectAll(POJOPropertiesCollector.java:451) at org.apache.flink.cdc.models.openai.shaded.com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector.getJsonValueAccessor(POJOPropertiesCollector.java:269) at org.apache.flink.cdc.models.openai.shaded.com.fasterxml.jackson.databind.introspect.BasicBeanDescription.findJsonValueAccessor(BasicBeanDescription.java:248) at org.apache.flink.cdc.models.openai.shaded.com.fasterxml.jackson.databind.ser.BasicSerializerFactory.findSerializerByAnnotations(BasicSerializerFactory.java:393) at org.apache.flink.cdc.models.openai.shaded.com.fasterxml.jackson.databind.ser.BeanSerializerFactory._createSerializer2(BeanSerializerFactory.java:225) at org.apache.flink.cdc.models.openai.shaded.com.fasterxml.jackson.databind.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:174) at org.apache.flink.cdc.models.openai.shaded.com.fasterxml.jackson.databind.SerializerProvider._createUntypedSerializer(SerializerProvider.java:1523) at org.apache.flink.cdc.models.openai.shaded.com.fasterxml.jackson.databind.SerializerProvider._createAndCacheUntypedSerializer(SerializerProvider.java:1471) at org.apache.flink.cdc.models.openai.shaded.com.fasterxml.jackson.databind.SerializerProvider.findValueSerializer(SerializerProvider.java:578) at org.apache.flink.cdc.models.openai.shaded.com.fasterxml.jackson.databind.SerializerProvider.findTypedValueSerializer(SerializerProvider.java:856) at org.apache.flink.cdc.models.openai.shaded.com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:330) at org.apache.flink.cdc.models.openai.shaded.com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4811) ... 56 more ``` ########## flink-cdc-pipeline-model/pom.xml: ########## @@ -31,6 +31,7 @@ limitations under the License. <modules> <module>flink-cdc-pipeline-model-legacy</module> <module>flink-cdc-pipeline-model-dummy</module> + <module>flink-cdc-pipeline-model-openai-compatible</module> </modules> Review Comment: Seems we didn't include the discovered AI model client jars into the composer translator, causing the following exception: ``` Caused by: java.lang.ClassNotFoundException: org.apache.flink.cdc.models.openai.OpenAiCompatibleModelClient ``` Though we can use `--jar` as a workaround, it would be better by calling `FlinkEnvironmentUtils.addJar(...)` for discovered AI model client jars, just like source and sink factories. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
