mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 19:38:13 +00:00
(improvement)(chat) Make it compatible with the case when the agent is empty. (#596)
This commit is contained in:
@@ -22,7 +22,9 @@ public class Agent extends RecordInfo {
|
||||
private String name;
|
||||
private String description;
|
||||
|
||||
//0 offline, 1 online
|
||||
/**
|
||||
* 0 offline, 1 online
|
||||
*/
|
||||
private Integer status;
|
||||
private List<String> examples;
|
||||
private String agentConfig;
|
||||
@@ -49,7 +51,7 @@ public class Agent extends RecordInfo {
|
||||
return enableSearch != null && enableSearch == 1;
|
||||
}
|
||||
|
||||
public boolean containsAllModel(Set<Long> detectModelIds) {
|
||||
public static boolean containsAllModel(Set<Long> detectModelIds) {
|
||||
return !CollectionUtils.isEmpty(detectModelIds) && detectModelIds.contains(-1L);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,9 +85,12 @@ public class MapperHelper {
|
||||
public Set<Long> getModelIds(QueryReq request, Agent agent) {
|
||||
|
||||
Long modelId = request.getModelId();
|
||||
Set<Long> detectModelIds = agent.getModelIds(null);
|
||||
Set<Long> detectModelIds = new HashSet<>();
|
||||
if (Objects.nonNull(agent)) {
|
||||
detectModelIds = agent.getModelIds(null);
|
||||
}
|
||||
//contains all
|
||||
if (agent.containsAllModel(detectModelIds)) {
|
||||
if (Agent.containsAllModel(detectModelIds)) {
|
||||
if (Objects.nonNull(modelId) && modelId > 0) {
|
||||
Set<Long> result = new HashSet<>();
|
||||
result.add(modelId);
|
||||
|
||||
@@ -61,8 +61,12 @@ public class LLMRequestService {
|
||||
}
|
||||
|
||||
public ModelCluster getModelCluster(QueryContext queryCtx, ChatContext chatCtx) {
|
||||
Set<Long> distinctModelIds = queryCtx.getAgent().getModelIds(AgentToolType.NL2SQL_LLM);
|
||||
if (queryCtx.getAgent().containsAllModel(distinctModelIds)) {
|
||||
Agent agent = queryCtx.getAgent();
|
||||
Set<Long> distinctModelIds = new HashSet<>();
|
||||
if (Objects.nonNull(agent)) {
|
||||
distinctModelIds = agent.getModelIds(AgentToolType.NL2SQL_LLM);
|
||||
}
|
||||
if (Agent.containsAllModel(distinctModelIds)) {
|
||||
distinctModelIds = new HashSet<>();
|
||||
}
|
||||
ModelResolver modelResolver = ComponentFactory.getModelResolver();
|
||||
@@ -77,7 +81,7 @@ public class LLMRequestService {
|
||||
Optional<NL2SQLTool> llmParserTool = commonAgentTools.stream()
|
||||
.filter(tool -> {
|
||||
List<Long> modelIds = tool.getModelIds();
|
||||
if (agent.containsAllModel(new HashSet<>(modelIds))) {
|
||||
if (Agent.containsAllModel(new HashSet<>(modelIds))) {
|
||||
return true;
|
||||
}
|
||||
for (Long modelId : modelIdSet) {
|
||||
|
||||
Reference in New Issue
Block a user