Skip to content

Commit

Permalink
BUGFIX: Add import types and typevars from core (#13829)
Browse files Browse the repository at this point in the history
  • Loading branch information
baskaryan authored Nov 25, 2023
1 parent 751226e commit 58f7e10
Show file tree
Hide file tree
Showing 22 changed files with 73 additions and 18 deletions.
2 changes: 2 additions & 0 deletions libs/core/langchain_core/language_models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from langchain_core.language_models.base import (
BaseLanguageModel,
LanguageModelInput,
LanguageModelOutput,
get_tokenizer,
)
from langchain_core.language_models.chat_models import BaseChatModel, SimpleChatModel
Expand All @@ -14,4 +15,5 @@
"LLM",
"LanguageModelInput",
"get_tokenizer",
"LanguageModelOutput",
]
1 change: 1 addition & 0 deletions libs/core/tests/unit_tests/language_models/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"BaseLLM",
"LLM",
"LanguageModelInput",
"LanguageModelOutput",
"get_tokenizer",
]

Expand Down
4 changes: 2 additions & 2 deletions libs/langchain/langchain/schema/cache.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from langchain_core.caches import BaseCache
from langchain_core.caches import RETURN_VAL_TYPE, BaseCache

__all__ = ["BaseCache"]
__all__ = ["BaseCache", "RETURN_VAL_TYPE"]
15 changes: 13 additions & 2 deletions libs/langchain/langchain/schema/language_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
from langchain_core.language_models import BaseLanguageModel, get_tokenizer
from langchain_core.language_models import (
BaseLanguageModel,
LanguageModelInput,
LanguageModelOutput,
get_tokenizer,
)
from langchain_core.language_models.base import _get_token_ids_default_method

__all__ = ["get_tokenizer", "BaseLanguageModel", "_get_token_ids_default_method"]
__all__ = [
"get_tokenizer",
"BaseLanguageModel",
"_get_token_ids_default_method",
"LanguageModelInput",
"LanguageModelOutput",
]
2 changes: 2 additions & 0 deletions libs/langchain/langchain/schema/messages.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from langchain_core.messages import (
AIMessage,
AIMessageChunk,
AnyMessage,
BaseMessage,
BaseMessageChunk,
ChatMessage,
Expand Down Expand Up @@ -46,4 +47,5 @@
"_message_to_dict",
"_message_from_dict",
"message_to_dict",
"AnyMessage",
]
2 changes: 2 additions & 0 deletions libs/langchain/langchain/schema/output_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
BaseTransformOutputParser,
StrOutputParser,
)
from langchain_core.output_parsers.base import T

# Backwards compatibility.
NoOpOutputParser = StrOutputParser
Expand All @@ -20,4 +21,5 @@
"NoOpOutputParser",
"StrOutputParser",
"OutputParserException",
"T",
]
7 changes: 7 additions & 0 deletions libs/langchain/langchain/schema/runnable/base.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
from langchain_core.runnables.base import (
Other,
Runnable,
RunnableBinding,
RunnableBindingBase,
RunnableEach,
RunnableEachBase,
RunnableGenerator,
RunnableLambda,
RunnableLike,
RunnableParallel,
RunnableSequence,
RunnableSerializable,
coerce_to_runnable,
)
from langchain_core.runnables.utils import Input, Output

# Backwards compatibility.
RunnableMap = RunnableParallel

