This commit is contained in:
Mohammad Zwaib
2026-07-16 00:02:45 +02:00
parent 794d87e408
commit 7cef62cc48
3 changed files with 52 additions and 7 deletions
@@ -4,11 +4,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.homme.demo.dto.AskResponse;
import com.homme.demo.dto.ChatRequest;
import com.homme.demo.service.RagService;
@@ -20,20 +22,23 @@ public class ChatController {
@Autowired
private RagService ragService;
@PostMapping("/ask")
public AskResponse ask(@RequestParam String question) {
@PostMapping("/ask")
public AskResponse ask(@RequestBody ChatRequest request) {
String question = request.getMessage();
if (question == null || question.isBlank()) {
String warn = "Bitte stellen Sie eine Frage.";
return AskResponse.builder()
.answer("Bitte stellen Sie eine Frage.")
.answer(warn).reply(warn).message(warn)
.build();
}
String answer = ragService.answerQuestion(question);
return AskResponse.builder()
.answer(ragService.answerQuestion(question))
.answer(answer).reply(answer).message(answer)
.build();
}