Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
Lazy load chroma (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakethekoenig authored Feb 21, 2024
1 parent a2d109f commit 3c16705
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion mentat/feature_filters/embedding_similarity_filter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from mentat.code_feature import CodeFeature
from mentat.embeddings import get_feature_similarity_scores
from mentat.feature_filters.feature_filter import FeatureFilter


Expand All @@ -11,6 +10,10 @@ async def score(
self,
features: list[CodeFeature],
) -> list[tuple[CodeFeature, float]]:
from mentat.embeddings import ( # dynamic import to improve startup time.
get_feature_similarity_scores,
)

if self.query == "":
return [(f, 0.0) for f in features]

Expand Down
6 changes: 5 additions & 1 deletion mentat/llm_api_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pathlib import Path
from timeit import default_timer
from typing import (
TYPE_CHECKING,
Any,
AsyncIterator,
Callable,
Expand All @@ -22,7 +23,6 @@
import attr
import sentry_sdk
import tiktoken
from chromadb.api.types import Embeddings
from dotenv import load_dotenv
from openai import (
APIConnectionError,
Expand All @@ -48,6 +48,10 @@

TOKEN_COUNT_WARNING = 32000

if TYPE_CHECKING:
# This import is slow
from chromadb.api.types import Embeddings


def is_test_environment():
"""Returns True if in pytest and not benchmarks"""
Expand Down

0 comments on commit 3c16705

Please sign in to comment.