-
Notifications
You must be signed in to change notification settings - Fork 911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JdbcChatMemory #1528
base: main
Are you sure you want to change the base?
Add JdbcChatMemory #1528
Conversation
...ngframework/ai/autoconfigure/chat/memory/pgvector/PgVectorChatMemoryAutoConfigurationIT.java
Outdated
Show resolved
Hide resolved
...ector-store/src/test/java/org/springframework/ai/chat/memory/PgVectorChatMemoryConfigIT.java
Outdated
Show resolved
Hide resolved
...ai-pgvector-store/src/test/java/org/springframework/ai/chat/memory/PgVectorChatMemoryIT.java
Outdated
Show resolved
Hide resolved
Is it will be usable with VectorStoreChayMemoryAdvisor? Or what is the point ? |
@ogbozoyan |
@leijendary which advisor you should use with that ChatMemory to process saving ? |
@ogbozoyan You can use @Bean
fun chatClient(builder: ChatClient.Builder, vectorStore: VectorStore, chatMemory: ChatMemory): ChatClient {
val memoryAdvisor = MessageChatMemoryAdvisor(chatMemory)
val documentRetriever = VectorStoreDocumentRetriever.builder()
.vectorStore(vectorStore)
.build()
val ragAdvisor = RetrievalAugmentationAdvisor.builder()
.documentRetriever(documentRetriever)
.build()
return builder
.defaultAdvisors(memoryAdvisor, ragAdvisor)
.build()
} |
in this example you passing VectorStore, may be you meant ? fun chatClient(builder: ChatClient.Builder, **pgVectorChatMemory: PgVectorChatMemory**, chatMemory: ChatMemory): ChatClient {
val memoryAdvisor = MessageChatMemoryAdvisor(**pgVectorChatMemory**)
val documentRetriever = VectorStoreDocumentRetriever.builder()
.vectorStore(vectorStore)
.build()
val ragAdvisor = RetrievalAugmentationAdvisor.builder()
.documentRetriever(documentRetriever)
.build()
return builder
.defaultAdvisors(memoryAdvisor, ragAdvisor)
.build()
} |
The code I provided is correct. I am using it right now. The |
I wonder if this should be more generic and instead providing a |
@eddumelendez I agree. I also originally designed it to be the same as the existing CREATE TABLE ai_chat_memory (
session_id character varying(36) NOT NULL,
content text NOT NULL,
type character varying(10) NOT NULL, -- USER/ASSISTANT
"timestamp" timestamp without time zone NOT NULL DEFAULT NOW()
); Do you also mean that the table should not be automatically created and instead be created manually by the developer? |
it should be created automatically by detecting the database. I meant having something like https://github.com/spring-projects/spring-session/blob/main/spring-session-jdbc/src/main/resources/org/springframework/session/jdbc/schema-postgresql.sql that spring ai can execute, so, if new database should be supported then adding a script should be enough |
maybe add check ? CREATE TABLE ai_chat_memory (
session_id character varying(36) NOT NULL,
content text NOT NULL,
type character varying(10) NOT NULL CHECK (type IN ('USER', 'ASSISTANT')), -- USER/ASSISTANT
"timestamp" timestamp without time zone NOT NULL DEFAULT NOW()
); |
An option to use a generic
JdbcChatMemory
with a starter for users that want to use SQL as chat memory.