mirror of
https://github.com/ccmjga/zhilu-admin
synced 2026-03-14 13:43:42 +08:00
add md render
This commit is contained in:
@@ -1,14 +1,25 @@
|
||||
package com.zl.mjga.config.ai;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "deep-seek")
|
||||
public class DeepSeekConfiguration {
|
||||
|
||||
@jakarta.annotation.Resource
|
||||
private ResourceLoader resourceLoader;
|
||||
|
||||
private String baseUrl;
|
||||
private String apiKey;
|
||||
private Prompt prompt;
|
||||
@@ -18,4 +29,12 @@ public class DeepSeekConfiguration {
|
||||
public static class Prompt {
|
||||
private String system;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() throws IOException {
|
||||
Resource resource = resourceLoader.getResource("classpath:prompt.txt");
|
||||
prompt = new Prompt();
|
||||
prompt.setSystem(Files.readString(Paths.get(resource.getURI())));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import java.time.Duration;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Sinks;
|
||||
@@ -34,8 +33,6 @@ public class AiController {
|
||||
.onError(sink::tryEmitError)
|
||||
.start();
|
||||
return sink.asFlux()
|
||||
.timeout(Duration.ofSeconds(120))
|
||||
.doOnCancel(SecurityContextHolder::clearContext)
|
||||
.doOnTerminate(SecurityContextHolder::clearContext);
|
||||
.timeout(Duration.ofSeconds(120));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user