mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	【新增】AI 知识库:支持读取 PDF、DOC/DOCX、PPT/PPTX 和 HTML等格式
This commit is contained in:
		| @@ -39,11 +39,17 @@ | ||||
|             <artifactId>spring-ai-stability-ai-spring-boot-starter</artifactId> | ||||
|             <version>${spring-ai.version}</version> | ||||
|         </dependency> | ||||
|  | ||||
|         <dependency> | ||||
|             <groupId>org.springframework.ai</groupId> | ||||
|             <artifactId>spring-ai-transformers-spring-boot-starter</artifactId> | ||||
|             <version>${spring-ai.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.springframework.ai</groupId> | ||||
|             <artifactId>spring-ai-tika-document-reader</artifactId> | ||||
|             <version>${spring-ai.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.springframework.ai</groupId> | ||||
|             <artifactId>spring-ai-redis-store</artifactId> | ||||
|   | ||||
| @@ -10,11 +10,18 @@ import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoChatModel; | ||||
| import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoChatOptions; | ||||
| import com.alibaba.cloud.ai.tongyi.TongYiAutoConfiguration; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.ai.autoconfigure.vectorstore.redis.RedisVectorStoreProperties; | ||||
| import org.springframework.ai.document.MetadataMode; | ||||
| import org.springframework.ai.transformer.splitter.TokenTextSplitter; | ||||
| import org.springframework.ai.transformers.TransformersEmbeddingModel; | ||||
| import org.springframework.ai.vectorstore.RedisVectorStore; | ||||
| import org.springframework.boot.autoconfigure.AutoConfiguration; | ||||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||||
| import org.springframework.boot.autoconfigure.data.redis.RedisProperties; | ||||
| import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||||
| import org.springframework.context.annotation.Bean; | ||||
| import org.springframework.context.annotation.Import; | ||||
| import redis.clients.jedis.JedisPooled; | ||||
|  | ||||
| /** | ||||
|  * 芋道 AI 自动配置 | ||||
| @@ -73,4 +80,33 @@ public class YudaoAiAutoConfiguration { | ||||
|         return new SunoApi(yudaoAiProperties.getSuno().getBaseUrl()); | ||||
|     } | ||||
|  | ||||
|     // ========== rag 相关 ========== | ||||
|     @Bean | ||||
|     public TransformersEmbeddingModel transformersEmbeddingClient() { | ||||
|         return new TransformersEmbeddingModel(MetadataMode.EMBED); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 我们启动有加载很多 Embedding 模型,不晓得取哪个好,先 new 个 TransformersEmbeddingModel 跑 | ||||
|      */ | ||||
|     @Bean | ||||
|     public RedisVectorStore vectorStore(TransformersEmbeddingModel transformersEmbeddingModel, RedisVectorStoreProperties properties, | ||||
|                                         RedisProperties redisProperties) { | ||||
|         var config = RedisVectorStore.RedisVectorStoreConfig.builder() | ||||
|                 .withIndexName(properties.getIndex()) | ||||
|                 .withPrefix(properties.getPrefix()) | ||||
|                 .build(); | ||||
|  | ||||
|         RedisVectorStore redisVectorStore = new RedisVectorStore(config, transformersEmbeddingModel, | ||||
|                 new JedisPooled(redisProperties.getHost(), redisProperties.getPort()), | ||||
|                 properties.isInitializeSchema()); | ||||
|         redisVectorStore.afterPropertiesSet(); | ||||
|         return redisVectorStore; | ||||
|     } | ||||
|  | ||||
|     @Bean | ||||
|     public TokenTextSplitter tokenTextSplitter() { | ||||
|         return new TokenTextSplitter(500, 100, 5, 10000, true); | ||||
|     } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 xiaoxin
					xiaoxin