Added support for mongoDB KV store (#543)

Added the support for mongoDB as KV store
validated in mongodb, it is able to store agent data, session data and
turn data
<img width="1332" alt="image"
src="https://github.com/user-attachments/assets/867700a4-b9ee-4a3c-8278-f39074d39d56">
this is how run.yaml would look:
```
    config:
      persistence_store:
        type: mongodb
        namespace: null
        host: localhost
        port: 27017
        db: llamastack
        user: ""
        password: ""
        collection_name: llamastack_kvstore
```

---------

Co-authored-by: shrinitgoyal <shrinit.goyal@engati.com>
This commit is contained in:
Shrinit Goyal 2025-02-20 12:00:50 +05:30 committed by GitHub
parent 5966079770
commit b74f25035c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 106 additions and 2 deletions

View file

@ -11,7 +11,7 @@ from .config import KVStoreConfig, KVStoreType
def kvstore_dependencies():
return ["aiosqlite", "psycopg2-binary", "redis"]
return ["aiosqlite", "psycopg2-binary", "redis", "pymongo"]
class InmemoryKVStoreImpl(KVStore):
@ -44,6 +44,10 @@ async def kvstore_impl(config: KVStoreConfig) -> KVStore:
from .postgres import PostgresKVStoreImpl
impl = PostgresKVStoreImpl(config)
elif config.type == KVStoreType.mongodb.value:
from .mongodb import MongoDBKVStoreImpl
impl = MongoDBKVStoreImpl(config)
else:
raise ValueError(f"Unknown kvstore type {config.type}")