From fb93d0de1212ee834252173eef4475a6cafdc47d Mon Sep 17 00:00:00 2001 From: wangxy <1481820854@qq.com> Date: Wed, 19 Feb 2025 10:05:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/web/controller/home/LawController.java | 5 +++-- .../ruoyi/framework/web/service/DeepSeekLocalService.java | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/home/LawController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/home/LawController.java index 67477ec..339eb0b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/home/LawController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/home/LawController.java @@ -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)); } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/DeepSeekLocalService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/DeepSeekLocalService.java index 7697667..e8e5d2a 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/DeepSeekLocalService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/DeepSeekLocalService.java @@ -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());