Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/unstract/api_deployments/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import logging
import ntpath
import os
import json
from urllib.parse import urlparse

import requests
Expand Down Expand Up @@ -99,11 +100,12 @@ def __save_base_url(self, full_url: str):
self.base_url = parsed_url.scheme + "://" + parsed_url.netloc
self.logger.debug("Base URL: " + self.base_url)

def structure_file(self, file_paths: list[str]) -> dict:
def structure_file(self, file_paths: list[str], custom_data: dict = None) -> dict:
"""Invokes the API deployed on the Unstract platform.

Args:
file_paths (list[str]): The file path to the file to be uploaded.
custom_data (dict, optional): Custom data to send with the request.

Returns:
dict: The response from the API.
Expand All @@ -116,6 +118,10 @@ def structure_file(self, file_paths: list[str]) -> dict:
}

data = {"timeout": self.api_timeout, "include_metadata": self.include_metadata}
# Add custom_data if provided
if custom_data is not None:
data["custom_data"] = json.dumps(custom_data) if isinstance(custom_data, dict) else custom_data
self.logger.debug("Custom data added to request")

files = []

Expand Down Expand Up @@ -271,4 +277,4 @@ def check_execution_status(self, status_check_api_endpoint: str) -> dict:
):
obj_to_return["pending"] = True

return obj_to_return
return obj_to_return