From f7ab096796f44d3d360d328fb739b3eba5d00765 Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Fri, 8 Mar 2024 19:58:37 +0800 Subject: [PATCH] feat: add MapUtil.java --- .../llm/client/BaseLlmClientListener.java | 1 - .../java/com/agentsflex/util/MapUtil.java | 35 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 agents-flex-core/src/main/java/com/agentsflex/util/MapUtil.java diff --git a/agents-flex-core/src/main/java/com/agentsflex/llm/client/BaseLlmClientListener.java b/agents-flex-core/src/main/java/com/agentsflex/llm/client/BaseLlmClientListener.java index 5b811b9..5a65f0d 100644 --- a/agents-flex-core/src/main/java/com/agentsflex/llm/client/BaseLlmClientListener.java +++ b/agents-flex-core/src/main/java/com/agentsflex/llm/client/BaseLlmClientListener.java @@ -41,7 +41,6 @@ public class BaseLlmClientListener implements LlmClientListener { private final StringBuilder fullMessage = new StringBuilder(); private AiMessage lastAiMessage; private boolean isFunctionCalling = false; - private final ChatContext context; public BaseLlmClientListener(Llm llm, LlmClient client, MessageListener messageListener, Prompt prompt diff --git a/agents-flex-core/src/main/java/com/agentsflex/util/MapUtil.java b/agents-flex-core/src/main/java/com/agentsflex/util/MapUtil.java new file mode 100644 index 0000000..5ad2611 --- /dev/null +++ b/agents-flex-core/src/main/java/com/agentsflex/util/MapUtil.java @@ -0,0 +1,35 @@ +package com.agentsflex.util; + +import java.util.HashMap; +import java.util.Map; + +public class MapUtil { + + public static Map ofSingleKey(String key, Object value) { + Map map = new HashMap<>(); + map.put(key, value); + return map; + } + + public static MapBuilder of() { + return new MapBuilder(); + } + + public static MapBuilder of(String key, Object value) { + return new MapBuilder().put(key, value); + } + + public static class MapBuilder { + private Map map = new HashMap<>(); + + public MapBuilder put(String key, Object value) { + map.put(key, value); + return this; + } + + public Map build() { + return map; + } + } + +}