Refactor constants.py to add Message type alias

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-06-23 15:55:30 -03:00
commit 67764c0182

View file

@ -1,4 +1,4 @@
from typing import Callable, Dict, Text, TypeAlias, TypeVar, Union
from typing import Callable, Dict, TypeAlias, TypeVar, Union
from langchain.agents.agent import AgentExecutor
from langchain.chains.base import Chain
@ -16,6 +16,8 @@ from langchain_core.tools import Tool
from langchain_core.vectorstores import VectorStore, VectorStoreRetriever
from langchain_text_splitters import TextSplitter
from langflow.schema.message import Message
NestedDict: TypeAlias = Dict[str, Union[str, Dict]]
LanguageModel = TypeVar("LanguageModel", BaseLanguageModel, BaseLLM, BaseChatModel)
Retriever = TypeVar(
@ -23,6 +25,7 @@ Retriever = TypeVar(
BaseRetriever,
VectorStoreRetriever,
)
Text: TypeAlias = Message
class Object:
@ -62,6 +65,7 @@ CUSTOM_COMPONENT_SUPPORTED_TYPES = {
**LANGCHAIN_BASE_TYPES,
"NestedDict": NestedDict,
"Data": Data,
"Message": Message,
"Text": Text,
"Object": Object,
"Callable": Callable,