Sets up metadata db for every llm class (#1401)

This commit is contained in:
Pranav Puranik
2024-08-02 00:45:28 +05:30
committed by GitHub
parent 58b6887bf5
commit b386e24f5d
5 changed files with 22 additions and 14 deletions
+8
View File
@@ -1,9 +1,11 @@
import logging
import os
from collections.abc import Generator
from typing import Any, Optional
from langchain.schema import BaseMessage as LCBaseMessage
from embedchain.constants import SQLITE_PATH
from embedchain.config import BaseLlmConfig
from embedchain.config.llm.base import (
DEFAULT_PROMPT,
@@ -11,6 +13,7 @@ from embedchain.config.llm.base import (
DEFAULT_PROMPT_WITH_MEM0_MEMORY_TEMPLATE,
DOCS_SITE_PROMPT_TEMPLATE,
)
from embedchain.core.db.database import init_db, setup_engine
from embedchain.helpers.json_serializable import JSONSerializable
from embedchain.memory.base import ChatHistory
from embedchain.memory.message import ChatMessage
@@ -30,6 +33,11 @@ class BaseLlm(JSONSerializable):
else:
self.config = config
# Initialize the metadata db for the app here since llmfactory needs it for initialization of
# the llm memory
setup_engine(database_uri=os.environ.get("EMBEDCHAIN_DB_URI", f"sqlite:///{SQLITE_PATH}"))
init_db()
self.memory = ChatHistory()
self.is_docs_site_instance = False
self.history: Any = None