spring-ai icon indicating copy to clipboard operation
spring-ai copied to clipboard

Create MongoDB chat memory implementation

Open deejay1 opened this issue 7 months ago • 5 comments

This is the initial implementation of a stock MongoDB chat memory which doesn't require MongoDB Atlas

Closes #2688

deejay1 avatar Apr 09 '25 12:04 deejay1

I feel like it could be better to have only Mongo instead of MongoDb in all classes names. For example : MongoDbChatMemoryProperties.java could be named MongoChatMemoryPropoerties.java.

It would follow the same logic as all classes in org.springframework.data.mongodb (MongoTemplate and not MongoDbTemplate)

Amine-Kadi avatar Apr 17 '25 13:04 Amine-Kadi

I feel like it could be better to have only Mongo instead of MongoDb in all classes names. For example : MongoDbChatMemoryProperties.java could be named MongoChatMemoryPropoerties.java.

It would follow the same logic as all classes in org.springframework.data.mongodb (MongoTemplate and not MongoDbTemplate)

Good idea to keep it in sync. Implemented

deejay1 avatar Apr 17 '25 14:04 deejay1

This will probably be reimplemented tomorrow atop of https://github.com/spring-projects/spring-ai/pull/2803

deejay1 avatar Apr 21 '25 07:04 deejay1

@deejay1 thanks so much for your contribution! We have just delivered some changes to the ChatMemory API which include the introduction of a ChatMemoryRepository API to separate the two different concerns: memory management strategy and storage mechanism. For example, the JdbcChatMemory has now been superseded by JdbcChatMemoryRepository. It would be great if we could use the new approach directly for MongoDB. What do you think?

Upgrade Notes: https://docs.spring.io/spring-ai/reference/upgrade-notes.html#_chat_memory New Chat Memory Docs: https://docs.spring.io/spring-ai/reference/api/chat-memory.html PR with the change: https://github.com/spring-projects/spring-ai/pull/2890

ThomasVitale avatar Apr 25 '25 20:04 ThomasVitale

@ThomasVitale sure, I'll rewrite it of course!

deejay1 avatar Apr 26 '25 12:04 deejay1

@ThomasVitale ok, rewritten into a ChatMemoryRepository implementation

deejay1 avatar Apr 28 '25 11:04 deejay1

@ThomasVitale any chances to get it in before 1.0.0?

deejay1 avatar May 05 '25 09:05 deejay1

Updated to latest changes

deejay1 avatar May 12 '25 10:05 deejay1

@xchopin @eddumelendez Could you take a look again?

deejay1 avatar May 26 '25 11:05 deejay1

@xchopin any update on getting this merged? I am kinda blocked on this.

juzerali avatar Jun 24 '25 05:06 juzerali

Would be nice to have this feature in 1.1.0

Amine-Kadi avatar Jul 29 '25 09:07 Amine-Kadi

@markpollack Can I bump this a little? ;)

deejay1 avatar Sep 04 '25 13:09 deejay1

@ilayaperumalg any chances this also gets merged? we're using it successfully in prod for a while now (since April to be exact ;)

deejay1 avatar Oct 10 '25 10:10 deejay1

This is great and would help a ton - any chance to get this in soon? @markpollack

imod avatar Nov 03 '25 06:11 imod

@deejay1 It seems like you write the metadata information, but doesn't seem to restore it upon read. Is that intentional? Also how about throwing an IllegalStateException for unsupported message types?

sobychacko avatar Nov 06 '25 18:11 sobychacko

Merged on main as 80527b26 for inclusion in 1.1.0

@sobychacko please create issues related to your above comment if you feel like they're relevant.

Thanks everyone for this high quality contribution.

ericbottard avatar Nov 07 '25 15:11 ericbottard

@sobychacko You're right, I've implemented this here https://github.com/spring-projects/spring-ai/pull/4830

deejay1 avatar Nov 07 '25 17:11 deejay1