Form Recognizer V2/成本呈爆炸式增长



作为对ChadZ的回应,这里是表单识别器的度量,我正在谈论表单识别器度量。在我们的测试中,我们检查目录中的文件,并按顺序分析它们,等待每个响应,写入结果,获取下一个文件等等。没有多线程。

看看4月14日的最大峰值,有15330个电话。如果我们假设4月14日的每次通话需要10秒(这很快,正常情况下可能需要一分钟(,那么分析需要153300秒,即2555分钟或42.58小时。即使分析只需要5秒,也将超过20个小时。

当然,我可能错了,但目前最好的逻辑解释是,也会跟踪get请求;账单。

原始帖子

我使用了一个带有标签的自定义模型(使用示例标签工具创建(,并使用本页底部的"Python Form Recognizer Async Analyze"V2 SDK代码获得结果。虽然V2中的异步比V1慢得多(我在这里描述过(,但它似乎也要昂贵得多。

在后api调用后获得结果的原始示例代码如下所示:

n_tries = 15
n_try = 0
wait_sec = 5
max_wait_sec = 60
while n_try < n_tries:
try:
resp = get(url = get_url, headers = {"Ocp-Apim-Subscription-Key": apim_key})
resp_json = resp.json()
if resp.status_code != 200:
print("GET analyze results failed:n%s" % json.dumps(resp_json))
quit()
status = resp_json["status"]
if status == "succeeded":
print("Analysis succeeded:n%s" % json.dumps(resp_json))
quit()
if status == "failed":
print("Analysis failed:n%s" % json.dumps(resp_json))
quit()
# Analysis still running. Wait and retry.
time.sleep(wait_sec)
n_try += 1
wait_sec = min(2*wait_sec, max_wait_sec)     
except Exception as e:
msg = "GET analyze results failed:n%s" % str(e)
print(msg)
quit()
print("Analyze operation did not complete within the allocated time.")

正如您在原始示例代码中看到的那样,它每5秒钟查找一次以获得结果。

我的问题:在我看来,不仅分析文档的api调用会被计费,而且每个获取结果的请求都会被计费。

自从使用V2以来,我们的账单增加了十倍甚至更多。我们目前处于测试阶段,通常每月大约有400-500份文档,这些文档在V1中得到了正确的跟踪和计费。有了V2和上面的示例代码,我们现在有63690个(!!!!(呼叫,每个呼叫都有账单,成本正在爆炸式增长。

有人能证实这种行为吗?

就我个人而言,我想返回同步操作,其中api调用的响应还包含任何文档分析的结果。

try:
url = base_url + "/models/" + model_id + "/analyze"
with open(filepath, "rb") as f:
data_bytes = f.read()
response = requests.post(url=url, data=data_bytes, headers=headers)
return response.json()
except Exception as e:
print(str(e))
return None

不幸的是,这已经不起作用了。。。。。

try:
response = requests.post(url=post_url, data=data_bytes, headers=headers)  # , params=params)
if response.status_code != 202:
return None
# Success
get_url = response.headers["operation-location"]
return form_recognizerv2_getdata(get_url, subscription_key)
except Exception as e:
print("POST analyze failed:n%s" % str(e))
return None

GetAnalyzeResults调用不计费。Form Recognizer仅针对分析的页面计费,不按交易和请求计费。图形"Form Recognizer Metrics"显示了您的所有事务和API调用,包括GetAnalyzeResults,但您不会为此付费。V1和V2的计费相同。如果您遇到账单问题,请联系客服。

Neta MSFT

我可以确认,在Form Recognizer v2中,GET调用不会计费。火车呼叫也是免费的。如果有账单问题,请联系客服。

最新更新