123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- package cn.cslg.pas.controller.outApi;
- import cn.cslg.pas.common.core.base.Constants;
- import cn.cslg.pas.common.model.dify.*;
- import cn.cslg.pas.common.model.dify.confessionSession.ConfessionSessionDetailDTO;
- import cn.cslg.pas.common.model.dify.confessionSession.ConfessionSessionDetailVO;
- import cn.cslg.pas.common.model.dify.generatePatentResult.ExportPatentDTO;
- import cn.cslg.pas.common.model.dify.generatePatentResult.GeneratePatentResultDTO;
- import cn.cslg.pas.common.utils.CacheUtils;
- import cn.cslg.pas.common.utils.LoginUtils;
- import cn.cslg.pas.common.utils.Response;
- import cn.cslg.pas.factorys.difyFactory.GeneratePatentResultService;
- import cn.cslg.pas.service.common.DifyService;
- import cn.cslg.pas.service.dify.*;
- import com.alibaba.fastjson2.JSONObject;
- import io.swagger.v3.oas.annotations.Operation;
- import io.swagger.v3.oas.annotations.tags.Tag;
- import lombok.RequiredArgsConstructor;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.context.annotation.Lazy;
- import org.springframework.http.MediaType;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import reactor.core.publisher.Flux;
- import java.io.IOException;
- @SuppressWarnings({"all"})
- @Tag(name = "外部人员调用接口")
- @RestController
- @RequestMapping(Constants.API_XiaoSHI + "/dify")
- @RequiredArgsConstructor(onConstructor_ = {@Lazy})
- public class DifyController {
- private final DifyService difyService;
- private final DifySessionService difySessionService;
- private final GenerateInstructionService generateInstructionService;
- private final GenerateDiscoveryResultService generateDiscoveryResultService;
- private final ConfessionSessionService confessionSessionService;
- @Autowired
- private CacheUtils cacheUtils;
- @Autowired
- private LoginUtils loginUtils;
- private final PatentResultService patentResultService;
- @RequestMapping(value = "/chatMessage", method = RequestMethod.POST, produces = MediaType.TEXT_EVENT_STREAM_VALUE)
- @Operation(summary = "发送对话")
- public Flux<String> chatMessage(@RequestBody ChatMessageDTO chatMessageDTO) throws IOException {
- return difyService.getOkhttp(chatMessageDTO);
- }
- @RequestMapping(value = "/queryHistoryMessage", method = RequestMethod.POST)
- @Operation(summary = "查询历史会话")
- public Response queryHistoryMessage(@RequestBody DifyHistoryMessageDTO difyHistoryMessageDTO) throws IOException {
- String jsons = difyService.queryHistoryMessage(difyHistoryMessageDTO);
- JSONObject jsonObject = JSONObject.parseObject(jsons);
- return Response.success(jsonObject);
- }
- @RequestMapping(value = "/querySessionId", method = RequestMethod.GET)
- @Operation(summary = "查询会话id")
- public Response querySessionId(Integer projectId) throws IOException {
- String userId = loginUtils.getId().toString();
- return Response.success(difySessionService.getSessionId(projectId, userId));
- }
- @RequestMapping(value = "/stopMessage", method = RequestMethod.GET)
- @Operation(summary = "停止会话")
- public Response stopMessage(String taskId,Integer type) throws IOException {
- return Response.success(difyService.stopMessage(taskId,type));
- }
- @RequestMapping(value = "/generateInventionPoint", method = RequestMethod.POST)
- @Operation(summary = "生成发明点")
- public Response generateInventionPoint(@RequestBody ChatMessageDTO chatMessageDTO) throws IOException {
- return Response.success(difyService.generateInventionPoint(chatMessageDTO));
- }
- @RequestMapping(value = "/generateClaimExplain", method = RequestMethod.POST)
- @Operation(summary = "生成权利要求解释和有益效果")
- public Response generateClaimExplain(@RequestBody GenerateClaimDTO generateClaimDTO) throws Exception {
- return Response.success(difyService.generateClaimExplain(generateClaimDTO));
- }
- @RequestMapping(value = "/sendOADefense", method = RequestMethod.POST, produces = MediaType.TEXT_EVENT_STREAM_VALUE)
- @Operation(summary = "OA答辩")
- public Flux<String> sendOADefense(@RequestBody OAParamDTO paramDTO) throws IOException {
- return difyService.successGetOAHttp1(paramDTO);
- }
- @RequestMapping(value = "/generateInstruction", method = RequestMethod.POST, produces = MediaType.TEXT_EVENT_STREAM_VALUE)
- @Operation(summary = "生成说明书")
- public Flux<String> addConfessionSession(@RequestBody GenerateClaimDTO generateClaimDTO) throws Exception {
- return generateInstructionService.generateInstruction2(generateClaimDTO);
- }
- @RequestMapping(value = "/generateDiscoveryResult", method = RequestMethod.POST)
- @Operation(summary = "生成技术交底书理解结果")
- public Response generateDiscoveryResult(@RequestBody ChatMessageDTO chatMessageDTO) throws Exception {
- return Response.success(generateDiscoveryResultService.generateResult(chatMessageDTO));
- }
- @RequestMapping(value = "/generateDiscoveryResult/detail", method = RequestMethod.POST)
- @Operation(summary = "获取技术交底书理解结果详情")
- public Response detail(@RequestBody ConfessionSessionDetailDTO confessionSessionDetailDTO) throws IOException {
- ConfessionSessionDetailVO confessionSessionDetailVO = confessionSessionService.getConfessionSessionDetail(confessionSessionDetailDTO);
- return Response.success(confessionSessionDetailVO);
- }
- @RequestMapping(value = "/generateDiscoveryResult/dialogue", method = RequestMethod.POST, produces = MediaType.TEXT_EVENT_STREAM_VALUE)
- @Operation(summary = "ai对话")
- public Flux<String> discoveryResultDialogue(@RequestBody ChatMessageDTO chatMessageDTO) throws Exception {
- return difyService.discoveryResultDialogue(chatMessageDTO);
- }
- @RequestMapping(value = "/generatePatentResult", method = RequestMethod.POST)
- @Operation(summary = "生成专利申请文档结果")
- public Flux<String> generatePatentResult(@RequestBody ExportPatentDTO exportPatentDTO) throws Exception {
- return patentResultService.aiGeneratePatentResult(generatePatentResultDTO);
- }
- }
|