From ab6f6ea02d7c353b909a2458b5d3d0473d57991a Mon Sep 17 00:00:00 2001 From: vishnuszipstack Date: Mon, 9 Dec 2024 09:48:41 +0530 Subject: [PATCH 1/2] added constant and helper update in promptservice --- .../src/unstract/prompt_service/constants.py | 1 + .../src/unstract/prompt_service/helper.py | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/prompt-service/src/unstract/prompt_service/constants.py b/prompt-service/src/unstract/prompt_service/constants.py index e905eec1e..a654ce5c2 100644 --- a/prompt-service/src/unstract/prompt_service/constants.py +++ b/prompt-service/src/unstract/prompt_service/constants.py @@ -71,6 +71,7 @@ class PromptServiceContants: ENABLE_HIGHLIGHT = "enable_highlight" FILE_PATH = "file_path" HIGHLIGHT_DATA = "highlight_data" + CONFIDENCE_DATA = "confidence_data" class RunLevel(Enum): diff --git a/prompt-service/src/unstract/prompt_service/helper.py b/prompt-service/src/unstract/prompt_service/helper.py index cf4ef63cb..62a24f2d1 100644 --- a/prompt-service/src/unstract/prompt_service/helper.py +++ b/prompt-service/src/unstract/prompt_service/helper.py @@ -296,8 +296,19 @@ def run_completion( ) answer: str = completion[PSKeys.RESPONSE].text highlight_data = completion.get(PSKeys.HIGHLIGHT_DATA) - if all([metadata, highlight_data, prompt_key]): - metadata.setdefault(PSKeys.HIGHLIGHT_DATA, {})[prompt_key] = highlight_data + confidence_data = completion.get(PSKeys.CONFIDENCE_DATA) + + if metadata is not None and prompt_key: + if highlight_data: + metadata.setdefault(PSKeys.HIGHLIGHT_DATA, {})[ + prompt_key + ] = highlight_data + + if confidence_data: + metadata.setdefault(PSKeys.CONFIDENCE_DATA, {})[ + prompt_key + ] = confidence_data + return answer # TODO: Catch and handle specific exception here except SdkRateLimitError as e: From 3568aff79459347703e24603cd8b4aedbaf22096 Mon Sep 17 00:00:00 2001 From: vishnuszipstack Date: Mon, 9 Dec 2024 09:49:14 +0530 Subject: [PATCH 2/2] removed unused epilogue --- tools/structure/src/main.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/tools/structure/src/main.py b/tools/structure/src/main.py index 9d93e3b5e..49871c35c 100644 --- a/tools/structure/src/main.py +++ b/tools/structure/src/main.py @@ -236,21 +236,6 @@ def run( if not summarize_as_source: metadata = structured_output_dict[SettingsKeys.METADATA] - epilogue = metadata.pop(SettingsKeys.EPILOGUE, None) - if epilogue: - try: - from helper import ( # type: ignore [attr-defined] - get_confidence_data, - ) - - metadata[SettingsKeys.CONFIDENCE_DATA] = get_confidence_data( - epilogue, tool_data_dir - ) - except ImportError: - self.stream_log( - f"Confidence data is not added. {PAID_FEATURE_MSG}", - level=LogLevel.WARN, - ) # Update the dictionary with modified metadata structured_output_dict[SettingsKeys.METADATA] = metadata structured_output = json.dumps(structured_output_dict)