Skip to content

Commit

Permalink
Feat/mrq filter by low confidence (#850)
Browse files Browse the repository at this point in the history
* added place holder utils for mrq db rules functionality and frontend changes

* added urls and view to get prompt tools details

* renamed db rules function to avoid confusion

* Update frontend/src/components/agency/configure-connector-modal/ConfigureConnectorModal.jsx

Co-authored-by: jagadeeswaran-zipstack <[email protected]>
Signed-off-by: vishnuszipstack <[email protected]>

* Pr comment fixes

* added enum

* added constants

---------

Signed-off-by: vishnuszipstack <[email protected]>
Co-authored-by: jagadeeswaran-zipstack <[email protected]>
  • Loading branch information
vishnuszipstack and jagadeeswaran-zipstack authored Dec 17, 2024
1 parent 3c491e5 commit 8a01ca2
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 8 deletions.
14 changes: 13 additions & 1 deletion backend/prompt_studio/prompt_studio_registry_v2/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
from django.urls import path
from rest_framework.urlpatterns import format_suffix_patterns

urlpatterns = format_suffix_patterns([])
from .views import PromptStudioRegistryView

urlpatterns = [
path(
"registry/",
PromptStudioRegistryView.as_view({"get": "list"}),
name="prompt_studio_registry_list",
),
]

# Optional: Apply format suffix patterns
urlpatterns = format_suffix_patterns(urlpatterns)
8 changes: 5 additions & 3 deletions backend/workflow_manager/endpoint_v2/destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from workflow_manager.workflow_v2.file_history_helper import FileHistoryHelper
from workflow_manager.workflow_v2.models.file_history import FileHistory
from workflow_manager.workflow_v2.models.workflow import Workflow
from workflow_manager.workflow_v2.utils import WorkflowUtil

from backend.constants import FeatureFlag
from backend.exceptions import UnstractFSException
Expand Down Expand Up @@ -183,9 +184,9 @@ def handle_output(
if connection_type == WorkflowEndpoint.ConnectionType.FILESYSTEM:
self.copy_output_to_output_directory()
elif connection_type == WorkflowEndpoint.ConnectionType.DATABASE:
if (
file_hash.file_destination
== WorkflowEndpoint.ConnectionType.MANUALREVIEW
result = self.get_result(file_history)
if WorkflowUtil.validate_db_rule(
result, workflow, file_hash.file_destination
):
self._push_data_to_queue(file_name, workflow, input_file_path)
else:
Expand Down Expand Up @@ -288,6 +289,7 @@ def insert_into_db(self, input_file_path: str) -> None:
# If data is None, don't execute CREATE or INSERT query
if not data:
return

# Remove metadata from result
# Tool text-extractor returns data in the form of string.
# Don't pop out metadata in this case.
Expand Down
5 changes: 5 additions & 0 deletions backend/workflow_manager/workflow_v2/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,8 @@ class WorkflowMessages:
FILE_MARKER_CLEAR_SUCCESS = "File marker cleared successfully."
FILE_MARKER_CLEAR_FAILED = "Failed to clear file marker."
WORKFLOW_EXECUTION_NOT_FOUND = "Workflow execution not found."


class ResultKeys:
METADATA = "metadata"
CONFIDENCE_DATA = "confidence_data"
5 changes: 5 additions & 0 deletions backend/workflow_manager/workflow_v2/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,8 @@ class ColumnModes(Enum):

class AgentName(Enum):
UNSTRACT_DBWRITER = "Unstract/DBWriter"


class RuleLogic(Enum):
AND = "AND"
OR = "OR"
23 changes: 22 additions & 1 deletion backend/workflow_manager/workflow_v2/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any
from typing import Any, Optional

from workflow_manager.endpoint_v2.dto import FileHash
from workflow_manager.workflow_v2.models.workflow import Workflow
Expand Down Expand Up @@ -59,3 +59,24 @@ def add_file_destination_filehash(
destination modified.
"""
return file_hash

@staticmethod
def validate_db_rule(
result: Optional[Any],
workflow_id: Workflow,
file_destination: Optional[tuple[str, str]],
) -> bool:
"""Placeholder method to check the db rules - MRQ
Args:
result (Optional[Any]): The result dictionary containing
confidence_data.
workflow_id (str): The ID of the workflow to retrieve the rules.
file_destination (Optional[tuple[str, str]]): The destination of
the file (e.g., MANUALREVIEW or other).
Returns:
bool: True if the field_key conditions are met based on rule logic
and file destination.
"""
return False
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function ConfigureConnectorModal({
connType,
selectedItemName,
setSelectedItemName,
workflowDetails,
}) {
const [activeKey, setActiveKey] = useState("1");
useEffect(() => {
Expand Down Expand Up @@ -190,8 +191,11 @@ function ConfigureConnectorModal({
{activeKey === "2" && connType === "FILESYSTEM" && (
<ManageFiles selectedItem={connectorId} />
)}
{activeKey === "MANUALREVIEW" && (
<DBRules connDetails={connDetails} />
{activeKey === "MANUALREVIEW" && DBRules && (
<DBRules
connDetails={connDetails}
workflowDetails={workflowDetails}
/>
)}
</Col>
</Row>
Expand All @@ -218,6 +222,7 @@ ConfigureConnectorModal.propTypes = {
connType: PropTypes.string.isRequired,
selectedItemName: PropTypes.string,
setSelectedItemName: PropTypes.func.isRequired,
workflowDetails: PropTypes.object,
};

export { ConfigureConnectorModal };
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const needToRemove = {

function DsSettingsCard({ type, endpointDetails, message }) {
const workflowStore = useWorkflowStore();
const { source, destination, allowChangeEndpoint } = workflowStore;
const { source, destination, allowChangeEndpoint, details } = workflowStore;
const [options, setOptions] = useState({});
const [openModal, setOpenModal] = useState(false);

Expand Down Expand Up @@ -490,6 +490,7 @@ function DsSettingsCard({ type, endpointDetails, message }) {
connType={connType}
selectedItemName={selectedItemName}
setSelectedItemName={setSelectedItemName}
workflowDetails={details}
/>
</>
);
Expand Down

0 comments on commit 8a01ca2

Please sign in to comment.