|
20 | 20 | import org.slf4j.LoggerFactory; |
21 | 21 |
|
22 | 22 | import org.springframework.ai.chat.memory.repository.mongo.Conversation; |
| 23 | +import org.springframework.boot.autoconfigure.AutoConfiguration; |
23 | 24 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
24 | 25 | import org.springframework.context.event.ContextRefreshedEvent; |
25 | 26 | import org.springframework.context.event.EventListener; |
26 | 27 | import org.springframework.data.domain.Sort; |
27 | 28 | import org.springframework.data.mongodb.core.MongoTemplate; |
28 | 29 | import org.springframework.data.mongodb.core.index.Index; |
29 | | -import org.springframework.stereotype.Component; |
30 | 30 |
|
31 | 31 | /** |
32 | | - * Class responsible for creating MongoDB proper indices for the ChatMemory. Creates a |
| 32 | + * Class responsible for creating proper MongoDB indices for the ChatMemory. Creates a |
33 | 33 | * main index on the conversationId and timestamp fields, and a TTL index on the timestamp |
34 | 34 | * field if the TTL is set in properties. |
35 | 35 | * |
36 | 36 | * @author Łukasz Jernaś |
37 | 37 | * @see MongoChatMemoryProperties |
38 | 38 | * @since 1.1.0 |
39 | 39 | */ |
40 | | -@Component |
| 40 | +@AutoConfiguration |
41 | 41 | @ConditionalOnProperty(value = "spring.ai.chat.memory.repository.mongo.create-indices", havingValue = "true") |
42 | | -public class MongoChatMemoryIndexCreator { |
| 42 | +public class MongoChatMemoryIndexCreatorAutoConfiguration { |
43 | 43 |
|
44 | | - private static final Logger logger = LoggerFactory.getLogger(MongoChatMemoryIndexCreator.class); |
| 44 | + private static final Logger logger = LoggerFactory.getLogger(MongoChatMemoryIndexCreatorAutoConfiguration.class); |
45 | 45 |
|
46 | 46 | private final MongoTemplate mongoTemplate; |
47 | 47 |
|
48 | 48 | private final MongoChatMemoryProperties mongoChatMemoryProperties; |
49 | 49 |
|
50 | | - public MongoChatMemoryIndexCreator(MongoTemplate mongoTemplate, |
| 50 | + public MongoChatMemoryIndexCreatorAutoConfiguration(MongoTemplate mongoTemplate, |
51 | 51 | MongoChatMemoryProperties mongoChatMemoryProperties) { |
52 | 52 | this.mongoTemplate = mongoTemplate; |
53 | 53 | this.mongoChatMemoryProperties = mongoChatMemoryProperties; |
|
0 commit comments