implement game catalog vector MCP resolver
This commit is contained in:
@@ -23,6 +23,7 @@ public class McpSseService {
|
||||
private final McpProperties mcpProperties;
|
||||
private final QaVectorService qaVectorService;
|
||||
private final GameScopeService gameScopeService;
|
||||
private final GameCatalogVectorService gameCatalogVectorService;
|
||||
|
||||
public McpSseService(
|
||||
SelectAiService selectAiService,
|
||||
@@ -30,7 +31,8 @@ public class McpSseService {
|
||||
BackofficeProperties properties,
|
||||
McpProperties mcpProperties,
|
||||
QaVectorService qaVectorService,
|
||||
GameScopeService gameScopeService
|
||||
GameScopeService gameScopeService,
|
||||
GameCatalogVectorService gameCatalogVectorService
|
||||
) {
|
||||
this.selectAiService = selectAiService;
|
||||
this.objectMapper = objectMapper;
|
||||
@@ -38,6 +40,7 @@ public class McpSseService {
|
||||
this.mcpProperties = mcpProperties;
|
||||
this.qaVectorService = qaVectorService;
|
||||
this.gameScopeService = gameScopeService;
|
||||
this.gameCatalogVectorService = gameCatalogVectorService;
|
||||
}
|
||||
|
||||
public ObjectNode handle(String contextPath, JsonNode request) {
|
||||
@@ -191,8 +194,8 @@ public class McpSseService {
|
||||
response = gameScopeResponse(gameScopeService.resolve(
|
||||
token, arguments.path("question").asText("")));
|
||||
} else if (gameCatalogTool) {
|
||||
response = gameScopeResponse(gameScopeService.resolve(
|
||||
token, arguments.path("question").asText("")));
|
||||
response = gameCatalogVectorResponse(gameCatalogVectorService.search(
|
||||
token, arguments.path("question").asText(""), arguments.path("topK").asInt(5)));
|
||||
} else {
|
||||
String prompt = arguments.path("prompt").asText("");
|
||||
response = queryTool
|
||||
@@ -244,6 +247,19 @@ public class McpSseService {
|
||||
return response;
|
||||
}
|
||||
|
||||
private ObjectNode gameCatalogVectorResponse(List<GameCatalogVectorService.GameCandidate> candidates) {
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
response.put("status", candidates.isEmpty() ? "NO_MATCH" : "CANDIDATES");
|
||||
ArrayNode items = response.putArray("matchedGames");
|
||||
for (GameCatalogVectorService.GameCandidate c : candidates) {
|
||||
ObjectNode item = items.addObject();
|
||||
item.put("gameKey", c.gameKey()); item.put("gameId", c.gameId());
|
||||
item.put("gamePrefix", c.gamePrefix()); item.put("gameName", c.gameName());
|
||||
item.put("aliases", c.aliases()); item.put("cosineDistance", c.similarity());
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
private ObjectNode qaVectorStoreResponse(QaVectorService.VectorStoreResult stored) {
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
response.put("status", "QA_VECTOR_STORED");
|
||||
|
||||
Reference in New Issue
Block a user