| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.zy.ai.entity.DeviceConfigsData; |
| | | import com.zy.ai.entity.DeviceRealTimeData; |
| | | import com.zy.ai.entity.ChatCompletionRequest; |
| | | import com.zy.ai.entity.WcsDiagnosisRequest; |
| | | import com.zy.ai.entity.WcsDiagnosisResponse; |
| | | import com.zy.ai.log.AiLogAppender; |
| | | import com.zy.ai.service.WcsDiagnosisService; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.zy.common.web.BaseController; |
| | | import com.zy.asrs.entity.BasCrnp; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.BasCrnpService; |
| | |
| | | @RestController |
| | | @RequestMapping("/ai/diagnose") |
| | | @RequiredArgsConstructor |
| | | public class WcsDiagnosisController { |
| | | public class WcsDiagnosisController extends BaseController { |
| | | |
| | | @Autowired |
| | | private WcsDiagnosisService wcsDiagnosisService; |
| | |
| | | } |
| | | |
| | | @GetMapping("/askStream") |
| | | public SseEmitter askStream(@RequestParam("prompt") String prompt) { |
| | | public SseEmitter askStream(@RequestParam("prompt") String prompt, |
| | | @RequestParam(value = "chatId", required = false) String chatId, |
| | | @RequestParam(value = "reset", required = false, defaultValue = "false") boolean reset) { |
| | | SseEmitter emitter = new SseEmitter(0L); |
| | | new Thread(() -> { |
| | | try { |
| | |
| | | request.setDeviceRealtimeData(deviceRealTimeDataList); |
| | | request.setDeviceConfigs(deviceConfigsDataList); |
| | | |
| | | wcsDiagnosisService.askStream(request, prompt, emitter); |
| | | wcsDiagnosisService.askStream(request, prompt, chatId, reset, emitter); |
| | | } catch (Exception e) { |
| | | emitter.completeWithError(e); |
| | | } |
| | |
| | | return emitter; |
| | | } |
| | | |
| | | @GetMapping("/chats") |
| | | public List<Map<String, Object>> listChats() { |
| | | return wcsDiagnosisService.listChats(); |
| | | } |
| | | |
| | | @DeleteMapping("/chats/{chatId}") |
| | | public Boolean deleteChat(@PathVariable("chatId") String chatId) { |
| | | return wcsDiagnosisService.deleteChat(chatId); |
| | | } |
| | | |
| | | @GetMapping("/chats/{chatId}/history") |
| | | public List<ChatCompletionRequest.Message> getChatHistory(@PathVariable("chatId") String chatId) { |
| | | return wcsDiagnosisService.getChatHistory(chatId); |
| | | } |
| | | |
| | | /** |
| | | * POST /api/ai/diagnose/wcs |
| | | */ |