Skip to content

Commit

Permalink
fix: Lazy load llamaindex imports that are causing issues (#2075)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattzh72 authored Nov 21, 2024
1 parent 37d700a commit b9b83a5
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions letta/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,7 @@
from typing import Any, List, Optional

import numpy as np

# from llama_index.core.base.embeddings import BaseEmbedding
# from llama_index.core.embeddings import BaseEmbedding
# from llama_index.core.base.embeddings.base import BaseEmbedding
# from llama_index.bridge.pydantic import PrivateAttr
# from llama_index.embeddings.base import BaseEmbedding
# from llama_index.embeddings.huggingface_utils import format_text
import tiktoken
from llama_index.core import Document as LlamaIndexDocument

# from llama_index.core.base.embeddings import BaseEmbedding
from llama_index.core.node_parser import SentenceSplitter

from letta.constants import (
EMBEDDING_TO_TOKENIZER_DEFAULT,
Expand All @@ -26,6 +15,9 @@


def parse_and_chunk_text(text: str, chunk_size: int) -> List[str]:
from llama_index.core import Document as LlamaIndexDocument
from llama_index.core.node_parser import SentenceSplitter

parser = SentenceSplitter(chunk_size=chunk_size)
llama_index_docs = [LlamaIndexDocument(text=text)]
nodes = parser.get_nodes_from_documents(llama_index_docs)
Expand Down

0 comments on commit b9b83a5

Please sign in to comment.