🔀 refactor(endpoints.py): rename import of build_langchain_types_dict to langchain_types_dict for consistency

🔀 refactor(types.py): add langchain_types_dict as a separate variable to improve code readability and maintainability

The import statement in `endpoints.py` has been updated to import `langchain_types_dict` instead of `build_langchain_types_dict` for consistency with the variable name. This change improves code readability and maintainability.

In `types.py`, a new variable `langchain_types_dict` has been added as a separate variable to store the result of `build_langchain_types_dict()`. This change improves code readability and makes it easier to understand the purpose of the variable.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-29 09:55:59 -03:00
commit f427e17166
2 changed files with 7 additions and 2 deletions

View file

@ -11,7 +11,7 @@ from langflow.api.v1.schemas import (
UploadFileResponse,
)
from langflow.interface.types import build_langchain_types_dict
from langflow.interface.types import langchain_types_dict
from langflow.database.base import get_session
from sqlmodel import Session
@ -21,7 +21,7 @@ router = APIRouter(tags=["Base"])
@router.get("/all")
def get_all():
return build_langchain_types_dict()
return langchain_types_dict
# For backwards compatibility we will keep the old endpoint

View file

@ -11,6 +11,7 @@ from langflow.interface.tools.base import tool_creator
from langflow.interface.utilities.base import utility_creator
from langflow.interface.vector_store.base import vectorstore_creator
from langflow.interface.wrappers.base import wrapper_creator
from langflow.interface.retrievers.base import retriever_creator
def get_type_list():
@ -44,6 +45,7 @@ def build_langchain_types_dict(): # sourcery skip: dict-assign-update-to-union
documentloader_creator,
textsplitter_creator,
utility_creator,
retriever_creator,
]
all_types = {}
@ -52,3 +54,6 @@ def build_langchain_types_dict(): # sourcery skip: dict-assign-update-to-union
if created_types[creator.type_name].values():
all_types.update(created_types)
return all_types
langchain_types_dict = build_langchain_types_dict()