add md render

This commit is contained in:
Chuck1sn
2025-05-22 13:31:56 +08:00
parent a5781c28d3
commit bffb8a9ba4
7 changed files with 102 additions and 11 deletions

View File

@@ -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())));
}
}

View File

@@ -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));
}
}