From 83f7f6e65cd24d9889ec239aac5c6f3f9b550363 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 31 Mar 2026 15:05:03 +0800 Subject: [PATCH] bugfix --- ahserver/error.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/ahserver/error.py b/ahserver/error.py index 03c6eda..a23ea50 100644 --- a/ahserver/error.py +++ b/ahserver/error.py @@ -39,3 +39,46 @@ def return_ok(data): 'data': data } +def openai_401(): + d = { + "error": { + "message": "Incorrect API key provided: sk-abc...xyz. You can find your API key at https://platform.openai.com/account/api-keys.", + "type": "invalid_request_error", + "param": null, + "code": "invalid_api_key" + } + } + return json_response(d, status=401) + +def openai_403(): + d = { + "error": { + "message": "You don't have access to this model.", + "type": "invalid_request_error", + "param": null, + "code": "model_not_found" + } + } + return json_resposne(d, status=403) + +def openai_429(): + d = { + "error": { + "message": "You exceeded your current quota, please check your plan and billing details.", + "type": "insufficient_quota", + "param": null, + "code": "insufficient_quota" + } + } + return json_response(d, status=429) + +def openai_400(): + d = { + "error": { + "message": "Parameters error.", + "type": "invalidparameters", + "param": null, + "code": "invalidparameters" + } + } +