Closed MarkKorenevskiy closed 2 months ago
var searchRequest = SearchRequest.query(request.userText()) .withTopK(this.doGetChatMemoryRetrieveSize(context)) .withFilterExpression( " + DOCUMENT_METADATA_CONVERSATION_ID + "=='" + this.doGetConversationId(context) + "'");
this works, remove the ' around DOCUMENT_METADATA_CONVERSATION_ID
copiedadviseRequest method
@MarkKorenevskiy Could you please share the entire method here? I'm trying to do the same fix, but there are some private fields in VectorStoreChatMemoryAdvisor so I'm wondering how you got access to those.
Bug description When using PGvector as vector store for VectorStoreChatMemoryAdvisor to save conversation history, there is org.postgresql.util.PSQLException "ERROR: syntax error at or near "conversationId"". The problem happens because in adviseRequest method in VectorStoreChatMemoryAdvisor single quotes added around DOCUMENT_METADATA_CONVERSATION_ID, which causes an error when parse it in JDBCTemplate.
Environment SpringAI - 1.0.0-M1 SpringBoot - 3.2.6 Java - 21
Steps to reproduce
ChatClient
bean withVectorStoreChatMemoryAdvisor
default advisor and provide advisor with autowired vector storeVectorStoreChatMemoryAdvisor
tries to do similarity search, exception will be thrown.Expected behavior Return conversation history if any present in PGvector
Custom solution I extended from
VectorStoreChatMemoryAdvisor
, copiedadviseRequest
method and manually removed this single quotes aroundDOCUMENT_METADATA_CONVERSATION_ID
. It completely worked for me.