forked from jfilcik/CU-Tools
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcustom-analyzer-with-replace.http
More file actions
312 lines (298 loc) · 9.75 KB
/
custom-analyzer-with-replace.http
File metadata and controls
312 lines (298 loc) · 9.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# ====================================================================
# Custom Analyzer with Allow Replace Flag
# ====================================================================
#
# This file demonstrates creating or replacing a custom analyzer
# using the "allowReplace" query parameter.
#
# API Reference: https://learn.microsoft.com/en-us/rest/api/contentunderstanding/content-analyzers/create-or-replace?view=rest-contentunderstanding-2025-11-01&tabs=HTTP
#
# The allowReplace parameter enables the operation to replace an
# existing analyzer with the same ID, making it safe to update
# analyzer definitions without causing conflicts.
#
# ====================================================================
# Variables - Loaded from .env file in the same directory
@subscriptionKey = {{$dotenv API_KEY}}
@endpoint = {{$dotenv ENDPOINT_URL}}
@apiVersion = 2025-11-01
# ====================================================================
# Example 1: Create Custom Analyzer with allowReplace=true
# ====================================================================
#
# Using allowReplace=true ensures that if an analyzer with this ID
# already exists, it will be replaced with the new definition.
# This is useful for updating analyzer schemas or configurations.
#
# @name createCustomAnalyzerWithReplace
PUT {{endpoint}}/contentunderstanding/analyzers/custom_claims_analyzer?api-version={{apiVersion}}&allowReplace=true
Ocp-Apim-Subscription-Key: {{subscriptionKey}}
Content-Type: application/json
{
"description": "Custom analyzer for insurance claims processing",
"tags": {
"version": "1.0",
"category": "claims"
},
"baseAnalyzerId": "prebuilt-document",
"models": {
"completion": "gpt-4.1",
"embedding": "text-embedding-3-large"
},
"fieldSchema": {
"name": "Insurance Claims Schema",
"description": "Extract key information from insurance claims",
"fields": {
"ClaimNumber": {
"type": "string",
"method": "extract",
"description": "The unique claim reference number"
},
"ClaimDate": {
"type": "date",
"method": "extract",
"description": "The date the claim was filed"
},
"PolicyHolder": {
"type": "string",
"method": "extract",
"description": "Name of the policy holder"
},
"PolicyNumber": {
"type": "string",
"method": "extract",
"description": "The insurance policy number"
},
"LossType": {
"type": "string",
"method": "classify",
"description": "Category of loss",
"enum": ["property", "auto", "health", "liability", "other"]
},
"ClaimAmount": {
"type": "number",
"method": "extract",
"description": "The amount claimed"
},
"ClaimSummary": {
"type": "string",
"method": "generate",
"description": "AI-generated summary of the claim details"
},
"DocumentedExpenses": {
"type": "array",
"method": "extract",
"description": "List of expenses documented in the claim",
"items": {
"type": "object",
"properties": {
"Date": {
"type": "date",
"description": "Date of the expense"
},
"Category": {
"type": "string",
"description": "Category of expense"
},
"Amount": {
"type": "number",
"description": "Amount of the expense"
},
"Description": {
"type": "string",
"description": "Details about the expense"
}
}
}
}
},
"definitions": {}
},
"config": {
"enableOcr": true,
"enableLayout": true,
"enableFormula": false,
"returnDetails": true,
"omitContent": false
}
}
### Get custom analyzer definition
GET {{endpoint}}/contentunderstanding/analyzers/custom_claims_analyzer?api-version={{apiVersion}}
Ocp-Apim-Subscription-Key: {{subscriptionKey}}
### Test the custom analyzer
# @name testCustomAnalyzer
POST {{endpoint}}/contentunderstanding/analyzers/custom_claims_analyzer:analyze?api-version={{apiVersion}}
Content-Type: application/json
Ocp-Apim-Subscription-Key: {{subscriptionKey}}
{
"inputs": [
{
"url": "https://github.com/Azure-Samples/azure-ai-content-understanding-python/raw/refs/heads/main/data/invoice.pdf"
}
]
}
### Get analysis results
GET {{endpoint}}/contentunderstanding/analyzerResults/{{testCustomAnalyzer.response.body.id}}?api-version={{apiVersion}}
Ocp-Apim-Subscription-Key: {{subscriptionKey}}
# ====================================================================
# Example 2: Update Existing Analyzer with allowReplace=true
# ====================================================================
#
# This demonstrates updating the custom_claims_analyzer with modified
# field schema. The allowReplace=true parameter allows this PUT request
# to replace the existing analyzer without throwing a conflict error.
#
# Simply modify the fieldSchema below and re-run this request to update
# the analyzer definition.
#
### Update analyzer schema (with allowReplace=true to avoid conflicts)
# @name updateCustomAnalyzer
PUT {{endpoint}}/contentunderstanding/analyzers/custom_claims_analyzer?api-version={{apiVersion}}&allowReplace=true
Ocp-Apim-Subscription-Key: {{subscriptionKey}}
Content-Type: application/json
{
"description": "Updated custom analyzer for insurance claims processing - v2",
"tags": {
"version": "2.0",
"category": "claims",
"lastUpdated": "2025-01-29"
},
"baseAnalyzerId": "prebuilt-document",
"models": {
"completion": "gpt-4.1",
"embedding": "text-embedding-3-large"
},
"fieldSchema": {
"name": "Insurance Claims Schema v2",
"description": "Enhanced schema for insurance claims with additional fields",
"fields": {
"ClaimNumber": {
"type": "string",
"method": "extract",
"description": "The unique claim reference number"
},
"ClaimDate": {
"type": "date",
"method": "extract",
"description": "The date the claim was filed"
},
"PolicyHolder": {
"type": "string",
"method": "extract",
"description": "Name of the policy holder"
},
"PolicyNumber": {
"type": "string",
"method": "extract",
"description": "The insurance policy number"
},
"LossType": {
"type": "string",
"method": "classify",
"description": "Category of loss",
"enum": ["property", "auto", "health", "liability", "other"]
},
"ClaimAmount": {
"type": "number",
"method": "extract",
"description": "The amount claimed"
},
"ClaimStatus": {
"type": "string",
"method": "classify",
"description": "Current status of the claim",
"enum": ["pending", "approved", "denied", "settled"]
},
"AdjusterName": {
"type": "string",
"method": "extract",
"description": "Name of the assigned claims adjuster"
},
"ClaimSummary": {
"type": "string",
"method": "generate",
"description": "AI-generated summary of the claim details"
},
"RiskAssessment": {
"type": "string",
"method": "generate",
"description": "AI-generated risk assessment based on claim details"
},
"DocumentedExpenses": {
"type": "array",
"method": "extract",
"description": "List of expenses documented in the claim",
"items": {
"type": "object",
"properties": {
"Date": {
"type": "date",
"description": "Date of the expense"
},
"Category": {
"type": "string",
"description": "Category of expense"
},
"Amount": {
"type": "number",
"description": "Amount of the expense"
},
"Description": {
"type": "string",
"description": "Details about the expense"
},
"Verified": {
"type": "boolean",
"description": "Whether the expense has been verified"
}
}
}
}
},
"definitions": {}
},
"config": {
"enableOcr": true,
"enableLayout": true,
"enableFormula": false,
"returnDetails": true,
"omitContent": false,
"estimateFieldSourceAndConfidence": true
}
}
# ====================================================================
# Example 3: Create Without allowReplace (will fail if exists)
# ====================================================================
#
# For reference: if you omit the allowReplace parameter or set it to
# false, the request will fail if an analyzer with that ID already exists.
# Use this when you want to ensure you're only creating new analyzers.
#
### Create custom analyzer without allowReplace (strict creation)
# This will return a 201 if successful, or fail with a conflict error
# if the analyzer already exists
# @name createCustomAnalyzerStrict
PUT {{endpoint}}/contentunderstanding/analyzers/custom_new_analyzer?api-version={{apiVersion}}
Ocp-Apim-Subscription-Key: {{subscriptionKey}}
Content-Type: application/json
{
"description": "Custom analyzer without allow replace",
"baseAnalyzerId": "prebuilt-document",
"models": {
"completion": "gpt-4.1"
},
"fieldSchema": {
"name": "Simple Schema",
"fields": {
"Title": {
"type": "string",
"method": "extract",
"description": "Document title"
}
},
"definitions": {}
}
}
# ====================================================================
# END OF FILE
# ====================================================================