Skip to content

Commit ecbe2b4

Browse files
authored
build: Upgrade to LangChain 0.2 (#997)
1 parent df22433 commit ecbe2b4

7 files changed

Lines changed: 35 additions & 36 deletions

File tree

code/backend/batch/utilities/document_loading/web.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import List
22
import re
3-
from langchain.docstore.document import Document
43
from langchain_community.document_loaders import WebBaseLoader
54
from .document_loading_base import DocumentLoadingBase
65
from ..common.source_document import SourceDocument
@@ -11,7 +10,7 @@ def __init__(self) -> None:
1110
super().__init__()
1211

1312
def load(self, document_url: str) -> List[SourceDocument]:
14-
documents: List[Document] = WebBaseLoader(document_url).load()
13+
documents = WebBaseLoader(document_url).load()
1514
for document in documents:
1615
document.page_content = re.sub("\n{3,}", "\n\n", document.page_content)
1716
# Remove half non-ascii character from start/end of doc content

code/backend/batch/utilities/helpers/azure_search_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
from typing import Union
3-
from langchain.vectorstores.azuresearch import AzureSearch
3+
from langchain_community.vectorstores import AzureSearch
44
from azure.core.credentials import AzureKeyCredential
55
from azure.identity import DefaultAzureCredential
66
from azure.search.documents import SearchClient

code/backend/batch/utilities/helpers/document_chunking_helper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import List
2-
from langchain.docstore.document import Document
32

3+
from ..common.source_document import SourceDocument
44
from ..document_chunking.chunking_strategy import ChunkingSettings, ChunkingStrategy
55
from ..document_chunking.strategies import get_document_chunker
66

@@ -12,8 +12,8 @@ def __init__(self) -> None:
1212
pass
1313

1414
def chunk(
15-
self, documents: List[Document], chunking: ChunkingSettings
16-
) -> List[Document]:
15+
self, documents: List[SourceDocument], chunking: ChunkingSettings
16+
) -> List[SourceDocument]:
1717
chunker = get_document_chunker(chunking.chunking_strategy.value)
1818
if chunker is None:
1919
raise Exception(

code/backend/batch/utilities/helpers/document_loading_helper.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import List
2-
from langchain.docstore.document import Document
2+
3+
from ..common.source_document import SourceDocument
34
from ..document_loading import LoadingSettings
45
from ..document_loading.strategies import get_document_loader
56

@@ -8,7 +9,7 @@ class DocumentLoading:
89
def __init__(self) -> None:
910
pass
1011

11-
def load(self, document_url: str, loading: LoadingSettings) -> List[Document]:
12+
def load(self, document_url: str, loading: LoadingSettings) -> List[SourceDocument]:
1213
loader = get_document_loader(loading.loading_strategy.value)
1314
if loader is None:
1415
raise Exception(

code/backend/batch/utilities/orchestrator/lang_chain_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from langchain.agents import Tool
44
from langchain.memory import ConversationBufferMemory
55
from langchain.agents import ZeroShotAgent, AgentExecutor
6-
from langchain.chains import LLMChain
6+
from langchain.chains.llm import LLMChain
77
from langchain_community.callbacks import get_openai_callback
88

99
from .orchestrator_base import OrchestratorBase

poetry.lock

Lines changed: 24 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ azure-storage-blob = "12.20.0"
1818
azure-identity = "1.16.0"
1919
flask = {extras = ["async"], version = "^3.0.3"}
2020
openai = "1.30.3"
21-
langchain = "0.1.20"
22-
langchain-community = "0.0.38"
21+
langchain = "0.2.1"
22+
langchain-community = "0.2.1"
2323
langchain-openai = "0.1.7"
2424
requests = "2.32.2"
2525
tiktoken = "0.7.0"

0 commit comments

Comments
 (0)