Use embeddings model store from state in text to entries

Do not need to instantiating it separately. In all other places we're
using the embeddings model store in global state anyway
This commit is contained in:
Debanjum Singh Solanky 2023-11-15 17:05:49 -08:00
parent f88a5867b4
commit 0679b2a7bd

View file

@ -6,15 +6,15 @@ import logging
import uuid
from tqdm import tqdm
from typing import Callable, List, Tuple, Set, Any
from khoj.utils import state
from khoj.utils.helpers import is_none_or_empty, timer, batcher
# Internal Packages
from khoj.utils.rawconfig import Entry
from khoj.processor.embeddings import EmbeddingsModel
from khoj.search_filter.date_filter import DateFilter
from database.models import KhojUser, Entry as DbEntry, EntryDates
from database.adapters import EntryAdapters, get_or_create_search_model
from database.adapters import EntryAdapters
logger = logging.getLogger(__name__)
@ -22,8 +22,7 @@ logger = logging.getLogger(__name__)
class TextToEntries(ABC):
def __init__(self, config: Any = None):
bi_encoder_name = get_or_create_search_model().bi_encoder
self.embeddings_model = EmbeddingsModel(bi_encoder_name)
self.embeddings_model = state.embeddings_model
self.config = config
self.date_filter = DateFilter()