pass previous tool context into few-shot query

This commit is contained in:
devmrko
2026-07-27 14:47:37 +09:00
parent 3a7e2ced00
commit ec5d731bf5
2 changed files with 14 additions and 2 deletions

View File

@@ -144,6 +144,10 @@ public class McpSseService {
if (fewShotNl2SqlToolName().equals(toolView.name())) {
addStringProperty(properties, "scopeGameKey",
"선택 사항입니다. game_scope_resolve가 반환한 SUPPORTED gameKey만 전달하세요.", 128);
ObjectNode plan = properties.putObject("queryPlan");
plan.put("type", "object");
plan.put("description", "앞 단계 game_query_plan의 구조화된 결과입니다.");
plan.putObject("additionalProperties").put("type", "object");
}
required.add("prompt");
}
@@ -208,7 +212,8 @@ public class McpSseService {
? selectAiService.generateAndExecute(token, prompt)
: fewShotNl2SqlTool
? selectAiService.generateAndExecute(token, prompt,
arguments.path("scopeGameKey").asText(""))
arguments.path("scopeGameKey").asText(""),
arguments.path("queryPlan"))
: selectAiService.generatePrompt(token, prompt);
}
} catch (VpdTokenAccessDeniedException ignored) {

View File

@@ -115,6 +115,13 @@ public class SelectAiService {
return response;
}
public JsonNode generateAndExecute(
String bearerToken, String prompt, String scopeGameKey, JsonNode priorToolContext) {
String context = priorToolContext == null || priorToolContext.isMissingNode()
|| priorToolContext.isNull() ? "" : "\n[PREVIOUS TOOL RESULT]\n" + priorToolContext;
return generateAndExecute(bearerToken, prompt + context, scopeGameKey);
}
private GameContext resolveGameContext(String bearerToken, String question) {
try {
List<GameCatalogVectorService.GameCandidate> candidates =