Skip to content

Commit c59b5c3

Browse files
authored
[FIX] - FIxed Validation Issue with Deployment Name for Azure OpenAI LLM (#1691)
* added proper validation for azure openai llm * updated tool versions
1 parent 2b14032 commit c59b5c3

File tree

5 files changed

+31
-15
lines changed

5 files changed

+31
-15
lines changed

tools/classifier/src/config/properties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"schemaVersion": "0.0.1",
33
"displayName": "File Classifier",
44
"functionName": "classify",
5-
"toolVersion": "0.0.72",
5+
"toolVersion": "0.0.73",
66
"description": "Classifies a file into a bin based on its contents",
77
"input": {
88
"description": "File to be classified"

tools/structure/src/config/properties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"schemaVersion": "0.0.1",
33
"displayName": "Structure Tool",
44
"functionName": "structure_tool",
5-
"toolVersion": "0.0.92",
5+
"toolVersion": "0.0.93",
66
"description": "This is a template tool which can answer set of input prompts designed in the Prompt Studio",
77
"input": {
88
"description": "File that needs to be indexed and parsed for answers"

tools/text_extractor/src/config/properties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"schemaVersion": "0.0.1",
33
"displayName": "Text Extractor",
44
"functionName": "text_extractor",
5-
"toolVersion": "0.0.68",
5+
"toolVersion": "0.0.69",
66
"description": "The Text Extractor is a powerful tool designed to convert documents to its text form or Extract texts from documents",
77
"input": {
88
"description": "Document"

unstract/sdk1/src/unstract/sdk1/adapters/base1.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
if TYPE_CHECKING:
1010
from typing import Any
1111

12-
from pydantic import BaseModel, Field
12+
from pydantic import BaseModel, Field, model_validator
1313
from unstract.sdk1.adapters.constants import Common
1414
from unstract.sdk1.adapters.enums import AdapterTypes
1515

@@ -235,6 +235,17 @@ class AzureOpenAILLMParameters(BaseChatCompletionParameters):
235235
num_retries: int | None = 3
236236
reasoning_effort: str | None = None
237237

238+
@model_validator(mode="before")
239+
@classmethod
240+
def set_model_from_deployment_name(cls, data: dict[str, "Any"]) -> dict[str, "Any"]:
241+
"""Convert deployment_name to model field before validation."""
242+
if "deployment_name" in data:
243+
deployment_name = data.pop("deployment_name")
244+
if not deployment_name.startswith("azure/"):
245+
deployment_name = f"azure/{deployment_name}"
246+
data["model"] = deployment_name
247+
return data
248+
238249
@staticmethod
239250
def validate(adapter_metadata: dict[str, "Any"]) -> dict[str, "Any"]:
240251
adapter_metadata["model"] = AzureOpenAILLMParameters.validate_model(
@@ -289,13 +300,18 @@ def validate(adapter_metadata: dict[str, "Any"]) -> dict[str, "Any"]:
289300

290301
@staticmethod
291302
def validate_model(adapter_metadata: dict[str, "Any"]) -> str:
292-
model = adapter_metadata.get("deployment_name", "")
293-
# Only add azure/ prefix if the model doesn't already have it
294-
del adapter_metadata["deployment_name"]
303+
# deployment_name ALWAYS takes precedence over model
304+
if "deployment_name" in adapter_metadata:
305+
deployment_name = adapter_metadata["deployment_name"]
306+
if deployment_name.startswith("azure/"):
307+
return deployment_name
308+
return f"azure/{deployment_name}"
309+
310+
# Only use model if deployment_name doesn't exist (second validation call)
311+
model = adapter_metadata.get("model", "")
295312
if model.startswith("azure/"):
296313
return model
297-
else:
298-
return f"azure/{model}"
314+
return f"azure/{model}"
299315

300316

301317
class VertexAILLMParameters(BaseChatCompletionParameters):

unstract/tool-registry/tool_registry_config/public_tools.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"schemaVersion": "0.0.1",
66
"displayName": "File Classifier",
77
"functionName": "classify",
8-
"toolVersion": "0.0.72",
8+
"toolVersion": "0.0.73",
99
"description": "Classifies a file into a bin based on its contents",
1010
"input": {
1111
"description": "File to be classified"
@@ -106,17 +106,17 @@
106106
"properties": {}
107107
},
108108
"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",
109-
"image_url": "docker:unstract/tool-classifier:0.0.72",
109+
"image_url": "docker:unstract/tool-classifier:0.0.73",
110110
"image_name": "unstract/tool-classifier",
111-
"image_tag": "0.0.72"
111+
"image_tag": "0.0.73"
112112
},
113113
"text_extractor": {
114114
"tool_uid": "text_extractor",
115115
"properties": {
116116
"schemaVersion": "0.0.1",
117117
"displayName": "Text Extractor",
118118
"functionName": "text_extractor",
119-
"toolVersion": "0.0.68",
119+
"toolVersion": "0.0.69",
120120
"description": "The Text Extractor is a powerful tool designed to convert documents to its text form or Extract texts from documents",
121121
"input": {
122122
"description": "Document"
@@ -191,8 +191,8 @@
191191
}
192192
},
193193
"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",
194-
"image_url": "docker:unstract/tool-text-extractor:0.0.68",
194+
"image_url": "docker:unstract/tool-text-extractor:0.0.69",
195195
"image_name": "unstract/tool-text-extractor",
196-
"image_tag": "0.0.68"
196+
"image_tag": "0.0.69"
197197
}
198198
}

0 commit comments

Comments
 (0)