@@ -12,6 +12,49 @@ var ChatGPTModels = [
12
12
13
13
var SYSTEM_PROMPT = "You are a translation engine that can only translate text and cannot interpret it."
14
14
15
+ var HttpErrorCodes = {
16
+ "400" : "Bad Request" ,
17
+ "401" : "Unauthorized" ,
18
+ "402" : "Payment Required" ,
19
+ "403" : "Forbidden" ,
20
+ "404" : "Not Found" ,
21
+ "405" : "Method Not Allowed" ,
22
+ "406" : "Not Acceptable" ,
23
+ "407" : "Proxy Authentication Required" ,
24
+ "408" : "Request Timeout" ,
25
+ "409" : "Conflict" ,
26
+ "410" : "Gone" ,
27
+ "411" : "Length Required" ,
28
+ "412" : "Precondition Failed" ,
29
+ "413" : "Payload Too Large" ,
30
+ "414" : "URI Too Long" ,
31
+ "415" : "Unsupported Media Type" ,
32
+ "416" : "Range Not Satisfiable" ,
33
+ "417" : "Expectation Failed" ,
34
+ "418" : "I'm a teapot" ,
35
+ "421" : "Misdirected Request" ,
36
+ "422" : "Unprocessable Entity" ,
37
+ "423" : "Locked" ,
38
+ "424" : "Failed Dependency" ,
39
+ "425" : "Too Early" ,
40
+ "426" : "Upgrade Required" ,
41
+ "428" : "Precondition Required" ,
42
+ "429" : "Too Many Requests" ,
43
+ "431" : "Request Header Fields Too Large" ,
44
+ "451" : "Unavailable For Legal Reasons" ,
45
+ "500" : "Internal Server Error" ,
46
+ "501" : "Not Implemented" ,
47
+ "502" : "Bad Gateway" ,
48
+ "503" : "Service Unavailable" ,
49
+ "504" : "Gateway Timeout" ,
50
+ "505" : "HTTP Version Not Supported" ,
51
+ "506" : "Variant Also Negotiates" ,
52
+ "507" : "Insufficient Storage" ,
53
+ "508" : "Loop Detected" ,
54
+ "510" : "Not Extended" ,
55
+ "511" : "Network Authentication Required"
56
+ }
57
+
15
58
/**
16
59
* @param {string } url
17
60
* @returns {string }
@@ -158,7 +201,6 @@ function buildRequestBody(model, isChatGPTModel, query) {
158
201
} ;
159
202
}
160
203
161
-
162
204
/**
163
205
* @param {Bob.TranslateQuery } query
164
206
* @param {Bob.HttpResponse } result
@@ -170,13 +212,12 @@ function handleError(query, result) {
170
212
query . onCompletion ( {
171
213
error : {
172
214
type : reason ,
173
- message : `接口响应错误 - ${ result . data . error . message } ` ,
174
- addtion : `${ statusCode } : ${ JSON . stringify ( result ) } ` ,
215
+ message : `接口响应错误 - ${ HttpErrorCodes [ statusCode ] } ` ,
216
+ addtion : `${ JSON . stringify ( result ) } ` ,
175
217
} ,
176
218
} ) ;
177
219
}
178
220
179
-
180
221
/**
181
222
* @param {Bob.TranslateQuery } query
182
223
* @param {boolean } isChatGPTModel
0 commit comments