-
Notifications
You must be signed in to change notification settings - Fork 592
Python: Add Cosmos DB ChatMessageStore sample example for external chat history #1533
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
base: main
Are you sure you want to change the base?
Python: Add Cosmos DB ChatMessageStore sample example for external chat history #1533
Conversation
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey great work! I have started to work on something similar and your works looks nice. Just a small comments from my site on this and one more thought. Feel free to implement or ignore them 😄
You could also think to add this maybe as a package so others could make easy use of you class without copying your code.
python/samples/getting_started/chat_store/third_party_chat_store_cosmosDB.py
Outdated
Show resolved
Hide resolved
python/samples/getting_started/chat_store/third_party_chat_store_cosmos_db.py
Show resolved
Hide resolved
python/samples/getting_started/chat_store/third_party_chat_store_cosmosDB.py
Outdated
Show resolved
Hide resolved
python/samples/getting_started/chat_store/third_party_chat_store_cosmosDB.py
Outdated
Show resolved
Hide resolved
|
Thanks, @nmoeller the idea to package this is excellent and really helpful. I’m planning to implement that. In the meantime, I’ve updated the sample with your suggested changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few fore "editorial" things. But overall looking good 👍
Could we rename third_party_chat_store_cosmosDB.py to third_party_chat_store_cosmos_db.py or third_party_chat_store_cosmosdb.py ? I did not yet found a file with upper cases in the repo.
Thanks you for working on this, nearly there !
python/samples/getting_started/chat_store/third_party_chat_store_cosmos_db.py
Show resolved
Hide resolved
python/samples/getting_started/chat_store/third_party_chat_store_cosmos_db.py
Show resolved
Hide resolved
python/samples/getting_started/chat_store/third_party_chat_store_cosmosDB.py
Outdated
Show resolved
Hide resolved
python/samples/getting_started/chat_store/third_party_chat_store_cosmosDB.py
Outdated
Show resolved
Hide resolved
python/samples/getting_started/chat_store/third_party_chat_store_cosmosDB.py
Outdated
Show resolved
Hide resolved
python/samples/getting_started/chat_store/third_party_chat_store_cosmosDB.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small thing from my side, which is again more editorial.
Thanks for working on this, let's see what the Core Team says to this as well 👍
Motivation and Context
This change introduces a Cosmos DB–backed
ChatMessageStoreimplementation that enables developers to persist agent chat history externally instead of relying on the default in-memory storage.Why is this change required?
Many production scenarios require durable and queryable chat history beyond process lifetime, especially when scaling agents horizontally or resuming long-running threads.
What problem does it solve?
Existing examples only demonstrate in-memory or vector-based message storage. This contribution provides a clear, working reference for integrating Azure Cosmos DB (Core SQL API) as a persistent external store.
What scenario does it contribute to?
/thread_id) for scalable storageRelated issue (if any):
N/A – this is a new sample addition.
Description
This PR adds a new sample file:
chat_store/third_party_chat_store_cosmosDB.pyKey highlights:
CosmosDBChatMessageStorefor the Microsoft Agent Framework.partition_key=/thread_id)ORDER BY ts ASC)store.aclose()andchat_client.aclose()ChatAgentandAzureOpenAIChatClient.Contribution Checklist