eemario commented on code in PR #1397:
URL: https://github.com/apache/flink-agents/pull/1397#discussion_r4680048986
##########
plan/src/main/java/org/apache/flink/agents/plan/resource/python/PythonChatModelSetup.java:
##########
@@ -107,6 +107,32 @@ public ChatResult chat(
}
}
+ @Override
+ public List<ChatMessage> prepareRequestMessages(
+ List<ChatMessage> messages, Map<String, Object> promptArgs) {
+ try (PythonObjectScope scope = new PythonObjectScope()) {
+ List<Object> pythonMessages = new ArrayList<>();
+ for (ChatMessage message : messages) {
+
pythonMessages.add(scope.own(adapter.toPythonChatMessage(message)));
+ }
+ Object prepared =
+ scope.own(
+ adapter.callMethod(
+ chatModelSetup,
+ "prepare_request_messages",
+ Map.of(
+ "messages",
+ pythonMessages,
+ "prompt_args",
+ promptArgs == null ? Map.of() :
promptArgs)));
+ List<ChatMessage> result = new ArrayList<>();
+ for (Object message : (List<?>) prepared) {
+ result.add(adapter.fromPythonChatMessage(message));
Review Comment:
Addressed in b0300c8b6. Both routing strategies now trim the original
conversation before adding prompt and skill messages. Updated the docs and
added a regression test with copied messages.
##########
api/src/main/java/org/apache/flink/agents/api/chat/model/BaseChatModelSetup.java:
##########
@@ -329,19 +329,28 @@ public ChatResult chat(
List<Tool> tools,
@Nullable Map<String, Object> modelParams,
@Nullable Object outputSchema) {
+ return callConnection(messages, tools, modelParams, outputSchema,
tools.isEmpty());
+ }
+
+ private ChatResult callConnection(
Review Comment:
Addressed in b0300c8b6. Java and Python now strip tool-only parameters
whenever the resolved tool list is empty. Added coverage for plain chat in both
languages.
##########
api/src/main/java/org/apache/flink/agents/api/event/ChatRequestEvent.java:
##########
@@ -114,17 +129,23 @@ private static Map<String, Object>
normalizeAttributes(Map<String, Object> attri
}
attributes.put("messages", messages);
}
+ Object budget = attributes.get("budget");
+ if (budget instanceof Map) {
+ attributes.put("budget", MAPPER.convertValue(budget,
ReActLoopBudget.class));
+ } else if (budget != null && !(budget instanceof ReActLoopBudget)) {
Review Comment:
Addressed in b0300c8b6. Removed the type check and kept the map-to-budget
conversion. The restoration tests still cover invalid budget fields.
##########
plan/src/main/java/org/apache/flink/agents/plan/serializer/ActionJsonDeserializer.java:
##########
@@ -146,7 +147,7 @@ private JavaFunction deserializeJavaFunction(JsonNode
execNode) throws IOExcepti
private Map<String, Object> deserializeJavaConfig(JsonNode node) throws
Exception {
- ObjectMapper mapper = new ObjectMapper();
+ ObjectMapper mapper = new ObjectMapper().registerModule(new
JavaTimeModule());
Review Comment:
Addressed in b0300c8b6. Centralized JavaTimeModule registration in
JacksonMapperFactory. Each component caches its own mapper and retains its
serializers and mixins.
--
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]