From 2edffd33eef29c57691e346b00fc77d498fd1ab3 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Mon, 28 Aug 2023 17:54:54 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(endpoints.py):=20add=20missi?= =?UTF-8?q?ng=20colon=20after=20if=20statement=20condition=20=F0=9F=94=92?= =?UTF-8?q?=20chore(endpoints.py):=20rename=20api=5Fkey=20parameter=20to?= =?UTF-8?q?=20api=5Fkey=5Fuser=20for=20clarity=20and=20consistency=20?= =?UTF-8?q?=F0=9F=94=92=20chore(endpoints.py):=20add=20type=20hint=20for?= =?UTF-8?q?=20api=5Fkey=5Fuser=20parameter=20to=20indicate=20it=20is=20of?= =?UTF-8?q?=20type=20User=20=F0=9F=94=92=20chore(endpoints.py):=20remove?= =?UTF-8?q?=20unnecessary=20assignment=20of=20api=5Fkey=5Fuser=20from=20ap?= =?UTF-8?q?i=5Fkey.user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/endpoints.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backend/langflow/api/v1/endpoints.py b/src/backend/langflow/api/v1/endpoints.py index 49426aeb7..9cacefcd4 100644 --- a/src/backend/langflow/api/v1/endpoints.py +++ b/src/backend/langflow/api/v1/endpoints.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Annotated, Optional, Union +from typing import Annotated, Any, Optional, Union from langflow.services.auth.utils import api_key_security, get_current_active_user from langflow.services.cache.utils import save_uploaded_file @@ -40,7 +40,7 @@ def get_all(current_user: User = Depends(get_current_active_user)): native_components = build_langchain_types_dict() # custom_components is a list of dicts # need to merge all the keys into one dict - custom_components_from_file = {} + custom_components_from_file: dict[str, Any] = {} settings_manager = get_settings_manager() if settings_manager.settings.COMPONENTS_PATH: logger.info( @@ -93,19 +93,19 @@ async def process_flow( tweaks: Optional[dict] = None, clear_cache: Annotated[bool, Body(embed=True)] = False, # noqa: F821 session_id: Annotated[Union[None, str], Body(embed=True)] = None, # noqa: F821 - api_key=Depends(api_key_security), + api_key_user: User =Depends(api_key_security), ): """ Endpoint to process an input with a given flow_id. """ try: - if api_key is None: + if api_key_user is None raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid API Key", ) - api_key_user = api_key.user + # Get the flow that matches the flow_id and belongs to the user flow = ( session.query(Flow)