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