Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

fix: Enhance classifier prompt to avoid explanation (#511)

Chandrasekharan Mf078293e6aea
diff --git a/backend/adapter_processor/constants.py b/backend/adapter_processor/constants.py
index e35f2d0ac..4c263bd4a 100644
--- a/backend/adapter_processor/constants.py
+++ b/backend/adapter_processor/constants.py
@@ -21,8 +21,8 @@ class AdapterKeys:
X2TEXT_DEFAULT = "x2text_default"
SHARED_USERS = "shared_users"
ADAPTER_NAME_EXISTS = (
- "Configuration with this Name already exists. "
- "Please try with a different Name"
+ "Configuration with this name already exists within your organisation. "
+ "Please try with a different name."
)
ADAPTER_CREATED_BY = "created_by_email"
ADAPTER_CONTEXT_WINDOW_SIZE = "context_window_size"
diff --git a/backend/adapter_processor_v2/constants.py b/backend/adapter_processor_v2/constants.py
index e35f2d0ac..91d555c77 100644
--- a/backend/adapter_processor_v2/constants.py
+++ b/backend/adapter_processor_v2/constants.py
@@ -21,8 +21,8 @@ class AdapterKeys:
X2TEXT_DEFAULT = "x2text_default"
SHARED_USERS = "shared_users"
ADAPTER_NAME_EXISTS = (
- "Configuration with this Name already exists. "
- "Please try with a different Name"
+ "Configuration with this name already exists within your organisation. "
+ "Please try with a different name"
)
ADAPTER_CREATED_BY = "created_by_email"
ADAPTER_CONTEXT_WINDOW_SIZE = "context_window_size"
diff --git a/tools/classifier/sample.env b/tools/classifier/sample.env
index 86107f7a6..677efa2dc 100644
--- a/tools/classifier/sample.env
+++ b/tools/classifier/sample.env
@@ -1,11 +1,7 @@
-PLATFORM_SERVICE_HOST=
-PLATFORM_SERVICE_PORT=
-PLATFORM_SERVICE_API_KEY=
-TOOL_DATA_DIR=
+PLATFORM_SERVICE_HOST=http://unstract-platform-service
+PLATFORM_SERVICE_PORT=3001
+PLATFORM_SERVICE_API_KEY=<add_platform_key_from_Unstract_frontend>
+TOOL_DATA_DIR=../data_dir
-# Azure OpenAI
-OPENAI_API_KEY=
-OPENAI_API_BASE=
-OPENAI_API_VERSION=
-OPENAI_API_ENGINE=
-OPENAI_API_MODEL=
+X2TEXT_HOST=http://unstract-x2text-service
+X2TEXT_PORT=3004
diff --git a/tools/classifier/src/config/properties.json b/tools/classifier/src/config/properties.json
index b095314dd..c86c089d9 100644
--- a/tools/classifier/src/config/properties.json
+++ b/tools/classifier/src/config/properties.json
@@ -2,7 +2,7 @@
"schemaVersion": "0.0.1",
"displayName": "File Classifier",
"functionName": "classify",
- "toolVersion": "0.0.26",
+ "toolVersion": "0.0.27",
"description": "Classifies a file into a bin based on its contents",
"input": {
"description": "File to be classified"
diff --git a/tools/classifier/src/main.py b/tools/classifier/src/main.py
index c1dfb9453..e22f88ef1 100644
--- a/tools/classifier/src/main.py
+++ b/tools/classifier/src/main.py
@@ -27,7 +27,9 @@ class UnstractClassifier(BaseTool):
if not llm_adapter_instance_id:
self.stream_error_and_exit("Choose an LLM to process the classifier")
if not text_extraction_adapter_id:
- self.stream_error_and_exit("Choose an LLM to extract the documents")
+ self.stream_error_and_exit(
+ "Choose a text extractor to extract the documents"
+ )
def run(
self,
@@ -99,9 +101,10 @@ class UnstractClassifier(BaseTool):
prompt = (
f"Classify the following text into one of the following categories: {' '.join(bins_with_quotes)}.\n\n" # noqa: E501
- f"Your categorization should be strictly exactly one of the items in the " # noqa: E501
- f"categories given. Find a semantic match of category if possible. If it does not categorize well " # noqa: E501
- f"into any of the listed categories, categorize it as 'unknown'.\n\nText:\n\n{text}\n\n\nCategory:" # noqa: E501
+ "Your categorization should be strictly exactly one of the items in the " # noqa: E501
+ "categories given, do not provide any explanation. Find a semantic match of category if possible. " # noqa: E501
+ "If it does not categorize well into any of the listed categories, categorize it as 'unknown'.\n\n" # noqa: E501
+ f"Text:\n\n{text}\n\n\nCategory:"
)
settings_string = "".join(str(value) for value in settings.values())
diff --git a/unstract/tool-registry/src/unstract/tool_registry/public_tools.json b/unstract/tool-registry/src/unstract/tool_registry/public_tools.json
index c74e8e471..729679652 100644
--- a/unstract/tool-registry/src/unstract/tool_registry/public_tools.json
+++ b/unstract/tool-registry/src/unstract/tool_registry/public_tools.json
@@ -5,7 +5,7 @@
"schemaVersion": "0.0.1",
"displayName": "File Classifier",
"functionName": "classify",
- "toolVersion": "0.0.26",
+ "toolVersion": "0.0.27",
"description": "Classifies a file into a bin based on its contents",
"input": {
"description": "File to be classified"
@@ -139,9 +139,9 @@
}
},
"icon": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg\n enable-background=\"new 0 0 20 20\"\n height=\"48\"\n viewBox=\"0 0 20 20\"\n width=\"48\"\n fill=\"#000000\"\n version=\"1.1\"\n id=\"svg8109\"\n sodipodi:docname=\"folder_copy_black_48dp.svg\"\n xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"\n xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:svg=\"http://www.w3.org/2000/svg\">\n <defs\n id=\"defs8113\" />\n <sodipodi:namedview\n id=\"namedview8111\"\n pagecolor=\"#ffffff\"\n bordercolor=\"#000000\"\n borderopacity=\"0.25\"\n inkscape:showpageshadow=\"2\"\n inkscape:pageopacity=\"0.0\"\n inkscape:pagecheckerboard=\"0\"\n inkscape:deskcolor=\"#d1d1d1\"\n showgrid=\"false\" />\n <g\n id=\"g8099\">\n <rect\n fill=\"none\"\n height=\"20\"\n width=\"20\"\n x=\"0\"\n id=\"rect8097\"\n y=\"0\" />\n </g>\n <g\n id=\"g8107\"\n style=\"fill:#ff4d6d;fill-opacity:1\">\n <g\n id=\"g8105\"\n style=\"fill:#ff4d6d;fill-opacity:1\">\n <path\n d=\"M 2.5,5 H 1 V 15.5 C 1,16.33 1.67,17 2.5,17 H 15.68 V 15.5 H 2.5 Z\"\n id=\"path8101\"\n style=\"fill:#ff4d6d;fill-opacity:1\" />\n <path\n d=\"M 16.5,4 H 11 L 9,2 H 5.5 C 4.67,2 4,2.67 4,3.5 v 9 C 4,13.33 4.67,14 5.5,14 h 11 c 0.83,0 1.5,-0.67 1.5,-1.5 v -7 C 18,4.67 17.33,4 16.5,4 Z m 0,8.5 h -11 v -9 h 2.88 l 2,2 h 6.12 z\"\n id=\"path8103\"\n style=\"fill:#ff4d6d;fill-opacity:1\" />\n </g>\n </g>\n</svg>\n",
- "image_url": "docker:unstract/tool-classifier:0.0.26",
+ "image_url": "docker:unstract/tool-classifier:0.0.27",
"image_name": "unstract/tool-classifier",
- "image_tag": "0.0.26"
+ "image_tag": "0.0.27"
},
"text_extractor": {
"tool_uid": "text_extractor",