@@ -118,6 +118,15 @@ def __init__(
118
118
self .api_key = api_key
119
119
120
120
self .headers = {"unstract-key" : self .api_key }
121
+ # For test purpose
122
+ # self.headers = {
123
+ # "Subscription-Id": "python-client",
124
+ # "Subscription-Name": "python-client",
125
+ # "User-Id": "python-client-user",
126
+ # "Product-Id": "python-client-product",
127
+ # "Product-Name": "python-client-product",
128
+ # "Start-Date": "2024-07-09",
129
+ # }
121
130
122
131
def get_usage_info (self ) -> dict :
123
132
"""Retrieves the usage information of the LLMWhisperer API.
@@ -318,6 +327,15 @@ def generate():
318
327
message ["status" ] = "error"
319
328
message ["extraction" ] = {}
320
329
return message
330
+ elif "error" in status ["status" ]:
331
+ # for backward compatabity
332
+ self .logger .debug (f"Whisper-hash:{ whisper_hash } | STATUS: failed..." )
333
+ self .logger .error (f'Whisper-hash:{ whisper_hash } | STATUS: failed with { status ["status" ]} ' )
334
+ message ["status_code" ] = - 1
335
+ message ["message" ] = status ["status" ]
336
+ message ["status" ] = "error"
337
+ message ["extraction" ] = {}
338
+ return message
321
339
elif status ["status" ] == "processed" :
322
340
self .logger .debug (f"Whisper-hash:{ whisper_hash } | STATUS: processed!" )
323
341
resultx = self .whisper_retrieve (whisper_hash = whisper_hash )
0 commit comments