You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
973 B
28 lines
973 B
1 year ago
|
package cn.teammodel.controller.frontend;
|
||
|
|
||
|
import cn.teammodel.model.dto.ai.ChatCompletionReqDto;
|
||
|
import cn.teammodel.service.ChatMessageService;
|
||
|
import io.swagger.annotations.ApiOperation;
|
||
|
import org.springframework.web.bind.annotation.*;
|
||
|
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||
|
|
||
|
import javax.annotation.Resource;
|
||
|
import javax.validation.Valid;
|
||
|
|
||
|
@RestController
|
||
|
@RequestMapping("/public/ai")
|
||
|
public class AiController {
|
||
|
@Resource
|
||
|
private ChatMessageService chatMessageService;
|
||
|
|
||
|
@PostMapping("chat/completion")
|
||
|
@ApiOperation("与 spark 的流式对话")
|
||
|
public SseEmitter chatCompletion(@RequestBody @Valid ChatCompletionReqDto chatCompletionReqDto) {
|
||
|
return chatMessageService.chatCompletion(chatCompletionReqDto);
|
||
|
}
|
||
|
@GetMapping("test/completion")
|
||
|
@ApiOperation("与 spark 的流式对话")
|
||
|
public SseEmitter testChatCompletion() {
|
||
|
return chatMessageService.chatCompletion(null);
|
||
|
}
|
||
|
}
|