结构化输出

This commit is contained in:
huangge1199 2025-07-12 11:20:53 +08:00
parent 9d95e3bff1
commit ade5b50e33
2 changed files with 19 additions and 0 deletions

View File

@ -32,4 +32,16 @@ public class LangChainController {
String result = langChainService.chat(message);
return R.ok(result);
}
/**
* 结构化输出
*
* @param message 输入信息
* @return ai返回结果
*/
@PostMapping("/chatForReport")
public R<LangChainService.Report> chatForReport(@RequestBody String message) {
LangChainService.Report result = langChainService.chatForReport(message);
return R.ok(result);
}
}

View File

@ -2,6 +2,8 @@ package com.huangge1199.ai.service;
import dev.langchain4j.service.SystemMessage;
import java.util.List;
/**
* LangChainService
*
@ -12,4 +14,9 @@ public interface LangChainService {
@SystemMessage(fromResource = "system-prompt.txt")
String chat(String message);
@SystemMessage(fromResource = "system-prompt.txt")
Report chatForReport(String message);
record Report(String name, List<String> list){}
}