|
@@ -7,6 +7,7 @@ import org.springframework.http.MediaType;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestPart;
|
|
import org.springframework.web.bind.annotation.RequestPart;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -22,18 +23,32 @@ public class EnhancementController {
|
|
|
private final EnhancementService enhancementService;
|
|
private final EnhancementService enhancementService;
|
|
|
|
|
|
|
|
@PostMapping("single-step")
|
|
@PostMapping("single-step")
|
|
|
- public String singleStepAnalysis(@RequestBody String html) {
|
|
|
|
|
- return enhancementService.calculateScoreAndProduceCommentsWithSingleCall(ExtractionRequest.fromHtml(html));
|
|
|
|
|
|
|
+ public String singleStepAnalysis(@RequestBody String html,
|
|
|
|
|
+ @RequestParam(value = "provider", required = false) String provider,
|
|
|
|
|
+ @RequestParam(value = "model", required = false) String model) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ return enhancementService.calculateScoreAndProduceCommentsWithSingleCall(ExtractionRequest.fromHtml(html), provider, model);
|
|
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
|
|
+ throw new ResponseStatusException(BAD_REQUEST, e.getMessage(), e);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PostMapping(value = "single-step/file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
@PostMapping(value = "single-step/file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
|
- public String singleStepAnalysisFile(@RequestPart("file") MultipartFile file) {
|
|
|
|
|
|
|
+ public String singleStepAnalysisFile(@RequestPart("file") MultipartFile file,
|
|
|
|
|
+ @RequestParam(value = "provider", required = false) String provider,
|
|
|
|
|
+ @RequestParam(value = "model", required = false) String model) {
|
|
|
if (file.isEmpty()) {
|
|
if (file.isEmpty()) {
|
|
|
throw new ResponseStatusException(BAD_REQUEST, "Uploaded file is empty");
|
|
throw new ResponseStatusException(BAD_REQUEST, "Uploaded file is empty");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- return enhancementService.calculateScoreAndProduceCommentsWithSingleCall(ExtractionRequest.fromFile(file.getBytes(), file.getOriginalFilename(), file.getContentType()));
|
|
|
|
|
|
|
+ return enhancementService.calculateScoreAndProduceCommentsWithSingleCall(
|
|
|
|
|
+ ExtractionRequest.fromFile(file.getBytes(), file.getOriginalFilename(), file.getContentType()),
|
|
|
|
|
+ provider,
|
|
|
|
|
+ model
|
|
|
|
|
+ );
|
|
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
|
|
+ throw new ResponseStatusException(BAD_REQUEST, e.getMessage(), e);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
throw new ResponseStatusException(BAD_REQUEST, "Unable to read uploaded file", e);
|
|
throw new ResponseStatusException(BAD_REQUEST, "Unable to read uploaded file", e);
|
|
|
}
|
|
}
|