Repository: mem0ai/mem0
Pull request: allow_reset as constructor argument
## Description

Set `allow_reset` as constructor argument in ChromadbConfig.

Fixes #608 

## Type of change

Please delete options that are not relevant.

- [x] New feature (non-breaking change which adds functionality)

## How Has This Been Tested?

- [x] Unit Test

## Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
- [x] I have checked my code and corrected any misspellings


Problem statement:
feature request: `allow_reset` as a constructor argument for `ChromaDbConfig`
### 🚀 The feature

Currently we throw 
```
ValueError: For safety reasons, resetting is disabled.Please enable it by including `chromadb_settings={"allow_reset": True}` in your ChromaDbConfig`.
```

It's debatable whether we need this safety mechanism at all.

But either way, allow_reset should be directly configurable under ChromaDbConfig, without the need to pass it as a dict in the "advanced settings".

So the task is to make this accessible from the ChromaDbConfig constructor.

This 

```python
app = App(chromadb_config=ChromaDbConfig(chroma_settings={"allow_reset": True}))
```

should turn into this

```python
app = App(chromadb_config=ChromaDbConfig(allow_reset=True))
```

### Motivation, pitch

allow_reset should be directly configurable under ChromaDbConfig, without the need to pass it as a dict in the "advanced settings".

Hints from issue discussion:
Can I pick it up @cachho?
> Can I pick it up @cachho?

yes
Just make sure to update the actual code, tests and the error message
> Just make sure to update the actual code, tests and the error message

Yes

Commit message: allow_reset as constructor argument

Patch to review:
diff --git a/embedchain/config/vectordbs/ChromaDbConfig.py b/embedchain/config/vectordbs/ChromaDbConfig.py
index a1b32559cd..31d3e3c7d8 100644
--- a/embedchain/config/vectordbs/ChromaDbConfig.py
+++ b/embedchain/config/vectordbs/ChromaDbConfig.py
@@ -13,6 +13,7 @@ def __init__(
         host: Optional[str] = None,
         port: Optional[str] = None,
         chroma_settings: Optional[dict] = None,
+        allow_reset=False,
     ):
         """
         Initializes a configuration class instance for ChromaDB.
@@ -27,9 +28,10 @@ def __init__(
         :type port: Optional[str], optional
         :param chroma_settings: Chroma settings dict, defaults to None
         :type chroma_settings: Optional[dict], optional
+        :param allow_reset: Resets the database. defaults to False
+        :type allow_reset: bool
         """
-        """
-        :param chroma_settings: Optional. Chroma settings for connection.
-        """
+
         self.chroma_settings = chroma_settings
+        self.allow_reset = allow_reset
         super().__init__(collection_name=collection_name, dir=dir, host=host, port=port)
diff --git a/embedchain/vectordb/chroma.py b/embedchain/vectordb/chroma.py
index cb28b68d5d..704954f5f5 100644
--- a/embedchain/vectordb/chroma.py
+++ b/embedchain/vectordb/chroma.py
@@ -37,6 +37,7 @@ def __init__(self, config: Optional[ChromaDbConfig] = None):
             self.config = ChromaDbConfig()
 
         self.settings = Settings()
+        self.settings.allow_reset = self.config.allow_reset
         if self.config.chroma_settings:
             for key, value in self.config.chroma_settings.items():
                 if hasattr(self.settings, key):
@@ -209,7 +210,7 @@ def reset(self):
         except ValueError:
             raise ValueError(
                 "For safety reasons, resetting is disabled."
-                'Please enable it by including `chromadb_settings={"allow_reset": True}` in your ChromaDbConfig'
+                "Please enable it by setting `allow_reset=True` in your ChromaDbConfig"
             ) from None
         # Recreate
         self._get_or_create_collection(self.config.collection_name)
diff --git a/tests/vectordb/test_chroma_db.py b/tests/vectordb/test_chroma_db.py
index b87e3a02d2..e9c5f9d9c3 100644
--- a/tests/vectordb/test_chroma_db.py
+++ b/tests/vectordb/test_chroma_db.py
@@ -93,8 +93,7 @@ def test_init_with_host_and_port_log_level(self, mock_client):
 
 
 class TestChromaDbDuplicateHandling:
-    chroma_settings = {"allow_reset": True}
-    chroma_config = ChromaDbConfig(chroma_settings=chroma_settings)
+    chroma_config = ChromaDbConfig(allow_reset=True)
     app_config = AppConfig(collection_name=False, collect_metrics=False)
     app_with_settings = App(config=app_config, chromadb_config=chroma_config)
 
@@ -130,8 +129,7 @@ def test_duplicates_collections_no_warning(self, caplog):
 
 
 class TestChromaDbCollection(unittest.TestCase):
-    chroma_settings = {"allow_reset": True}
-    chroma_config = ChromaDbConfig(chroma_settings=chroma_settings)
+    chroma_config = ChromaDbConfig(allow_reset=True)
     app_config = AppConfig(collection_name=False, collect_metrics=False)
     app_with_settings = App(config=app_config, chromadb_config=chroma_config)
 


Code review comments:
diff_hunk: @@ -27,9 +28,10 @@ def __init__(
         :type port: Optional[str], optional
         :param chroma_settings: Chroma settings dict, defaults to None
         :type chroma_settings: Optional[dict], optional
+        :param allow_reset: Resets the database. defaults to False
path: embedchain/config/vectordbs/ChromaDbConfig.py
text: @user1:
I'd prefer if you changed the order (I know that could break stuff), but `chroma_settings` is a catch-all solution that should come last.