[FLINK-36525][transform] Support for AI Model Integration for Data Processing (#3753)
parent
c969957f02
commit
06154e9674
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.apache.flink.cdc.common.udf;
|
||||
|
||||
import org.apache.flink.cdc.common.configuration.Configuration;
|
||||
|
||||
/** Context for initialization of {@link UserDefinedFunction}. */
|
||||
public interface UserDefinedFunctionContext {
|
||||
|
||||
Configuration configuration();
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.apache.flink.cdc.composer.definition;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Common properties of model.
|
||||
*
|
||||
* <p>A transformation definition contains:
|
||||
*
|
||||
* <ul>
|
||||
* <li>modelName: The name of function.
|
||||
* <li>className: The model to transform data.
|
||||
* <li>parameters: The parameters that used to configure the model.
|
||||
* </ul>
|
||||
*/
|
||||
public class ModelDef {
|
||||
|
||||
private final String modelName;
|
||||
|
||||
private final String className;
|
||||
|
||||
private final Map<String, String> parameters;
|
||||
|
||||
public ModelDef(String modelName, String className, Map<String, String> parameters) {
|
||||
this.modelName = modelName;
|
||||
this.className = className;
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public String getModelName() {
|
||||
return modelName;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public Map<String, String> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ModelDef modelDef = (ModelDef) o;
|
||||
return Objects.equals(modelName, modelDef.modelName)
|
||||
&& Objects.equals(className, modelDef.className)
|
||||
&& Objects.equals(parameters, modelDef.parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(modelName, className, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ModelDef{"
|
||||
+ "name='"
|
||||
+ modelName
|
||||
+ '\''
|
||||
+ ", model='"
|
||||
+ className
|
||||
+ '\''
|
||||
+ ", parameters="
|
||||
+ parameters
|
||||
+ '}';
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
<?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>
|
||||
<artifactId>flink-cdc-parent</artifactId>
|
||||
<groupId>org.apache.flink</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>flink-cdc-pipeline-model</artifactId>
|
||||
<properties>
|
||||
<langchain4j.version>0.23.0</langchain4j.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.flink</groupId>
|
||||
<artifactId>flink-cdc-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.flink</groupId>
|
||||
<artifactId>flink-test-utils-junit</artifactId>
|
||||
<version>${flink.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dev.langchain4j</groupId>
|
||||
<artifactId>langchain4j</artifactId>
|
||||
<version>${langchain4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dev.langchain4j</groupId>
|
||||
<artifactId>langchain4j-open-ai</artifactId>
|
||||
<version>${langchain4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.theokanning.openai-gpt3-java</groupId>
|
||||
<artifactId>service</artifactId>
|
||||
<version>0.12.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test-jar</id>
|
||||
<goals>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.apache.flink.cdc.runtime.model;
|
||||
|
||||
import org.apache.flink.cdc.common.configuration.ConfigOption;
|
||||
import org.apache.flink.cdc.common.configuration.ConfigOptions;
|
||||
|
||||
/** Options of built-in model. */
|
||||
public class ModelOptions {
|
||||
|
||||
// Options for Open AI Model.
|
||||
public static final ConfigOption<String> OPENAI_MODEL_NAME =
|
||||
ConfigOptions.key("openai.model")
|
||||
.stringType()
|
||||
.noDefaultValue()
|
||||
.withDescription("Name of model to be called.");
|
||||
|
||||
public static final ConfigOption<String> OPENAI_HOST =
|
||||
ConfigOptions.key("openai.host")
|
||||
.stringType()
|
||||
.noDefaultValue()
|
||||
.withDescription("Host of the Model server to be connected.");
|
||||
|
||||
public static final ConfigOption<String> OPENAI_API_KEY =
|
||||
ConfigOptions.key("openai.apikey")
|
||||
.stringType()
|
||||
.noDefaultValue()
|
||||
.withDescription("Api Key for verification of the Model server.");
|
||||
|
||||
public static final ConfigOption<String> OPENAI_CHAT_PROMPT =
|
||||
ConfigOptions.key("openai.chat.prompt")
|
||||
.stringType()
|
||||
.noDefaultValue()
|
||||
.withDescription("Prompt for chat using OpenAI.");
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.apache.flink.cdc.runtime.model;
|
||||
|
||||
import org.apache.flink.cdc.common.configuration.Configuration;
|
||||
import org.apache.flink.cdc.common.types.DataType;
|
||||
import org.apache.flink.cdc.common.types.DataTypes;
|
||||
import org.apache.flink.cdc.common.udf.UserDefinedFunction;
|
||||
import org.apache.flink.cdc.common.udf.UserDefinedFunctionContext;
|
||||
import org.apache.flink.cdc.common.utils.Preconditions;
|
||||
|
||||
import dev.langchain4j.data.message.UserMessage;
|
||||
import dev.langchain4j.model.openai.OpenAiChatModel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.apache.flink.cdc.runtime.model.ModelOptions.OPENAI_API_KEY;
|
||||
import static org.apache.flink.cdc.runtime.model.ModelOptions.OPENAI_CHAT_PROMPT;
|
||||
import static org.apache.flink.cdc.runtime.model.ModelOptions.OPENAI_HOST;
|
||||
import static org.apache.flink.cdc.runtime.model.ModelOptions.OPENAI_MODEL_NAME;
|
||||
|
||||
/**
|
||||
* A {@link UserDefinedFunction} that use Model defined by OpenAI to generate text, refer to <a
|
||||
* href="https://docs.langchain4j.dev/integrations/language-models/open-ai/">docs</a>}.
|
||||
*/
|
||||
public class OpenAIChatModel implements UserDefinedFunction {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(OpenAIChatModel.class);
|
||||
|
||||
private OpenAiChatModel chatModel;
|
||||
|
||||
private String modelName;
|
||||
|
||||
private String host;
|
||||
|
||||
private String prompt;
|
||||
|
||||
public String eval(String input) {
|
||||
return chat(input);
|
||||
}
|
||||
|
||||
private String chat(String input) {
|
||||
if (input == null || input.trim().isEmpty()) {
|
||||
LOG.warn("Empty or null input provided for embedding.");
|
||||
return "";
|
||||
}
|
||||
if (prompt != null) {
|
||||
input = prompt + ": " + input;
|
||||
}
|
||||
return chatModel
|
||||
.generate(Collections.singletonList(new UserMessage(input)))
|
||||
.content()
|
||||
.text();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType getReturnType() {
|
||||
return DataTypes.STRING();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(UserDefinedFunctionContext userDefinedFunctionContext) {
|
||||
Configuration modelOptions = userDefinedFunctionContext.configuration();
|
||||
this.modelName = modelOptions.get(OPENAI_MODEL_NAME);
|
||||
Preconditions.checkNotNull(modelName, OPENAI_MODEL_NAME.key() + " should not be empty.");
|
||||
this.host = modelOptions.get(OPENAI_HOST);
|
||||
Preconditions.checkNotNull(host, OPENAI_HOST.key() + " should not be empty.");
|
||||
String apiKey = modelOptions.get(OPENAI_API_KEY);
|
||||
Preconditions.checkNotNull(apiKey, OPENAI_API_KEY.key() + " should not be empty.");
|
||||
this.prompt = modelOptions.get(OPENAI_CHAT_PROMPT);
|
||||
LOG.info("Opening OpenAIChatModel " + modelName + " " + host);
|
||||
this.chatModel =
|
||||
OpenAiChatModel.builder().apiKey(apiKey).baseUrl(host).modelName(modelName).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
LOG.info("Closed OpenAIChatModel " + modelName + " " + host);
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.apache.flink.cdc.runtime.model;
|
||||
|
||||
import org.apache.flink.cdc.common.configuration.Configuration;
|
||||
import org.apache.flink.cdc.common.data.ArrayData;
|
||||
import org.apache.flink.cdc.common.data.GenericArrayData;
|
||||
import org.apache.flink.cdc.common.types.DataType;
|
||||
import org.apache.flink.cdc.common.types.DataTypes;
|
||||
import org.apache.flink.cdc.common.udf.UserDefinedFunction;
|
||||
import org.apache.flink.cdc.common.udf.UserDefinedFunctionContext;
|
||||
import org.apache.flink.cdc.common.utils.Preconditions;
|
||||
|
||||
import dev.langchain4j.data.document.Metadata;
|
||||
import dev.langchain4j.data.embedding.Embedding;
|
||||
import dev.langchain4j.data.segment.TextSegment;
|
||||
import dev.langchain4j.model.openai.OpenAiEmbeddingModel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.apache.flink.cdc.runtime.model.ModelOptions.OPENAI_API_KEY;
|
||||
import static org.apache.flink.cdc.runtime.model.ModelOptions.OPENAI_HOST;
|
||||
import static org.apache.flink.cdc.runtime.model.ModelOptions.OPENAI_MODEL_NAME;
|
||||
|
||||
/**
|
||||
* A {@link UserDefinedFunction} that use Model defined by OpenAI to generate vector data, refer to
|
||||
* <a href="https://docs.langchain4j.dev/integrations/language-models/open-ai/">docs</a>}.
|
||||
*/
|
||||
public class OpenAIEmbeddingModel implements UserDefinedFunction {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(OpenAIEmbeddingModel.class);
|
||||
|
||||
private String modelName;
|
||||
|
||||
private String host;
|
||||
|
||||
private OpenAiEmbeddingModel embeddingModel;
|
||||
|
||||
public ArrayData eval(String input) {
|
||||
return getEmbedding(input);
|
||||
}
|
||||
|
||||
private ArrayData getEmbedding(String input) {
|
||||
if (input == null || input.trim().isEmpty()) {
|
||||
LOG.debug("Empty or null input provided for embedding.");
|
||||
return new GenericArrayData(new Float[0]);
|
||||
}
|
||||
|
||||
TextSegment textSegment = new TextSegment(input, new Metadata());
|
||||
|
||||
List<Embedding> embeddings =
|
||||
embeddingModel.embedAll(Collections.singletonList(textSegment)).content();
|
||||
|
||||
if (embeddings != null && !embeddings.isEmpty()) {
|
||||
List<Float> embeddingList = embeddings.get(0).vectorAsList();
|
||||
Float[] embeddingArray = embeddingList.toArray(new Float[0]);
|
||||
return new GenericArrayData(embeddingArray);
|
||||
} else {
|
||||
LOG.warn("No embedding results returned for input: {}", input);
|
||||
return new GenericArrayData(new Float[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType getReturnType() {
|
||||
return DataTypes.ARRAY(DataTypes.FLOAT());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(UserDefinedFunctionContext userDefinedFunctionContext) {
|
||||
Configuration modelOptions = userDefinedFunctionContext.configuration();
|
||||
this.modelName = modelOptions.get(OPENAI_MODEL_NAME);
|
||||
Preconditions.checkNotNull(modelName, OPENAI_MODEL_NAME.key() + " should not be empty.");
|
||||
this.host = modelOptions.get(OPENAI_HOST);
|
||||
Preconditions.checkNotNull(host, OPENAI_HOST.key() + " should not be empty.");
|
||||
String apiKey = modelOptions.get(OPENAI_API_KEY);
|
||||
Preconditions.checkNotNull(apiKey, OPENAI_API_KEY.key() + " should not be empty.");
|
||||
LOG.info("Opening OpenAIEmbeddingModel " + modelName + " " + host);
|
||||
this.embeddingModel =
|
||||
OpenAiEmbeddingModel.builder()
|
||||
.apiKey(apiKey)
|
||||
.baseUrl(host)
|
||||
.modelName(modelName)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
LOG.info("Closed OpenAIEmbeddingModel " + modelName + " " + host);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.apache.flink.cdc.runtime.model;
|
||||
|
||||
import org.apache.flink.cdc.common.configuration.Configuration;
|
||||
import org.apache.flink.cdc.common.udf.UserDefinedFunctionContext;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** A test for {@link OpenAIChatModel}. */
|
||||
public class TestOpenAIChatModel {
|
||||
@Test
|
||||
public void testEval() {
|
||||
OpenAIChatModel openAIChatModel = new OpenAIChatModel();
|
||||
Configuration configuration = new Configuration();
|
||||
configuration.set(ModelOptions.OPENAI_HOST, "http://langchain4j.dev/demo/openai/v1");
|
||||
configuration.set(ModelOptions.OPENAI_API_KEY, "demo");
|
||||
configuration.set(ModelOptions.OPENAI_MODEL_NAME, "gpt-4o-mini");
|
||||
UserDefinedFunctionContext userDefinedFunctionContext = () -> configuration;
|
||||
openAIChatModel.open(userDefinedFunctionContext);
|
||||
String response = openAIChatModel.eval("Who invented the electric light?");
|
||||
Assertions.assertFalse(response.isEmpty());
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.apache.flink.cdc.runtime.model;
|
||||
|
||||
import org.apache.flink.cdc.common.configuration.Configuration;
|
||||
import org.apache.flink.cdc.common.data.ArrayData;
|
||||
import org.apache.flink.cdc.common.udf.UserDefinedFunctionContext;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** A test for {@link OpenAIEmbeddingModel}. */
|
||||
public class TestOpenAIEmbeddingModel {
|
||||
|
||||
@Test
|
||||
public void testEval() {
|
||||
OpenAIEmbeddingModel openAIEmbeddingModel = new OpenAIEmbeddingModel();
|
||||
Configuration configuration = new Configuration();
|
||||
configuration.set(ModelOptions.OPENAI_HOST, "http://langchain4j.dev/demo/openai/v1");
|
||||
configuration.set(ModelOptions.OPENAI_API_KEY, "demo");
|
||||
configuration.set(ModelOptions.OPENAI_MODEL_NAME, "text-embedding-3-small");
|
||||
UserDefinedFunctionContext userDefinedFunctionContext = () -> configuration;
|
||||
openAIEmbeddingModel.open(userDefinedFunctionContext);
|
||||
ArrayData arrayData =
|
||||
openAIEmbeddingModel.eval("Flink CDC is a streaming data integration tool");
|
||||
Assertions.assertNotNull(arrayData);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue