diff --git a/src/backend/base/langflow/load/utils.py b/src/backend/base/langflow/load/utils.py index 9c2918e91..4012bc934 100644 --- a/src/backend/base/langflow/load/utils.py +++ b/src/backend/base/langflow/load/utils.py @@ -29,7 +29,7 @@ def upload(file_path, host, flow_id): raise Exception(f"Error uploading file: {e}") -def upload_file(file_path, host, flow_id, components, tweaks={}): +def upload_file(file_path: str, host: str, flow_id: str, components: list[str], tweaks: dict | None = None): """ Upload a file to Langflow and return the file path. @@ -47,6 +47,8 @@ def upload_file(file_path, host, flow_id, components, tweaks={}): Raises: Exception: If an error occurs during the upload process. """ + if not tweaks: + tweaks = {} try: response = upload(file_path, host, flow_id) if response["file_path"]: diff --git a/src/frontend/src/modals/apiModal/utils/get-python-api-code.tsx b/src/frontend/src/modals/apiModal/utils/get-python-api-code.tsx index 224d1d711..813e0fb72 100644 --- a/src/frontend/src/modals/apiModal/utils/get-python-api-code.tsx +++ b/src/frontend/src/modals/apiModal/utils/get-python-api-code.tsx @@ -35,7 +35,7 @@ except ImportError: warnings.warn("Langflow provides a function to help you upload files to the flow. Please install langflow to use it.") upload_file = None -BASE_API_URL = "${window.location.protocol}//${window.location.host}/api/v1/run" +BASE_API_URL = "${window.location.protocol}//${window.location.host}" FLOW_ID = "${flowId}" ENDPOINT = "${endpointName || ""}" ${ endpointName @@ -61,7 +61,7 @@ def run_flow(message: str, :param tweaks: Optional tweaks to customize the flow :return: The JSON response from the flow """ - api_url = f"{BASE_API_URL}/{endpoint}" + api_url = f"{BASE_API_URL}/api/v1/run/{endpoint}" payload = { "input_value": message,