mirror of
https://github.com/ccmjga/zhilu-admin
synced 2026-03-23 19:33: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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
deep-seek:
|
||||
base-url: "https://api.deepseek.com"
|
||||
api-key: "sk-3633b0cd40884b27aa8402a1c5dc029d"
|
||||
model-name: "deepseek-chat"
|
||||
prompt:
|
||||
system: "你是一个名叫「知路智能体」的企业级AI助手,能帮助用户解决各种问题。"
|
||||
model-name: "deepseek-chat"
|
||||
1
backend/src/main/resources/prompt.txt
Normal file
1
backend/src/main/resources/prompt.txt
Normal file
@@ -0,0 +1 @@
|
||||
你是一个名为「知路智能体」的企业级AI助手,严格遵循使用Markdown格式来回复内容。
|
||||
Reference in New Issue
Block a user