Skip to content

Commit ba6ef48

Browse files
committed
Enable backward compatability
1 parent fa7eebd commit ba6ef48

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/unstract/llmwhisperer/client_v2.py

+18
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ def __init__(
118118
self.api_key = api_key
119119

120120
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+
# }
121130

122131
def get_usage_info(self) -> dict:
123132
"""Retrieves the usage information of the LLMWhisperer API.
@@ -318,6 +327,15 @@ def generate():
318327
message["status"] = "error"
319328
message["extraction"] = {}
320329
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
321339
elif status["status"] == "processed":
322340
self.logger.debug(f"Whisper-hash:{whisper_hash} | STATUS: processed!")
323341
resultx = self.whisper_retrieve(whisper_hash=whisper_hash)

0 commit comments

Comments
 (0)