fix(get-python-api-code): set the endpoint in the correct variable (#2800)
* feat: refactor upload_file function to handle optional tweaks parameter Refactor the upload_file function in utils.py to handle the optional tweaks parameter. If the tweaks parameter is not provided, it is set to an empty dictionary. This change improves the flexibility and usability of the function. * fix(get-python-api-code): set the endpoint in the correct variable
This commit is contained in:
parent
66e6370ea8
commit
f504bcc8c2
2 changed files with 5 additions and 3 deletions
|
|
@ -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"]:
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue