mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-30 19:03:01 +01:00
Only import type hint packages for type checking. Avoids circular imports
Use annotations from the __future__ package to avoid having to quote type hints. This import will not be required after Python 3.11
This commit is contained in:
parent
e5254a8e56
commit
db7483329c
2 changed files with 20 additions and 15 deletions
|
@ -1,15 +1,19 @@
|
|||
# System Packages
|
||||
from __future__ import annotations # to avoid quoting type hints
|
||||
from enum import Enum
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
# External Packages
|
||||
import torch
|
||||
|
||||
# Internal Packages
|
||||
from src.utils.rawconfig import ConversationProcessorConfig, Entry
|
||||
from src.search_filter.base_filter import BaseFilter
|
||||
from src.utils.models import BaseEncoder
|
||||
if TYPE_CHECKING:
|
||||
from sentence_transformers import CrossEncoder
|
||||
from src.search_filter.base_filter import BaseFilter
|
||||
from src.utils.models import BaseEncoder
|
||||
from src.utils.rawconfig import ConversationProcessorConfig, Entry
|
||||
|
||||
|
||||
class SearchType(str, Enum):
|
||||
|
@ -25,7 +29,7 @@ class ProcessorType(str, Enum):
|
|||
|
||||
|
||||
class TextSearchModel():
|
||||
def __init__(self, entries: list[Entry], corpus_embeddings: torch.Tensor, bi_encoder: BaseEncoder, cross_encoder, filters: list[BaseFilter], top_k):
|
||||
def __init__(self, entries: list[Entry], corpus_embeddings: torch.Tensor, bi_encoder: BaseEncoder, cross_encoder: CrossEncoder, filters: list[BaseFilter], top_k):
|
||||
self.entries = entries
|
||||
self.corpus_embeddings = corpus_embeddings
|
||||
self.bi_encoder = bi_encoder
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
# Standard Packages
|
||||
from pathlib import Path
|
||||
from importlib import import_module
|
||||
import sys
|
||||
from os.path import join
|
||||
from collections import OrderedDict
|
||||
from typing import Optional, Union
|
||||
from __future__ import annotations # to avoid quoting type hints
|
||||
import logging
|
||||
import sys
|
||||
from collections import OrderedDict
|
||||
from importlib import import_module
|
||||
from os.path import join
|
||||
from pathlib import Path
|
||||
from typing import Optional, Union, TYPE_CHECKING
|
||||
|
||||
# External Packages
|
||||
from sentence_transformers import CrossEncoder
|
||||
|
||||
# Internal Packages
|
||||
from src.utils.models import BaseEncoder
|
||||
if TYPE_CHECKING:
|
||||
# External Packages
|
||||
from sentence_transformers import CrossEncoder
|
||||
# Internal Packages
|
||||
from src.utils.models import BaseEncoder
|
||||
|
||||
|
||||
def is_none_or_empty(item):
|
||||
|
|
Loading…
Reference in a new issue