Skip to content

Commit 044d5af

Browse files
author
80025731
committed
Merge branch 'main' of github.com:LangMem/mem4j into feat-winston
2 parents 61d7617 + e70f25d commit 044d5af

File tree

5 files changed

+616
-547
lines changed

5 files changed

+616
-547
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,4 @@ qdrant_storage/
187187
.crossnote
188188
testing.ipynb
189189
checkstyle-report.xml
190+
.flattened-pom.xml

mem4j-autoconfigure/src/main/java/io/github/mem4j/autoconfigure/MemoryAutoConfiguration.java

Lines changed: 100 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -55,117 +55,113 @@
5555
@EnableConfigurationProperties(MemoryConfig.class)
5656
public class MemoryAutoConfiguration {
5757

58-
private static final Logger logger = LoggerFactory.getLogger(MemoryAutoConfiguration.class);
58+
private static final Logger logger = LoggerFactory.getLogger(MemoryAutoConfiguration.class);
5959

60-
/**
61-
* Creates the main Memory bean with all required dependencies. This bean will be
62-
* created only if no other Memory bean exists.
63-
*
64-
* @param memoryConfig the memory configuration properties
65-
* @param vectorStoreService the vector store service (auto-selected based on config)
66-
* @param llmService the LLM service (auto-selected based on config)
67-
* @param embeddingService the embedding service (auto-selected based on config)
68-
* @return configured Memory instance
69-
*/
70-
@Bean
71-
@ConditionalOnMissingBean
72-
public Memory memory(MemoryConfig memoryConfig, VectorStoreService vectorStoreService, LLMService llmService, EmbeddingService embeddingService) {
73-
logger.info("Creating Memory bean with vector store type: {}", memoryConfig.getVectorStore().getType());
74-
return new Memory(memoryConfig, vectorStoreService, llmService, embeddingService);
75-
}
60+
/**
61+
* Creates the main Memory bean with all required dependencies. This bean will be
62+
* created only if no other Memory bean exists.
63+
* @param memoryConfig the memory configuration properties
64+
* @param vectorStoreService the vector store service (auto-selected based on config)
65+
* @param llmService the LLM service (auto-selected based on config)
66+
* @param embeddingService the embedding service (auto-selected based on config)
67+
* @return configured Memory instance
68+
*/
69+
@Bean
70+
@ConditionalOnMissingBean
71+
public Memory memory(MemoryConfig memoryConfig, VectorStoreService vectorStoreService, LLMService llmService,
72+
EmbeddingService embeddingService) {
73+
logger.info("Creating Memory bean with vector store type: {}", memoryConfig.getVectorStore().getType());
74+
return new Memory(memoryConfig, vectorStoreService, llmService, embeddingService);
75+
}
7676

77-
/**
78-
* Creates an InMemoryVectorStore service when no other VectorStore is configured or
79-
* when explicitly configured to use 'inmemory' type.
80-
*
81-
* @return InMemoryVectorStoreService instance
82-
*/
83-
@Bean
84-
@ConditionalOnMissingBean
85-
@ConditionalOnProperty(prefix = "mem4j.vector-store", name = "type", havingValue = "inmemory", matchIfMissing = true)
86-
public VectorStoreService inMemoryVectorStoreService() {
87-
logger.info("Creating InMemoryVectorStoreService");
88-
return new InMemoryVectorStoreService();
89-
}
77+
/**
78+
* Creates an InMemoryVectorStore service when no other VectorStore is configured or
79+
* when explicitly configured to use 'inmemory' type.
80+
* @return InMemoryVectorStoreService instance
81+
*/
82+
@Bean
83+
@ConditionalOnMissingBean
84+
@ConditionalOnProperty(prefix = "mem4j.vector-store", name = "type", havingValue = "inmemory",
85+
matchIfMissing = true)
86+
public VectorStoreService inMemoryVectorStoreService() {
87+
logger.info("Creating InMemoryVectorStoreService");
88+
return new InMemoryVectorStoreService();
89+
}
9090

91-
/**
92-
* Creates a Qdrant VectorStore service when configured to use 'qdrant' type. This
93-
* bean will only be created if the Qdrant client classes are available on the
94-
* classpath.
95-
*
96-
* @param memoryConfig the memory configuration properties
97-
* @return QdrantVectorStoreService instance
98-
*/
99-
@Bean
100-
@ConditionalOnMissingBean
101-
@ConditionalOnProperty(prefix = "mem4j.vector-store", name = "type", havingValue = "qdrant")
102-
@ConditionalOnClass(name = "io.qdrant.client.QdrantClient")
103-
public VectorStoreService qdrantVectorStoreService(MemoryConfig memoryConfig) {
104-
logger.info("Creating QdrantVectorStoreService");
105-
return new QdrantVectorStoreService(memoryConfig);
106-
}
91+
/**
92+
* Creates a Qdrant VectorStore service when configured to use 'qdrant' type. This
93+
* bean will only be created if the Qdrant client classes are available on the
94+
* classpath.
95+
* @param memoryConfig the memory configuration properties
96+
* @return QdrantVectorStoreService instance
97+
*/
98+
@Bean
99+
@ConditionalOnMissingBean
100+
@ConditionalOnProperty(prefix = "mem4j.vector-store", name = "type", havingValue = "qdrant")
101+
@ConditionalOnClass(name = "io.qdrant.client.QdrantClient")
102+
public VectorStoreService qdrantVectorStoreService(MemoryConfig memoryConfig) {
103+
logger.info("Creating QdrantVectorStoreService");
104+
return new QdrantVectorStoreService(memoryConfig);
105+
}
107106

108-
/**
109-
* Creates a Milvus VectorStore service when configured to use 'milvus' type. This
110-
* bean will only be created if the Milvus client classes are available on the
111-
* classpath.
112-
*
113-
* @param memoryConfig the memory configuration properties
114-
* @return MilvusVectorStoreService instance
115-
*/
116-
@Bean
117-
@ConditionalOnMissingBean
118-
@ConditionalOnProperty(prefix = "mem4j.vector-store", name = "type", havingValue = "milvus", matchIfMissing = true)
119-
@ConditionalOnClass(name = "io.milvus.client.MilvusClient")
120-
public VectorStoreService milvusVectorStoreService(MemoryConfig memoryConfig) {
121-
logger.info("Creating MilvusVectorStoreService");
122-
return new MilvusVectorStoreService(memoryConfig);
123-
}
107+
/**
108+
* Creates a Milvus VectorStore service when configured to use 'milvus' type. This
109+
* bean will only be created if the Milvus client classes are available on the
110+
* classpath.
111+
* @param memoryConfig the memory configuration properties
112+
* @return MilvusVectorStoreService instance
113+
*/
114+
@Bean
115+
@ConditionalOnMissingBean
116+
@ConditionalOnProperty(prefix = "mem4j.vector-store", name = "type", havingValue = "milvus", matchIfMissing = true)
117+
@ConditionalOnClass(name = "io.milvus.client.MilvusClient")
118+
public VectorStoreService milvusVectorStoreService(MemoryConfig memoryConfig) {
119+
logger.info("Creating MilvusVectorStoreService");
120+
return new MilvusVectorStoreService(memoryConfig);
121+
}
124122

125-
/**
126-
* Creates the appropriate LLM service based on configuration. Supports OpenAI and
127-
* DashScope implementations.
128-
*
129-
* @param memoryConfig the memory configuration properties
130-
* @return LLMService instance based on configuration
131-
*/
132-
@Bean
133-
@ConditionalOnMissingBean
134-
public LLMService llmService(MemoryConfig memoryConfig) {
135-
String llmType = memoryConfig.getLlm().getType();
136-
logger.info("Creating LLM service of type: {}", llmType);
123+
/**
124+
* Creates the appropriate LLM service based on configuration. Supports OpenAI and
125+
* DashScope implementations.
126+
* @param memoryConfig the memory configuration properties
127+
* @return LLMService instance based on configuration
128+
*/
129+
@Bean
130+
@ConditionalOnMissingBean
131+
public LLMService llmService(MemoryConfig memoryConfig) {
132+
String llmType = memoryConfig.getLlm().getType();
133+
logger.info("Creating LLM service of type: {}", llmType);
137134

138-
return switch (llmType.toLowerCase()) {
139-
case "dashscope" -> new DashScopeLLMService(memoryConfig);
140-
case "openai" -> new OpenAILLMService(memoryConfig);
141-
default -> {
142-
logger.warn("Unknown LLM type: {}, falling back to OpenAI", llmType);
143-
yield new OpenAILLMService(memoryConfig);
144-
}
145-
};
146-
}
135+
return switch (llmType.toLowerCase()) {
136+
case "dashscope" -> new DashScopeLLMService(memoryConfig);
137+
case "openai" -> new OpenAILLMService(memoryConfig);
138+
default -> {
139+
logger.warn("Unknown LLM type: {}, falling back to OpenAI", llmType);
140+
yield new OpenAILLMService(memoryConfig);
141+
}
142+
};
143+
}
147144

148-
/**
149-
* Creates the appropriate Embedding service based on configuration. Supports OpenAI
150-
* and DashScope implementations.
151-
*
152-
* @param memoryConfig the memory configuration properties
153-
* @return EmbeddingService instance based on configuration
154-
*/
155-
@Bean
156-
@ConditionalOnMissingBean
157-
public EmbeddingService embeddingService(MemoryConfig memoryConfig) {
158-
String embeddingType = memoryConfig.getEmbeddings().getType();
159-
logger.info("Creating Embedding service of type: {}", embeddingType);
145+
/**
146+
* Creates the appropriate Embedding service based on configuration. Supports OpenAI
147+
* and DashScope implementations.
148+
* @param memoryConfig the memory configuration properties
149+
* @return EmbeddingService instance based on configuration
150+
*/
151+
@Bean
152+
@ConditionalOnMissingBean
153+
public EmbeddingService embeddingService(MemoryConfig memoryConfig) {
154+
String embeddingType = memoryConfig.getEmbeddings().getType();
155+
logger.info("Creating Embedding service of type: {}", embeddingType);
160156

161-
return switch (embeddingType.toLowerCase()) {
162-
case "dashscope" -> new DashScopeEmbeddingService(memoryConfig);
163-
case "openai" -> new OpenAIEmbeddingService(memoryConfig);
164-
default -> {
165-
logger.warn("Unknown embedding type: {}, falling back to OpenAI", embeddingType);
166-
yield new OpenAIEmbeddingService(memoryConfig);
167-
}
168-
};
169-
}
157+
return switch (embeddingType.toLowerCase()) {
158+
case "dashscope" -> new DashScopeEmbeddingService(memoryConfig);
159+
case "openai" -> new OpenAIEmbeddingService(memoryConfig);
160+
default -> {
161+
logger.warn("Unknown embedding type: {}, falling back to OpenAI", embeddingType);
162+
yield new OpenAIEmbeddingService(memoryConfig);
163+
}
164+
};
165+
}
170166

171167
}

0 commit comments

Comments
 (0)