updating db storage and dependencies

This commit is contained in:
João Moura
2024-04-02 13:51:05 -03:00
parent 244458a1c9
commit 0abfcedda8
5 changed files with 136 additions and 108 deletions

View File

@@ -3,6 +3,7 @@ import sqlite3
from typing import Any, Dict, Union
from crewai.utilities import Printer
from crewai.utilities.paths import db_storage_path
class LTMSQLiteStorage:
@@ -10,7 +11,7 @@ class LTMSQLiteStorage:
An updated SQLite storage class for LTM data storage.
"""
def __init__(self, db_path=".db/long_term_memory_storage.db"):
def __init__(self, db_path=f"{db_storage_path()}/long_term_memory_storage.db"):
self.db_path = db_path
self._printer: Printer = Printer()
self._initialize_db()

View File

@@ -7,6 +7,7 @@ from embedchain import App
from embedchain.llm.base import BaseLlm
from crewai.memory.storage.interface import Storage
from crewai.utilities.paths import db_storage_path
@contextlib.contextmanager
@@ -50,7 +51,7 @@ class RAGStorage(Storage):
"provider": "chroma",
"config": {
"collection_name": type,
"dir": f".db/{type}",
"dir": f"{db_storage_path()}/{type}",
"allow_reset": allow_reset,
},
},

View File

@@ -0,0 +1,12 @@
from pathlib import Path
import appdirs
def db_storage_path():
app_name = "crewai"
app_author = "CrewAI"
data_dir = Path(appdirs.user_data_dir(app_name, app_author))
data_dir.mkdir(parents=True, exist_ok=True)
return data_dir