diff --git a/pilot/const/ipc.py b/pilot/const/ipc.py index edcd9f054d..a8d3592d64 100644 --- a/pilot/const/ipc.py +++ b/pilot/const/ipc.py @@ -16,6 +16,7 @@ MESSAGE_TYPE = { 'loopTrigger': 'loopTrigger', # Trigger loop feedback popup in extension 'progress': 'progress', # Progress bar for extension only 'projectStats': 'projectStats', # Project stats for extension only + 'keyExpired': 'keyExpired', # (Free trial) key expired message - for extension only } LOCAL_IGNORE_MESSAGE_TYPES = [ @@ -31,4 +32,5 @@ LOCAL_IGNORE_MESSAGE_TYPES = [ 'loopTrigger', 'progress', 'projectStats', + 'keyExpired', ] \ No newline at end of file diff --git a/pilot/utils/llm_connection.py b/pilot/utils/llm_connection.py index 15b30487c5..0e93a0efc7 100644 --- a/pilot/utils/llm_connection.py +++ b/pilot/utils/llm_connection.py @@ -440,6 +440,10 @@ def stream_gpt_completion(data, req_type, project): timeout=(API_CONNECT_TIMEOUT, API_READ_TIMEOUT), ) + if response.status_code == 401 and 'BricksLLM' in response.text: + print("", type='keyExpired') + raise ApiError(f"Trial Expired", response=response) + if response.status_code != 200: project.dot_pilot_gpt.log_chat_completion(endpoint, model, req_type, data['messages'], response.text) logger.info(f'problem with request (status {response.status_code}): {response.text}')