mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-03-13 20:53:42 +08:00
fix(billing): 当 knowledge.graph.enabled=false 时:所有知识图谱相关的 Bean 都不会被创建Neo4j 配置不会被加载即使没有配置 Neo4j 连接信息,默认禁用了知识图谱功能
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.ruoyi.graph.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
@@ -18,6 +19,7 @@ import java.util.concurrent.ThreadPoolExecutor;
|
||||
@Slf4j
|
||||
@EnableAsync
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "knowledge.graph", name = "enabled", havingValue = "true")
|
||||
public class GraphAsyncConfig {
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,7 @@ import lombok.Data;
|
||||
import org.neo4j.driver.AuthTokens;
|
||||
import org.neo4j.driver.Driver;
|
||||
import org.neo4j.driver.GraphDatabase;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -16,6 +17,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "knowledge.graph", name = "enabled", havingValue = "true")
|
||||
@ConfigurationProperties(prefix = "neo4j")
|
||||
public class Neo4jConfig {
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.ruoyi.graph.domain.GraphInstance;
|
||||
import org.ruoyi.graph.enums.GraphStatusEnum;
|
||||
import org.ruoyi.graph.service.IGraphBuildTaskService;
|
||||
import org.ruoyi.graph.service.IGraphInstanceService;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -29,6 +30,7 @@ import java.util.Map;
|
||||
@RestController
|
||||
@RequestMapping("/graph/instance")
|
||||
@Tag(name = "图谱实例管理", description = "知识图谱实例的创建、查询、更新、删除")
|
||||
@ConditionalOnProperty(prefix = "knowledge.graph", name = "enabled", havingValue = "true")
|
||||
public class GraphInstanceController extends BaseController {
|
||||
|
||||
private final IGraphInstanceService graphInstanceService;
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.ruoyi.graph.dto.GraphExtractionResult;
|
||||
import org.ruoyi.graph.service.IGraphExtractionService;
|
||||
import org.ruoyi.graph.service.IGraphRAGService;
|
||||
import org.ruoyi.graph.service.IGraphStoreService;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -29,6 +30,7 @@ import java.util.Map;
|
||||
@RestController
|
||||
@RequestMapping("/graph/query")
|
||||
@Tag(name = "图谱查询", description = "知识图谱查询相关接口")
|
||||
@ConditionalOnProperty(prefix = "knowledge.graph", name = "enabled", havingValue = "true")
|
||||
public class GraphQueryController extends BaseController {
|
||||
|
||||
private final IGraphStoreService graphStoreService;
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.ruoyi.graph.service.IGraphBuildTaskService;
|
||||
import org.ruoyi.graph.service.IGraphInstanceService;
|
||||
import org.ruoyi.graph.service.IGraphRAGService;
|
||||
import org.ruoyi.service.IKnowledgeAttachService;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -36,6 +37,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "knowledge.graph", name = "enabled", havingValue = "true")
|
||||
public class GraphBuildTaskServiceImpl implements IGraphBuildTaskService {
|
||||
|
||||
private final GraphBuildTaskMapper taskMapper;
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.ruoyi.graph.prompt.GraphExtractPrompt;
|
||||
import org.ruoyi.graph.service.IGraphExtractionService;
|
||||
import org.ruoyi.graph.service.llm.IGraphLLMService;
|
||||
import org.ruoyi.service.IChatModelService;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -31,6 +32,7 @@ import java.util.regex.Pattern;
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "knowledge.graph", name = "enabled", havingValue = "true")
|
||||
public class GraphExtractionServiceImpl implements IGraphExtractionService {
|
||||
|
||||
private final IChatModelService chatModelService;
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.ruoyi.graph.domain.GraphInstance;
|
||||
import org.ruoyi.graph.mapper.GraphInstanceMapper;
|
||||
import org.ruoyi.graph.service.IGraphInstanceService;
|
||||
import org.ruoyi.graph.service.IGraphStoreService;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -30,6 +31,7 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "knowledge.graph", name = "enabled", havingValue = "true")
|
||||
public class GraphInstanceServiceImpl implements IGraphInstanceService {
|
||||
|
||||
private final GraphInstanceMapper graphInstanceMapper;
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.ruoyi.graph.dto.GraphExtractionResult;
|
||||
import org.ruoyi.graph.service.IGraphExtractionService;
|
||||
import org.ruoyi.graph.service.IGraphRAGService;
|
||||
import org.ruoyi.graph.service.IGraphStoreService;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
@@ -26,6 +27,7 @@ import java.util.*;
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "knowledge.graph", name = "enabled", havingValue = "true")
|
||||
public class GraphRAGServiceImpl implements IGraphRAGService {
|
||||
|
||||
private final IGraphExtractionService graphExtractionService;
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.ruoyi.graph.config.GraphProperties;
|
||||
import org.ruoyi.graph.domain.GraphEdge;
|
||||
import org.ruoyi.graph.domain.GraphVertex;
|
||||
import org.ruoyi.graph.service.IGraphStoreService;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
@@ -30,6 +31,7 @@ import static org.neo4j.driver.Values.parameters;
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnProperty(prefix = "knowledge.graph", name = "enabled", havingValue = "true")
|
||||
public class GraphStoreServiceImpl implements IGraphStoreService {
|
||||
|
||||
private final Driver neo4jDriver;
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.neo4j.driver.Record;
|
||||
import org.neo4j.driver.Result;
|
||||
import org.neo4j.driver.Session;
|
||||
import org.neo4j.driver.types.Node;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -21,6 +22,7 @@ import static org.neo4j.driver.Values.parameters;
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@ConditionalOnProperty(prefix = "knowledge.graph", name = "enabled", havingValue = "true")
|
||||
public class Neo4jTestUtil {
|
||||
|
||||
private final Driver driver;
|
||||
|
||||
Reference in New Issue
Block a user