feat:测试代码

law-v2025-01
wangxy 2 months ago
parent 21afeb22b8
commit fb93d0de12

@ -2,6 +2,7 @@ package com.ruoyi.web.controller.home;
import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;
import com.ruoyi.common.core.controller.BaseController;
@ -99,8 +100,8 @@ public class LawController extends BaseController {
@Autowired
private DeepSeekLocalService deepSeekLocalService;
@GetMapping("/call-local-deepseek")
public R callLocalDeepSeek(@RequestParam(required = false) String content) {
@PostMapping("/call-local-deepseek")
public R callLocalDeepSeek(@RequestParam(required = false) String content) throws JsonProcessingException {
return R.ok(deepSeekLocalService.callLocalDeepSeek(content));
}

@ -18,7 +18,7 @@ import java.util.Arrays;
@Service
public class DeepSeekLocalService {
private static final String LOCAL_API_URL = "http://localhost:8081/chat/completions";
private static final String LOCAL_API_URL = "http://192.168.110.56:11434/v1/chat/completions";
private final RestTemplate restTemplate;
@ -41,7 +41,7 @@ public class DeepSeekLocalService {
userMessage.setContent(content);
DeepSeekRequest requestBody = new DeepSeekRequest();
requestBody.setModel("deepseek-chat");
requestBody.setModel("deepseek-r1:1.5b");
requestBody.setMessages(Arrays.asList(systemMessage, userMessage));
requestBody.setStream(false);
// 创建 HttpEntity
@ -55,6 +55,8 @@ public class DeepSeekLocalService {
);
// 处理响应
if (response.getStatusCode() == HttpStatus.OK) {
System.out.println("成功了!");
System.out.println("返回数据: " + response.getBody());
return response.getBody();
} else {
throw new RuntimeException("Request failed with status code: " + response.getStatusCode());

Loading…
Cancel
Save