Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions backend/api_v2/api_deployment_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def post(
tag_names = serializer.validated_data.get(ApiExecution.TAGS)
llm_profile_id = serializer.validated_data.get(ApiExecution.LLM_PROFILE_ID)
hitl_queue_name = serializer.validated_data.get(ApiExecution.HITL_QUEUE_NAME)
user_data = serializer.validated_data.get(ApiExecution.USER_DATA)

if presigned_urls:
DeploymentHelper.load_presigned_files(presigned_urls, file_objs)
Expand All @@ -85,6 +86,7 @@ def post(
tag_names=tag_names,
llm_profile_id=llm_profile_id,
hitl_queue_name=hitl_queue_name,
user_data=user_data,
request_headers=dict(request.headers),
)
if "error" in response and response["error"]:
Expand Down
1 change: 1 addition & 0 deletions backend/api_v2/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ class ApiExecution:
LLM_PROFILE_ID: str = "llm_profile_id"
HITL_QUEUE_NAME: str = "hitl_queue_name"
PRESIGNED_URLS: str = "presigned_urls"
USER_DATA: str = "user_data"
Comment thread
jaags-dev marked this conversation as resolved.
3 changes: 3 additions & 0 deletions backend/api_v2/deployment_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def execute_workflow(
tag_names: list[str] = [],
llm_profile_id: str | None = None,
hitl_queue_name: str | None = None,
user_data: dict[str, Any] | None = None,
request_headers=None,
Comment thread
jaags-dev marked this conversation as resolved.
) -> ReturnDict:
"""Execute workflow by api.
Expand All @@ -168,6 +169,7 @@ def execute_workflow(
tag_names (list(str)): list of tag names
llm_profile_id (str, optional): LLM profile ID for overriding tool settings
hitl_queue_name (str, optional): Custom queue name for manual review
user_data (dict[str, Any], optional): JSON data for user_data variable replacement in prompts

Returns:
ReturnDict: execution status/ result
Expand Down Expand Up @@ -234,6 +236,7 @@ def execute_workflow(
use_file_history=use_file_history,
llm_profile_id=llm_profile_id,
hitl_queue_name=hitl_queue_name,
user_data=user_data,
)
result.status_api = DeploymentHelper.construct_status_endpoint(
api_endpoint=api.api_endpoint, execution_id=execution_id
Expand Down
13 changes: 13 additions & 0 deletions backend/api_v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ class ExecutionRequestSerializer(TagParamsSerializer):
If not provided, uses API name as document class.
presigned_urls (list): List of presigned URLs to fetch files from.
URLs are validated for HTTPS and S3 endpoint requirements.
user_data (dict, optional): User-provided data for variable replacement in prompts.
Can be accessed in prompts using {{user_data.key}} syntax for dot notation traversal.
"""

MAX_FILES_ALLOWED = 32
Expand All @@ -224,6 +226,7 @@ class ExecutionRequestSerializer(TagParamsSerializer):
presigned_urls = ListField(child=URLField(), required=False)
llm_profile_id = CharField(required=False, allow_null=True, allow_blank=True)
hitl_queue_name = CharField(required=False, allow_null=True, allow_blank=True)
user_data = JSONField(required=False, allow_null=True)

def validate_hitl_queue_name(self, value: str | None) -> str | None:
"""Validate queue name format using enterprise validation if available."""
Expand All @@ -244,6 +247,16 @@ def validate_hitl_queue_name(self, value: str | None) -> str | None:
)
return value

def validate_user_data(self, value):
"""Validate user_data is a valid JSON object."""
if value is None:
return value

if not isinstance(value, dict):
raise ValidationError("user_data must be a JSON object")

return value

files = ListField(
child=FileField(),
required=False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ def get_tool_by_prompt_registry_id(
# Suppress all exceptions to allow processing
except Exception as e:
logger.warning(
"Error while fetching for prompt registry "
f"ID {prompt_registry_id}: {e} "
f"Error while fetching for prompt registry ID {prompt_registry_id}: {e} "
)
return None
return Tool(
Expand Down Expand Up @@ -215,8 +214,7 @@ def update_or_create_psr_tool(
return obj
except IntegrityError as error:
logger.error(
"Integrity Error - Error occurred while "
f"exporting custom tool : {error}"
f"Integrity Error - Error occurred while exporting custom tool : {error}"
)
raise ToolSaveError

Expand Down
2 changes: 1 addition & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies = [
"social-auth-core==4.4.2", # For OAuth
# TODO: Temporarily removing the extra dependencies of aws and gcs from unstract-sdk
# to resolve lock file. Will have to be re-looked into
"unstract-sdk[azure]~=0.77.1",
"unstract-sdk[azure]~=0.77.2",
"gcsfs==2024.10.0",
"s3fs==2024.10.0",
"azure-identity==1.16.0",
Expand Down
4 changes: 2 additions & 2 deletions backend/sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ PROMPT_STUDIO_FILE_PATH=/app/prompt-studio-data

# Structure Tool Image (Runs prompt studio exported tools)
# https://hub.docker.com/r/unstract/tool-structure
STRUCTURE_TOOL_IMAGE_URL="docker:unstract/tool-structure:0.0.86"
STRUCTURE_TOOL_IMAGE_URL="docker:unstract/tool-structure:0.0.87"
STRUCTURE_TOOL_IMAGE_NAME="unstract/tool-structure"
STRUCTURE_TOOL_IMAGE_TAG="0.0.86"
STRUCTURE_TOOL_IMAGE_TAG="0.0.87"

# Feature Flags
EVALUATION_SERVER_IP=unstract-flipt
Expand Down
3 changes: 1 addition & 2 deletions backend/tool_instance_v2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ def create(self, request: Any) -> Response:
self.perform_create(serializer)
except IntegrityError:
raise DuplicateData(
f"{ToolInstanceErrors.TOOL_EXISTS}, "
f"{ToolInstanceErrors.DUPLICATE_API}"
f"{ToolInstanceErrors.TOOL_EXISTS}, {ToolInstanceErrors.DUPLICATE_API}"
)
instance: ToolInstance = serializer.instance
ToolInstanceHelper.update_metadata_with_default_values(
Expand Down
Loading