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