调用本地大模型
This commit is contained in:
@@ -2,7 +2,10 @@ package com.rj.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.rj.dto.AiQaCustomerAskRequestDto;
|
||||
import com.rj.dto.AiQaCustomerAskResponseDto;
|
||||
import com.rj.entity.AiQaItem;
|
||||
import com.rj.service.IAiQaCustomerAskService;
|
||||
import com.rj.service.IAiQaItemService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
@@ -33,6 +36,32 @@ public class AiQaItemController {
|
||||
@Autowired
|
||||
private IAiQaItemService aiQaItemService;
|
||||
|
||||
@Autowired
|
||||
private IAiQaCustomerAskService aiQaCustomerAskService;
|
||||
|
||||
@PostMapping("/ask")
|
||||
@Operation(summary = "客户问答(大模型)", description = "接收客户问题,调用本地 OpenAI 兼容 Chat Completions,将回答返回给前端")
|
||||
public ResponseEntity<Map<String, Object>> askCustomer(
|
||||
@Parameter(description = "提问请求", required = true) @RequestBody AiQaCustomerAskRequestDto request) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
AiQaCustomerAskResponseDto data = aiQaCustomerAskService.askCustomer(request);
|
||||
result.put("success", true);
|
||||
result.put("message", "回答生成成功");
|
||||
result.put("data", data);
|
||||
return ResponseEntity.ok(result);
|
||||
} catch (IllegalArgumentException e) {
|
||||
result.put("success", false);
|
||||
result.put("message", e.getMessage());
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
} catch (Exception e) {
|
||||
log.error("ai_qa_item ask error", e);
|
||||
result.put("success", false);
|
||||
result.put("message", "调用大模型异常:" + e.getMessage());
|
||||
return ResponseEntity.internalServerError().body(result);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@Operation(summary = "新增", description = "新增 AI 问答子表记录")
|
||||
public ResponseEntity<Map<String, Object>> add(
|
||||
|
||||
Reference in New Issue
Block a user