feat: add MapUtil.java

This commit is contained in:
Michael Yang 2024-03-08 19:58:37 +08:00
parent 47c25e8bbf
commit f7ab096796
2 changed files with 35 additions and 1 deletions

View File

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

View File

@ -0,0 +1,35 @@
package com.agentsflex.util;
import java.util.HashMap;
import java.util.Map;
public class MapUtil {
public static Map<String, Object> ofSingleKey(String key, Object value) {
Map<String, Object> 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<String, Object> map = new HashMap<>();
public MapBuilder put(String key, Object value) {
map.put(key, value);
return this;
}
public Map<String, Object> build() {
return map;
}
}
}