引入依赖

<dependency>
    <groupId>io.github.pig-mesh.ai</groupId>
    <artifactId>deepseek-spring-boot-starter</artifactId>
    <version>1.4.5</version>
</dependency>

配置

deepseek:
  api-key: sk-******
  base-url: https://api.deepseek.com/v1 # 默认

API调用

@Autowired
private DeepSeekClient deepSeekClient;

@GetMapping(value = "/chat", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<ChatCompletionResponse> chat(String userMessage, HttpServletResponse response) {
    response.setCharacterEncoding("UTF-8");
    return deepSeekClient.chatFluxCompletion(userMessage);
}

测试

第一轮对话

SpringBoot调用DeepSeek-LMLPHP

第二轮对话

SpringBoot调用DeepSeek-LMLPHP

03-05 06:13