__all__ = [
"Input",
"Output",
"RunnableLike",
"Other",
"Runnable",
"RunnableSerializable",
"RunnableSequence",
Expand Down
12 changes: 10 additions & 2 deletions libs/langchain/langchain/schema/runnable/history.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
from langchain_core.runnables.history import RunnableWithMessageHistory
from langchain_core.runnables.history import (
GetSessionHistoryCallable,
MessagesOrDictWithMessages,
RunnableWithMessageHistory,
)

__all__ = ["RunnableWithMessageHistory"]
__all__ = [
"RunnableWithMessageHistory",
"GetSessionHistoryCallable",
"MessagesOrDictWithMessages",
]
4 changes: 2 additions & 2 deletions libs/langchain/langchain/schema/runnable/retry.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from langchain_core.runnables.retry import RunnableRetry
from langchain_core.runnables.retry import RunnableRetry, U

__all__ = ["RunnableRetry"]
__all__ = ["RunnableRetry", "U"]
4 changes: 4 additions & 0 deletions libs/langchain/langchain/schema/runnable/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from langchain_core.runnables.utils import (
Addable,
AddableDict,
AnyConfigurableField,
ConfigurableField,
ConfigurableFieldMultiOption,
ConfigurableFieldSingleOption,
Expand Down Expand Up @@ -44,4 +46,6 @@
"gather_with_concurrency",
"Input",
"Output",
"Addable",
"AnyConfigurableField",
]
4 changes: 2 additions & 2 deletions libs/langchain/langchain/schema/storage.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from langchain_core.stores import BaseStore
from langchain_core.stores import BaseStore, K, V

__all__ = ["BaseStore"]
__all__ = ["BaseStore", "K", "V"]
4 changes: 2 additions & 2 deletions libs/langchain/langchain/schema/vectorstore.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from langchain_core.vectorstores import VectorStore, VectorStoreRetriever
from langchain_core.vectorstores import VST, VectorStore, VectorStoreRetriever

__all__ = ["VectorStore", "VectorStoreRetriever"]
__all__ = ["VectorStore", "VectorStoreRetriever", "VST"]
4 changes: 4 additions & 0 deletions libs/langchain/tests/unit_tests/schema/runnable/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"RunnableSequence",
"RunnableSerializable",
"coerce_to_runnable",
"Input",
"Output",
"Other",
"RunnableLike",
]


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from langchain.schema.runnable.history import __all__

EXPECTED_ALL = ["RunnableWithMessageHistory"]
EXPECTED_ALL = [
"RunnableWithMessageHistory",
"GetSessionHistoryCallable",
"MessagesOrDictWithMessages",
]


def test_all_imports() -> None:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from langchain.schema.runnable.retry import __all__

EXPECTED_ALL = ["RunnableRetry"]
EXPECTED_ALL = ["RunnableRetry", "U"]


def test_all_imports() -> None:
Expand Down
2 changes: 2 additions & 0 deletions libs/langchain/tests/unit_tests/schema/runnable/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"indent_lines_after_first",
"Input",
"Output",
"Addable",
"AnyConfigurableField",
]


Expand Down
2 changes: 1 addition & 1 deletion libs/langchain/tests/unit_tests/schema/test_cache.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from langchain.schema.cache import __all__

EXPECTED_ALL = ["BaseCache"]
EXPECTED_ALL = ["BaseCache", "RETURN_VAL_TYPE"]


def test_all_imports() -> None:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
from langchain.schema.language_model import __all__

EXPECTED_ALL = ["BaseLanguageModel", "_get_token_ids_default_method", "get_tokenizer"]
EXPECTED_ALL = [
"BaseLanguageModel",
"_get_token_ids_default_method",
"get_tokenizer",
"LanguageModelOutput",
"LanguageModelInput",
]


def test_all_imports() -> None:
Expand Down
1 change: 1 addition & 0 deletions libs/langchain/tests/unit_tests/schema/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"merge_content",
"messages_from_dict",
"messages_to_dict",
"AnyMessage",
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"NoOpOutputParser",
"OutputParserException",
"StrOutputParser",
"T",
]


Expand Down
2 changes: 1 addition & 1 deletion libs/langchain/tests/unit_tests/schema/test_storage.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from langchain.schema.storage import __all__

EXPECTED_ALL = ["BaseStore"]
EXPECTED_ALL = ["BaseStore", "K", "V"]


def test_all_imports() -> None:
Expand Down
2 changes: 1 addition & 1 deletion libs/langchain/tests/unit_tests/schema/test_vectorstore.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from langchain.schema.vectorstore import __all__

EXPECTED_ALL = ["VectorStore", "VectorStoreRetriever"]
EXPECTED_ALL = ["VectorStore", "VectorStoreRetriever", "VST"]


def test_all_imports() -> None:
Expand Down

0 comments on commit 58f7e10

Please sign in to comment.