Skip to content

Commit

Permalink
update to langchain-core >= 0.3 (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
vbarda authored Oct 15, 2024
1 parent cca4729 commit e3d5978
Show file tree
Hide file tree
Showing 5 changed files with 292 additions and 235 deletions.
6 changes: 6 additions & 0 deletions backend/embeddings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from langchain_core.embeddings import Embeddings
from langchain_openai import OpenAIEmbeddings


def get_embeddings_model() -> Embeddings:
return OpenAIEmbeddings(model="text-embedding-3-small", chunk_size=200)
2 changes: 1 addition & 1 deletion backend/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from langsmith import Client as LangsmithClient

from backend.constants import WEAVIATE_DOCS_INDEX_NAME
from backend.ingest import get_embeddings_model
from backend.embeddings import get_embeddings_model

RESPONSE_TEMPLATE = """\
You are an expert programmer and problem-solver, tasked with answering any question \
Expand Down
9 changes: 2 additions & 7 deletions backend/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,18 @@
from bs4 import BeautifulSoup, SoupStrainer
from langchain.document_loaders import RecursiveUrlLoader, SitemapLoader
from langchain.indexes import SQLRecordManager, index
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.utils.html import PREFIXES_TO_IGNORE_REGEX, SUFFIXES_TO_IGNORE_REGEX
from langchain_core.embeddings import Embeddings
from langchain_openai import OpenAIEmbeddings
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_weaviate import WeaviateVectorStore

from backend.constants import WEAVIATE_DOCS_INDEX_NAME
from backend.embeddings import get_embeddings_model
from backend.parser import langchain_docs_extractor

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


def get_embeddings_model() -> Embeddings:
return OpenAIEmbeddings(model="text-embedding-3-small", chunk_size=200)


def metadata_extractor(
meta: dict, soup: BeautifulSoup, title_suffix: Optional[str] = None
) -> dict:
Expand Down
Loading

0 comments on commit e3d5978

Please sign in to comment.