From f3935322b925fb5777d79a8ae157b09fb03b6a4f Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 27 Sep 2023 12:58:06 +0200 Subject: [PATCH 1/3] Update lanchain pin. --- requirements-dev.txt | 2 +- spacy_llm/models/langchain/model.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 39bdf903..e546e8d4 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,7 +7,7 @@ mypy>=0.990,<1.1.0; platform_machine != "aarch64" and python_version >= "3.7" black==22.3.0 types-requests==2.28.11.16 # Prompting libraries needed for testing -langchain==0.0.249; python_version>="3.9" +langchain==0.0.302; python_version>="3.9" openai>=0.27; python_version>="3.9" # Necessary for running all local models on GPU. diff --git a/spacy_llm/models/langchain/model.py b/spacy_llm/models/langchain/model.py index b09d1788..633afc45 100644 --- a/spacy_llm/models/langchain/model.py +++ b/spacy_llm/models/langchain/model.py @@ -1,6 +1,7 @@ from typing import Any, Callable, Dict, Iterable, Optional, Type from confection import SimpleFrozenDict +from langchain import llms # noqa: F401 from ...compat import has_langchain, langchain from ...registry import registry From c8a3965715141457f73171aaba99dbdf2b7d35c2 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 27 Sep 2023 13:03:02 +0200 Subject: [PATCH 2/3] Fix import order. --- spacy_llm/models/langchain/model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spacy_llm/models/langchain/model.py b/spacy_llm/models/langchain/model.py index 633afc45..c7f63a96 100644 --- a/spacy_llm/models/langchain/model.py +++ b/spacy_llm/models/langchain/model.py @@ -1,11 +1,12 @@ from typing import Any, Callable, Dict, Iterable, Optional, Type from confection import SimpleFrozenDict -from langchain import llms # noqa: F401 from ...compat import has_langchain, langchain from ...registry import registry +from langchain import llms # noqa: F401, isort:skip + class LangChain: def __init__( From 2f53147bce63e3a5c8a5084a00829659df33efb1 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 27 Sep 2023 13:05:50 +0200 Subject: [PATCH 3/3] Fix import order. --- spacy_llm/models/langchain/model.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spacy_llm/models/langchain/model.py b/spacy_llm/models/langchain/model.py index c7f63a96..668be9f3 100644 --- a/spacy_llm/models/langchain/model.py +++ b/spacy_llm/models/langchain/model.py @@ -5,7 +5,10 @@ from ...compat import has_langchain, langchain from ...registry import registry -from langchain import llms # noqa: F401, isort:skip +try: + from langchain import llms # noqa: F401 +except (ImportError, AttributeError): + llms = None class LangChain: