mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-14 05:43:51 +00:00
[feature][headless-chat]Introduce ChatApp to support more flexible chat model config.#1739
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package com.tencent.supersonic.common.pojo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ChatApp {
|
||||
private String key;
|
||||
private String name;
|
||||
private String description;
|
||||
private String prompt;
|
||||
private boolean enable;
|
||||
private Integer chatModelId;
|
||||
@JsonIgnore
|
||||
private ChatModelConfig chatModelConfig;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.tencent.supersonic.common.util;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.tencent.supersonic.common.pojo.ChatApp;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChatAppManager {
|
||||
private static final Map<String, ChatApp> chatApps = Maps.newConcurrentMap();
|
||||
|
||||
public static void register(ChatApp chatApp) {
|
||||
if (chatApps.containsKey(chatApp.getKey())) {
|
||||
throw new RuntimeException("Duplicate chat app key is disallowed.");
|
||||
}
|
||||
chatApps.put(chatApp.getKey(), chatApp);
|
||||
}
|
||||
|
||||
public static Map<String, ChatApp> getAllApps() {
|
||||
return chatApps;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user