Cros
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user