xintongsong commented on code in PR #356:
URL: https://github.com/apache/flink-agents/pull/356#discussion_r2644666836


##########
api/src/main/java/org/apache/flink/agents/api/prompt/LocalPrompt.java:
##########
@@ -0,0 +1,207 @@
+/*
+ * 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.prompt;
+
+import org.apache.flink.agents.api.chat.messages.ChatMessage;
+import org.apache.flink.agents.api.chat.messages.MessageRole;
+import 
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator;
+import 
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
+import 
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonTypeInfo;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+/**
+ * Local prompt implementation for language models.
+ *
+ * <p>This prompt implementation uses a local template that can be either a 
string or a sequence of
+ * ChatMessage objects. The template supports placeholder substitution using 
{variable} syntax.
+ *
+ * <p>Example usage:
+ *
+ * <pre>{@code
+ * // String template
+ * LocalPrompt prompt = new LocalPrompt("Hello {name}!");
+ * String result = prompt.formatString(Map.of("name", "World"));
+ * // result: "Hello World!"
+ *
+ * // Message template
+ * List<ChatMessage> messages = List.of(
+ *     new ChatMessage(MessageRole.SYSTEM, "You are {role}"),
+ *     new ChatMessage(MessageRole.USER, "Help me with {task}")
+ * );
+ * LocalPrompt prompt2 = new LocalPrompt(messages);
+ * List<ChatMessage> result2 = prompt2.formatMessages(
+ *     MessageRole.SYSTEM,
+ *     Map.of("role", "an assistant", "task", "coding")
+ * );
+ * }</pre>
+ */
+public class LocalPrompt extends Prompt {

Review Comment:
   > If we move LocalPrompt to Plan module that will create circular dependency 
as we would still need LocalPrompt on the classpath at runtime for the 
reflection call
   
   That should be fine. We are using the same approach for 
`AgentsExecutionEnvironment` and it works fine. User programs only need to 
depend on the `api` module, with `provided` scope. They don't need to 
explicitly depend on the `plan` / `runtime` modules. Users must first install 
flink-agents to their flink clusters in order to execute the programs, which is 
specified in our installation documentations. So we can just assume the `plan` 
/ `runtime` modules exist in the classpath in runtime.



-- 
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]

Reply via email to