Skip to content

Commit

Permalink
Merge pull request Pythagora-io#711 from Pythagora-io/key-expired-mor…
Browse files Browse the repository at this point in the history
…e-info

show more information on key expired error
  • Loading branch information
LeonOstrez authored Mar 11, 2024
2 parents 01c40eb + 3a8e732 commit e1c5a00
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pilot/utils/llm_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,15 @@ def return_result(result_data, lines_printed):

if response.status_code == 401 and 'BricksLLM' in response.text:
print("", type='keyExpired')
raise ApiError("Trial Expired", response=response)
msg = "Trial Expired"
key = os.getenv("OPENAI_API_KEY")
endpoint = os.getenv("OPENAI_ENDPOINT")
if key:
msg += f"\n\n(using key ending in ...{key[-4:]}):"
if endpoint:
msg += f"\n(using endpoint: {endpoint}):"
msg += f"\n\nError details: {response.text}"
raise ApiError(msg, response=response)

if response.status_code != 200:
project.dot_pilot_gpt.log_chat_completion(endpoint, model, req_type, data['messages'], response.text)
Expand Down

0 comments on commit e1c5a00

Please sign in to comment.