From 5d8673a3c1935a05b2d8c38b7dd20b90d56f9714 Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Tue, 5 Sep 2023 15:25:28 +0100 Subject: [PATCH 1/3] Fix usage of AsyncHtmlLoader with an already running event loop (#10220) --- .../langchain/document_loaders/async_html.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/libs/langchain/langchain/document_loaders/async_html.py b/libs/langchain/langchain/document_loaders/async_html.py index 286319a5ee6..80436bfec60 100644 --- a/libs/langchain/langchain/document_loaders/async_html.py +++ b/libs/langchain/langchain/document_loaders/async_html.py @@ -1,7 +1,8 @@ import asyncio import logging import warnings -from typing import Any, Dict, Iterator, List, Optional, Union +from concurrent.futures import ThreadPoolExecutor +from typing import Any, Dict, Iterator, List, Optional, Union, cast import aiohttp import requests @@ -129,9 +130,18 @@ class AsyncHtmlLoader(BaseLoader): def load(self) -> List[Document]: """Load text from the url(s) in web_path.""" - results = asyncio.run(self.fetch_all(self.web_paths)) + try: + # Raises RuntimeError if there is no current event loop. + asyncio.get_running_loop() + # If there is a current event loop, we need to run the async code + # in a separate loop, in a separate thread. + with ThreadPoolExecutor(max_workers=1) as executor: + future = executor.submit(asyncio.run, self.fetch_all(self.web_paths)) + results = future.result() + except RuntimeError: + results = asyncio.run(self.fetch_all(self.web_paths)) docs = [] - for i, text in enumerate(results): + for i, text in enumerate(cast(List[str], results)): metadata = {"source": self.web_paths[i]} docs.append(Document(page_content=text, metadata=metadata)) From e34ad6fefd74faea1feddcdd5186ebffd3b8bf94 Mon Sep 17 00:00:00 2001 From: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com> Date: Tue, 5 Sep 2023 10:55:47 -0400 Subject: [PATCH 2/3] Temporarily disable step that seems to be transiently failing. (#10234) --- .github/actions/poetry_setup/action.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/actions/poetry_setup/action.yml b/.github/actions/poetry_setup/action.yml index 22dcb05e16e..9d7ce548dea 100644 --- a/.github/actions/poetry_setup/action.yml +++ b/.github/actions/poetry_setup/action.yml @@ -31,20 +31,20 @@ runs: with: python-version: ${{ inputs.python-version }} - - uses: actions/cache@v3 - id: cache-bin-poetry - name: Cache Poetry binary - Python ${{ inputs.python-version }} - env: - SEGMENT_DOWNLOAD_TIMEOUT_MIN: "1" - with: - path: | - /opt/pipx/venvs/poetry - /opt/pipx_bin/poetry - # This step caches the poetry installation, so make sure it's keyed on the poetry version as well. - key: bin-poetry-${{ runner.os }}-${{ runner.arch }}-py-${{ inputs.python-version }}-${{ inputs.poetry-version }} + # - uses: actions/cache@v3 + # id: cache-bin-poetry + # name: Cache Poetry binary - Python ${{ inputs.python-version }} + # env: + # SEGMENT_DOWNLOAD_TIMEOUT_MIN: "1" + # with: + # path: | + # /opt/pipx/venvs/poetry + # /opt/pipx_bin/poetry + # # This step caches the poetry installation, so make sure it's keyed on the poetry version as well. + # key: bin-poetry-${{ runner.os }}-${{ runner.arch }}-py-${{ inputs.python-version }}-${{ inputs.poetry-version }} - name: Install poetry - if: steps.cache-bin-poetry.outputs.cache-hit != 'true' + # if: steps.cache-bin-poetry.outputs.cache-hit != 'true' shell: bash env: POETRY_VERSION: ${{ inputs.poetry-version }} From c8d7ee62ba972af1d58f95524e94550fab7757c8 Mon Sep 17 00:00:00 2001 From: Bagatur <22008038+baskaryan@users.noreply.github.com> Date: Tue, 5 Sep 2023 07:58:00 -0700 Subject: [PATCH 3/3] bump 282 (#10233) --- libs/langchain/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/langchain/pyproject.toml b/libs/langchain/pyproject.toml index d1aedbb544c..e9df12a9911 100644 --- a/libs/langchain/pyproject.toml +++ b/libs/langchain/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langchain" -version = "0.0.281" +version = "0.0.282" description = "Building applications with LLMs through composability" authors = [] license = "MIT"