This is an automated email from the ASF dual-hosted git repository. xtsong pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/flink-agents.git
commit 18dfef91a7572570d887dee91620884123d2f2d2 Author: WenjinXie <[email protected]> AuthorDate: Wed Jan 14 15:16:17 2026 +0800 [api][java] Provide constant to point a resource to avoid importing integration package. fix --- .../apache/flink/agents/api/resource/Constant.java | 64 ++++++++++++++++++++++ .../test/ChatModelIntegrationAgent.java | 44 ++++++++------- .../test/EmbeddingIntegrationAgent.java | 15 ++--- .../agents/integration/test/ReActAgentTest.java | 9 ++- .../test/VectorStoreIntegrationAgent.java | 14 ++--- .../flink/agents/examples/ReActAgentExample.java | 4 +- .../examples/agents/CustomTypesAndResources.java | 5 +- .../examples/agents/ProductSuggestionAgent.java | 4 +- .../examples/agents/ReviewAnalysisAgent.java | 4 +- 9 files changed, 115 insertions(+), 48 deletions(-) diff --git a/api/src/main/java/org/apache/flink/agents/api/resource/Constant.java b/api/src/main/java/org/apache/flink/agents/api/resource/Constant.java new file mode 100644 index 00000000..4f893f8d --- /dev/null +++ b/api/src/main/java/org/apache/flink/agents/api/resource/Constant.java @@ -0,0 +1,64 @@ +/* + * 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.agents.api.resource; + +/** + * Constant strings for pointing a resource implementation in {@link ResourceDescriptor}. + * + * <p>TODO: Could use service provider interface to simplify the definition of constant in the + * future. + */ +public class Constant { + // Built-in ChatModel + // ollama + public static String OLLAMA_CHAT_MODEL_CONNECTION = + "org.apache.flink.agents.integrations.chatmodels.ollama.OllamaChatModelConnection"; + public static String OLLAMA_CHAT_MODEL = + "org.apache.flink.agents.integrations.chatmodels.ollama.OllamaChatModelSetup"; + + // anthropic + public static String ANTHROPIC_CHAT_MODEL_CONNECTION = + "org.apache.flink.agents.integrations.chatmodels.anthropic.AnthropicChatModelConnection"; + public static String ANTHROPIC_CHAT_MODEL = + "org.apache.flink.agents.integrations.chatmodels.anthropic.AnthropicChatModelSetup"; + + // Azure + public static String AZURE_CHAT_MODEL_CONNECTION = + "org.apache.flink.agents.integrations.chatmodels.anthropic.AzureAIChatModelConnection"; + public static String AZURE_CHAT_MODEL = + "org.apache.flink.agents.integrations.chatmodels.anthropic.AzureAIChatModelSetup"; + + // OpenAI + public static String OPENAI_CHAT_MODEL_CONNECTION = + "org.apache.flink.agents.integrations.chatmodels.openai.OpenAIChatModelConnection"; + public static String OPENAI_CHAT_MODEL = + "org.apache.flink.agents.integrations.chatmodels.openai.OpenAIChatModelSetup"; + + // Built-in EmbeddingModel + // ollama + public static String OLLAMA_EMBEDDING_MODEL_CONNECTION = + "org.apache.flink.agents.integrations.embeddingmodels.ollama.OllamaEmbeddingModelConnection"; + public static String OLLAMA_EMBEDDING_MODEL = + "org.apache.flink.agents.integrations.embeddingmodels.ollama.OllamaEmbeddingModelSetup"; + + // Built-in VectorStore + // elasticsearch + public static String ELASTICSEARCH_VECTOR_STORE = + "org.apache.flink.agents.integrations.vectorstores.elasticsearch.ElasticsearchVectorStore"; +} diff --git a/e2e-test/flink-agents-end-to-end-tests-integration/src/test/java/org/apache/flink/agents/integration/test/ChatModelIntegrationAgent.java b/e2e-test/flink-agents-end-to-end-tests-integration/src/test/java/org/apache/flink/agents/integration/test/ChatModelIntegrationAgent.java index 23a50b52..75b097f0 100644 --- a/e2e-test/flink-agents-end-to-end-tests-integration/src/test/java/org/apache/flink/agents/integration/test/ChatModelIntegrationAgent.java +++ b/e2e-test/flink-agents-end-to-end-tests-integration/src/test/java/org/apache/flink/agents/integration/test/ChatModelIntegrationAgent.java @@ -28,33 +28,36 @@ import org.apache.flink.agents.api.annotation.Tool; import org.apache.flink.agents.api.annotation.ToolParam; import org.apache.flink.agents.api.chat.messages.ChatMessage; import org.apache.flink.agents.api.chat.messages.MessageRole; +import org.apache.flink.agents.api.chat.model.BaseChatModelConnection; +import org.apache.flink.agents.api.chat.model.BaseChatModelSetup; import org.apache.flink.agents.api.context.RunnerContext; import org.apache.flink.agents.api.event.ChatRequestEvent; import org.apache.flink.agents.api.event.ChatResponseEvent; import org.apache.flink.agents.api.resource.ResourceDescriptor; import org.apache.flink.agents.api.resource.ResourceType; -import org.apache.flink.agents.integrations.chatmodels.anthropic.AnthropicChatModelConnection; -import org.apache.flink.agents.integrations.chatmodels.anthropic.AnthropicChatModelSetup; -import org.apache.flink.agents.integrations.chatmodels.azureai.AzureAIChatModelConnection; -import org.apache.flink.agents.integrations.chatmodels.azureai.AzureAIChatModelSetup; -import org.apache.flink.agents.integrations.chatmodels.ollama.OllamaChatModelConnection; -import org.apache.flink.agents.integrations.chatmodels.ollama.OllamaChatModelSetup; -import org.apache.flink.agents.integrations.chatmodels.openai.OpenAIChatModelConnection; -import org.apache.flink.agents.integrations.chatmodels.openai.OpenAIChatModelSetup; import java.util.Collections; import java.util.List; +import static org.apache.flink.agents.api.resource.Constant.ANTHROPIC_CHAT_MODEL; +import static org.apache.flink.agents.api.resource.Constant.ANTHROPIC_CHAT_MODEL_CONNECTION; +import static org.apache.flink.agents.api.resource.Constant.AZURE_CHAT_MODEL; +import static org.apache.flink.agents.api.resource.Constant.AZURE_CHAT_MODEL_CONNECTION; +import static org.apache.flink.agents.api.resource.Constant.OLLAMA_CHAT_MODEL; +import static org.apache.flink.agents.api.resource.Constant.OLLAMA_CHAT_MODEL_CONNECTION; +import static org.apache.flink.agents.api.resource.Constant.OPENAI_CHAT_MODEL; +import static org.apache.flink.agents.api.resource.Constant.OPENAI_CHAT_MODEL_CONNECTION; + /** * Agent example that integrates an external Ollama chat model into Flink Agents. * * <p>This class demonstrates how to: * * <ul> - * <li>Declare a chat model connection using {@link ChatModelConnection} metadata pointing to - * {@link OllamaChatModelConnection} - * <li>Declare a chat model setup using {@link ChatModelSetup} metadata pointing to {@link - * OllamaChatModelSetup} + * <li>Declare a chat model connection using {@link ChatModelConnection} metadata pointing to an + * implementation of {@link BaseChatModelConnection} + * <li>Declare a chat model setup using {@link ChatModelSetup} metadata pointing to an + * implementation of {@link BaseChatModelSetup} * <li>Expose callable tools via {@link Tool} annotated static methods (temperature conversion, * BMI, random number) * <li>Fetch a chat model from the {@link RunnerContext} and perform a single-turn chat @@ -73,26 +76,25 @@ public class ChatModelIntegrationAgent extends Agent { public static ResourceDescriptor chatModelConnection() { String provider = System.getProperty("MODEL_PROVIDER", "OLLAMA"); if (provider.equals("OLLAMA")) { - return ResourceDescriptor.Builder.newBuilder(OllamaChatModelConnection.class.getName()) + return ResourceDescriptor.Builder.newBuilder(OLLAMA_CHAT_MODEL_CONNECTION) .addInitialArgument("endpoint", "http://localhost:11434") .addInitialArgument("requestTimeout", 240) .build(); } else if (provider.equals("AZURE")) { String endpoint = System.getenv().get("AZURE_ENDPOINT"); String apiKey = System.getenv().get("AZURE_API_KEY"); - return ResourceDescriptor.Builder.newBuilder(AzureAIChatModelConnection.class.getName()) + return ResourceDescriptor.Builder.newBuilder(AZURE_CHAT_MODEL_CONNECTION) .addInitialArgument("endpoint", endpoint) .addInitialArgument("apiKey", apiKey) .build(); } else if (provider.equals("OPENAI")) { String apiKey = System.getenv().get("OPENAI_API_KEY"); - return ResourceDescriptor.Builder.newBuilder(OpenAIChatModelConnection.class.getName()) + return ResourceDescriptor.Builder.newBuilder(OPENAI_CHAT_MODEL_CONNECTION) .addInitialArgument("api_key", apiKey) .build(); } else if (provider.equals("ANTHROPIC")) { String apiKey = System.getenv().get("ANTHROPIC_API_KEY"); - return ResourceDescriptor.Builder.newBuilder( - AnthropicChatModelConnection.class.getName()) + return ResourceDescriptor.Builder.newBuilder(ANTHROPIC_CHAT_MODEL_CONNECTION) .addInitialArgument("api_key", apiKey) .addInitialArgument("timeout", 240) .build(); @@ -106,7 +108,7 @@ public class ChatModelIntegrationAgent extends Agent { String provider = System.getProperty("MODEL_PROVIDER", "OLLAMA"); if (provider.equals("OLLAMA")) { - return ResourceDescriptor.Builder.newBuilder(OllamaChatModelSetup.class.getName()) + return ResourceDescriptor.Builder.newBuilder(OLLAMA_CHAT_MODEL) .addInitialArgument("connection", "chatModelConnection") .addInitialArgument("model", OLLAMA_MODEL) .addInitialArgument( @@ -114,7 +116,7 @@ public class ChatModelIntegrationAgent extends Agent { List.of("calculateBMI", "convertTemperature", "createRandomNumber")) .build(); } else if (provider.equals("AZURE")) { - return ResourceDescriptor.Builder.newBuilder(AzureAIChatModelSetup.class.getName()) + return ResourceDescriptor.Builder.newBuilder(AZURE_CHAT_MODEL) .addInitialArgument("connection", "chatModelConnection") .addInitialArgument("model", "gpt-4o") .addInitialArgument( @@ -122,7 +124,7 @@ public class ChatModelIntegrationAgent extends Agent { List.of("calculateBMI", "convertTemperature", "createRandomNumber")) .build(); } else if (provider.equals("ANTHROPIC")) { - return ResourceDescriptor.Builder.newBuilder(AnthropicChatModelSetup.class.getName()) + return ResourceDescriptor.Builder.newBuilder(ANTHROPIC_CHAT_MODEL) .addInitialArgument("connection", "chatModelConnection") .addInitialArgument("model", "claude-sonnet-4-20250514") .addInitialArgument( @@ -130,7 +132,7 @@ public class ChatModelIntegrationAgent extends Agent { List.of("calculateBMI", "convertTemperature", "createRandomNumber")) .build(); } else if (provider.equals("OPENAI")) { - return ResourceDescriptor.Builder.newBuilder(OpenAIChatModelSetup.class.getName()) + return ResourceDescriptor.Builder.newBuilder(OPENAI_CHAT_MODEL) .addInitialArgument("connection", "chatModelConnection") .addInitialArgument("model", "gpt-4o-mini") .addInitialArgument( diff --git a/e2e-test/flink-agents-end-to-end-tests-integration/src/test/java/org/apache/flink/agents/integration/test/EmbeddingIntegrationAgent.java b/e2e-test/flink-agents-end-to-end-tests-integration/src/test/java/org/apache/flink/agents/integration/test/EmbeddingIntegrationAgent.java index a5ee7a4b..8a7bcec0 100644 --- a/e2e-test/flink-agents-end-to-end-tests-integration/src/test/java/org/apache/flink/agents/integration/test/EmbeddingIntegrationAgent.java +++ b/e2e-test/flink-agents-end-to-end-tests-integration/src/test/java/org/apache/flink/agents/integration/test/EmbeddingIntegrationAgent.java @@ -28,13 +28,15 @@ import org.apache.flink.agents.api.annotation.EmbeddingModelSetup; import org.apache.flink.agents.api.annotation.Tool; import org.apache.flink.agents.api.annotation.ToolParam; import org.apache.flink.agents.api.context.RunnerContext; +import org.apache.flink.agents.api.embedding.model.BaseEmbeddingModelSetup; import org.apache.flink.agents.api.resource.ResourceDescriptor; -import org.apache.flink.agents.integrations.embeddingmodels.ollama.OllamaEmbeddingModelConnection; -import org.apache.flink.agents.integrations.embeddingmodels.ollama.OllamaEmbeddingModelSetup; import java.util.HashMap; import java.util.Map; +import static org.apache.flink.agents.api.resource.Constant.OLLAMA_EMBEDDING_MODEL; +import static org.apache.flink.agents.api.resource.Constant.OLLAMA_EMBEDDING_MODEL_CONNECTION; + /** * Integration test agent for verifying embedding functionality with Ollama models. * @@ -52,8 +54,7 @@ public class EmbeddingIntegrationAgent extends Agent { public static ResourceDescriptor embeddingConnection() { String provider = System.getProperty("MODEL_PROVIDER", "OLLAMA"); if (provider.equals("OLLAMA")) { - return ResourceDescriptor.Builder.newBuilder( - OllamaEmbeddingModelConnection.class.getName()) + return ResourceDescriptor.Builder.newBuilder(OLLAMA_EMBEDDING_MODEL_CONNECTION) .addInitialArgument("host", "http://localhost:11434") .addInitialArgument("timeout", 60) .build(); @@ -66,7 +67,7 @@ public class EmbeddingIntegrationAgent extends Agent { public static ResourceDescriptor embeddingModel() { String provider = System.getProperty("MODEL_PROVIDER", "OLLAMA"); if (provider.equals("OLLAMA")) { - return ResourceDescriptor.Builder.newBuilder(OllamaEmbeddingModelSetup.class.getName()) + return ResourceDescriptor.Builder.newBuilder(OLLAMA_EMBEDDING_MODEL) .addInitialArgument("connection", "embeddingConnection") .addInitialArgument("model", OLLAMA_MODEL) .build(); @@ -200,8 +201,8 @@ public class EmbeddingIntegrationAgent extends Agent { /** Generate embedding using the framework's resource system for testing. */ private static float[] generateEmbeddingForTest(String text, RunnerContext ctx) { try { - OllamaEmbeddingModelSetup embeddingModel = - (OllamaEmbeddingModelSetup) + BaseEmbeddingModelSetup embeddingModel = + (BaseEmbeddingModelSetup) ctx.getResource( "embeddingModel", org.apache.flink.agents.api.resource.ResourceType diff --git a/e2e-test/flink-agents-end-to-end-tests-integration/src/test/java/org/apache/flink/agents/integration/test/ReActAgentTest.java b/e2e-test/flink-agents-end-to-end-tests-integration/src/test/java/org/apache/flink/agents/integration/test/ReActAgentTest.java index b4adee82..7d4a005d 100644 --- a/e2e-test/flink-agents-end-to-end-tests-integration/src/test/java/org/apache/flink/agents/integration/test/ReActAgentTest.java +++ b/e2e-test/flink-agents-end-to-end-tests-integration/src/test/java/org/apache/flink/agents/integration/test/ReActAgentTest.java @@ -28,8 +28,6 @@ import org.apache.flink.agents.api.prompt.Prompt; import org.apache.flink.agents.api.resource.ResourceDescriptor; import org.apache.flink.agents.api.resource.ResourceType; import org.apache.flink.agents.api.tools.Tool; -import org.apache.flink.agents.integrations.chatmodels.ollama.OllamaChatModelConnection; -import org.apache.flink.agents.integrations.chatmodels.ollama.OllamaChatModelSetup; import org.apache.flink.api.common.functions.MapFunction; import org.apache.flink.api.common.typeinfo.BasicTypeInfo; import org.apache.flink.api.common.typeinfo.TypeInformation; @@ -51,6 +49,8 @@ import java.util.List; import static org.apache.flink.agents.api.agents.AgentExecutionOptions.ERROR_HANDLING_STRATEGY; import static org.apache.flink.agents.api.agents.AgentExecutionOptions.MAX_RETRIES; +import static org.apache.flink.agents.api.resource.Constant.OLLAMA_CHAT_MODEL; +import static org.apache.flink.agents.api.resource.Constant.OLLAMA_CHAT_MODEL_CONNECTION; import static org.apache.flink.agents.integration.test.OllamaPreparationUtils.pullModel; public class ReActAgentTest { @@ -94,8 +94,7 @@ public class ReActAgentTest { .addResource( "ollama", ResourceType.CHAT_MODEL_CONNECTION, - ResourceDescriptor.Builder.newBuilder( - OllamaChatModelConnection.class.getName()) + ResourceDescriptor.Builder.newBuilder(OLLAMA_CHAT_MODEL_CONNECTION) .addInitialArgument("endpoint", "http://localhost:11434") .addInitialArgument("requestTimeout", 240) .build()) @@ -156,7 +155,7 @@ public class ReActAgentTest { // create ReAct agent. private static Agent getAgent() { ResourceDescriptor chatModelDescriptor = - ResourceDescriptor.Builder.newBuilder(OllamaChatModelSetup.class.getName()) + ResourceDescriptor.Builder.newBuilder(OLLAMA_CHAT_MODEL) .addInitialArgument("connection", "ollama") .addInitialArgument("model", OLLAMA_MODEL) .addInitialArgument("tools", List.of("add", "multiply")) diff --git a/e2e-test/flink-agents-end-to-end-tests-integration/src/test/java/org/apache/flink/agents/integration/test/VectorStoreIntegrationAgent.java b/e2e-test/flink-agents-end-to-end-tests-integration/src/test/java/org/apache/flink/agents/integration/test/VectorStoreIntegrationAgent.java index 94dbb1d0..a4752957 100644 --- a/e2e-test/flink-agents-end-to-end-tests-integration/src/test/java/org/apache/flink/agents/integration/test/VectorStoreIntegrationAgent.java +++ b/e2e-test/flink-agents-end-to-end-tests-integration/src/test/java/org/apache/flink/agents/integration/test/VectorStoreIntegrationAgent.java @@ -30,14 +30,15 @@ import org.apache.flink.agents.api.event.ContextRetrievalRequestEvent; import org.apache.flink.agents.api.event.ContextRetrievalResponseEvent; import org.apache.flink.agents.api.resource.ResourceDescriptor; import org.apache.flink.agents.api.vectorstores.Document; -import org.apache.flink.agents.integrations.embeddingmodels.ollama.OllamaEmbeddingModelConnection; -import org.apache.flink.agents.integrations.embeddingmodels.ollama.OllamaEmbeddingModelSetup; -import org.apache.flink.agents.integrations.vectorstores.elasticsearch.ElasticsearchVectorStore; import java.util.HashMap; import java.util.List; import java.util.Map; +import static org.apache.flink.agents.api.resource.Constant.ELASTICSEARCH_VECTOR_STORE; +import static org.apache.flink.agents.api.resource.Constant.OLLAMA_EMBEDDING_MODEL; +import static org.apache.flink.agents.api.resource.Constant.OLLAMA_EMBEDDING_MODEL_CONNECTION; + public class VectorStoreIntegrationAgent extends Agent { public static final String OLLAMA_MODEL = "nomic-embed-text"; @@ -45,8 +46,7 @@ public class VectorStoreIntegrationAgent extends Agent { public static ResourceDescriptor embeddingConnection() { final String provider = System.getProperty("MODEL_PROVIDER", "OLLAMA"); if (provider.equals("OLLAMA")) { - return ResourceDescriptor.Builder.newBuilder( - OllamaEmbeddingModelConnection.class.getName()) + return ResourceDescriptor.Builder.newBuilder(OLLAMA_EMBEDDING_MODEL_CONNECTION) .addInitialArgument("host", "http://localhost:11434") .addInitialArgument("timeout", 60) .build(); @@ -59,7 +59,7 @@ public class VectorStoreIntegrationAgent extends Agent { public static ResourceDescriptor embeddingModel() { String provider = System.getProperty("MODEL_PROVIDER", "OLLAMA"); if (provider.equals("OLLAMA")) { - return ResourceDescriptor.Builder.newBuilder(OllamaEmbeddingModelSetup.class.getName()) + return ResourceDescriptor.Builder.newBuilder(OLLAMA_EMBEDDING_MODEL) .addInitialArgument("connection", "embeddingConnection") .addInitialArgument("model", OLLAMA_MODEL) .build(); @@ -73,7 +73,7 @@ public class VectorStoreIntegrationAgent extends Agent { final String provider = System.getProperty("VECTOR_STORE_PROVIDER", "ELASTICSEARCH"); if (provider.equals("ELASTICSEARCH")) { final ResourceDescriptor.Builder builder = - ResourceDescriptor.Builder.newBuilder(ElasticsearchVectorStore.class.getName()) + ResourceDescriptor.Builder.newBuilder(ELASTICSEARCH_VECTOR_STORE) .addInitialArgument("embedding_model", "embeddingModel") .addInitialArgument("host", System.getenv("ES_HOST")) .addInitialArgument("index", System.getenv("ES_INDEX")) diff --git a/examples/src/main/java/org/apache/flink/agents/examples/ReActAgentExample.java b/examples/src/main/java/org/apache/flink/agents/examples/ReActAgentExample.java index 23af1bbe..f3b7f5f2 100644 --- a/examples/src/main/java/org/apache/flink/agents/examples/ReActAgentExample.java +++ b/examples/src/main/java/org/apache/flink/agents/examples/ReActAgentExample.java @@ -26,7 +26,6 @@ import org.apache.flink.agents.api.annotation.ToolParam; import org.apache.flink.agents.api.resource.ResourceDescriptor; import org.apache.flink.agents.api.resource.ResourceType; import org.apache.flink.agents.examples.agents.CustomTypesAndResources; -import org.apache.flink.agents.integrations.chatmodels.ollama.OllamaChatModelSetup; import org.apache.flink.api.common.eventtime.WatermarkStrategy; import org.apache.flink.connector.file.src.FileSource; import org.apache.flink.connector.file.src.reader.TextLineInputFormat; @@ -39,6 +38,7 @@ import java.io.File; import java.time.Duration; import java.util.Collections; +import static org.apache.flink.agents.api.resource.Constant.OLLAMA_CHAT_MODEL; import static org.apache.flink.agents.examples.WorkflowSingleAgentExample.copyResource; /** @@ -144,7 +144,7 @@ public class ReActAgentExample { // Create ReAct agent. private static ReActAgent getReActAgent() { return new ReActAgent( - ResourceDescriptor.Builder.newBuilder(OllamaChatModelSetup.class.getName()) + ResourceDescriptor.Builder.newBuilder(OLLAMA_CHAT_MODEL) .addInitialArgument("connection", "ollamaChatModelConnection") .addInitialArgument("model", "qwen3:8b") .addInitialArgument( diff --git a/examples/src/main/java/org/apache/flink/agents/examples/agents/CustomTypesAndResources.java b/examples/src/main/java/org/apache/flink/agents/examples/agents/CustomTypesAndResources.java index fd3b8aef..0e1c96ce 100644 --- a/examples/src/main/java/org/apache/flink/agents/examples/agents/CustomTypesAndResources.java +++ b/examples/src/main/java/org/apache/flink/agents/examples/agents/CustomTypesAndResources.java @@ -25,11 +25,12 @@ import org.apache.flink.agents.api.chat.messages.ChatMessage; import org.apache.flink.agents.api.chat.messages.MessageRole; import org.apache.flink.agents.api.prompt.Prompt; import org.apache.flink.agents.api.resource.ResourceDescriptor; -import org.apache.flink.agents.integrations.chatmodels.ollama.OllamaChatModelConnection; import java.util.Arrays; import java.util.List; +import static org.apache.flink.agents.api.resource.Constant.OLLAMA_CHAT_MODEL_CONNECTION; + /** Custom types and resources for the quickstart agents. */ public class CustomTypesAndResources { @@ -111,7 +112,7 @@ public class CustomTypesAndResources { // Ollama chat model connection descriptor public static final ResourceDescriptor OLLAMA_SERVER_DESCRIPTOR = - ResourceDescriptor.Builder.newBuilder(OllamaChatModelConnection.class.getName()) + ResourceDescriptor.Builder.newBuilder(OLLAMA_CHAT_MODEL_CONNECTION) .addInitialArgument("requestTimeout", 120) .addInitialArgument("endpoint", "http://localhost:11434") .build(); diff --git a/examples/src/main/java/org/apache/flink/agents/examples/agents/ProductSuggestionAgent.java b/examples/src/main/java/org/apache/flink/agents/examples/agents/ProductSuggestionAgent.java index 2a020b5e..aca3138a 100644 --- a/examples/src/main/java/org/apache/flink/agents/examples/agents/ProductSuggestionAgent.java +++ b/examples/src/main/java/org/apache/flink/agents/examples/agents/ProductSuggestionAgent.java @@ -33,12 +33,12 @@ import org.apache.flink.agents.api.event.ChatRequestEvent; import org.apache.flink.agents.api.event.ChatResponseEvent; import org.apache.flink.agents.api.resource.ResourceDescriptor; import org.apache.flink.agents.examples.agents.CustomTypesAndResources.ProductReviewSummary; -import org.apache.flink.agents.integrations.chatmodels.ollama.OllamaChatModelSetup; import java.util.ArrayList; import java.util.List; import java.util.Map; +import static org.apache.flink.agents.api.resource.Constant.OLLAMA_CHAT_MODEL; import static org.apache.flink.agents.examples.agents.CustomTypesAndResources.PRODUCT_SUGGESTION_PROMPT; /** @@ -57,7 +57,7 @@ public class ProductSuggestionAgent extends Agent { @ChatModelSetup public static ResourceDescriptor generateSuggestionModel() { - return ResourceDescriptor.Builder.newBuilder(OllamaChatModelSetup.class.getName()) + return ResourceDescriptor.Builder.newBuilder(OLLAMA_CHAT_MODEL) .addInitialArgument("connection", "ollamaChatModelConnection") .addInitialArgument("model", "qwen3:8b") .addInitialArgument("extract_reasoning", "true") diff --git a/examples/src/main/java/org/apache/flink/agents/examples/agents/ReviewAnalysisAgent.java b/examples/src/main/java/org/apache/flink/agents/examples/agents/ReviewAnalysisAgent.java index 77dfe2d7..246d67ef 100644 --- a/examples/src/main/java/org/apache/flink/agents/examples/agents/ReviewAnalysisAgent.java +++ b/examples/src/main/java/org/apache/flink/agents/examples/agents/ReviewAnalysisAgent.java @@ -34,13 +34,13 @@ import org.apache.flink.agents.api.context.RunnerContext; import org.apache.flink.agents.api.event.ChatRequestEvent; import org.apache.flink.agents.api.event.ChatResponseEvent; import org.apache.flink.agents.api.resource.ResourceDescriptor; -import org.apache.flink.agents.integrations.chatmodels.ollama.OllamaChatModelSetup; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; +import static org.apache.flink.agents.api.resource.Constant.OLLAMA_CHAT_MODEL; import static org.apache.flink.agents.examples.agents.CustomTypesAndResources.REVIEW_ANALYSIS_PROMPT; /** @@ -61,7 +61,7 @@ public class ReviewAnalysisAgent extends Agent { @ChatModelSetup public static ResourceDescriptor reviewAnalysisModel() { - return ResourceDescriptor.Builder.newBuilder(OllamaChatModelSetup.class.getName()) + return ResourceDescriptor.Builder.newBuilder(OLLAMA_CHAT_MODEL) .addInitialArgument("connection", "ollamaChatModelConnection") .addInitialArgument("model", "qwen3:8b") .addInitialArgument("prompt", "reviewAnalysisPrompt")
