@@ -244,22 +244,22 @@ router.post('/chat', auth, async (req, res) => {
244
244
await updateChat ( message . _id as unknown as string ,
245
245
response . data . text ,
246
246
response . data . id ,
247
- response . data . detail . usage as UsageResponse ,
247
+ response . data . detail ? .usage as UsageResponse ,
248
248
previousResponse )
249
249
}
250
250
else {
251
251
await updateChat ( message . _id as unknown as string ,
252
252
response . data . text ,
253
253
response . data . id ,
254
- response . data . detail . usage as UsageResponse )
254
+ response . data . detail ? .usage as UsageResponse )
255
255
}
256
256
257
257
if ( response . data . usage ) {
258
258
await insertChatUsage ( req . headers . userId as string ,
259
259
roomId ,
260
260
message . _id ,
261
261
response . data . id ,
262
- response . data . detail . usage as UsageResponse )
262
+ response . data . detail ? .usage as UsageResponse )
263
263
}
264
264
}
265
265
res . send ( response )
@@ -341,22 +341,22 @@ router.post('/chat-process', [auth, limiter], async (req, res) => {
341
341
await updateChat ( message . _id as unknown as string ,
342
342
result . data . text ,
343
343
result . data . id ,
344
- result . data . detail . usage as UsageResponse ,
344
+ result . data . detail ? .usage as UsageResponse ,
345
345
previousResponse )
346
346
}
347
347
else {
348
348
await updateChat ( message . _id as unknown as string ,
349
349
result . data . text ,
350
350
result . data . id ,
351
- result . data . detail . usage as UsageResponse )
351
+ result . data . detail ? .usage as UsageResponse )
352
352
}
353
353
354
- if ( result . data . detail . usage ) {
354
+ if ( result . data . detail ? .usage ) {
355
355
await insertChatUsage ( req . headers . userId as string ,
356
356
roomId ,
357
357
message . _id ,
358
358
result . data . id ,
359
- result . data . detail . usage as UsageResponse )
359
+ result . data . detail ? .usage as UsageResponse )
360
360
}
361
361
}
362
362
catch ( error ) {
@@ -575,7 +575,7 @@ router.post('/verifyadmin', async (req, res) => {
575
575
576
576
router . post ( '/setting-base' , rootAuth , async ( req , res ) => {
577
577
try {
578
- const { apiKey, apiModel, apiBaseUrl, accessToken, timeoutMs, socksProxy, socksAuth, httpsProxy } = req . body as Config
578
+ const { apiKey, apiModel, apiBaseUrl, accessToken, timeoutMs, reverseProxy , socksProxy, socksAuth, httpsProxy } = req . body as Config
579
579
580
580
if ( apiKey == null && accessToken == null )
581
581
throw new Error ( 'Missing OPENAI_API_KEY or OPENAI_ACCESS_TOKEN environment variable.' )
@@ -585,6 +585,7 @@ router.post('/setting-base', rootAuth, async (req, res) => {
585
585
thisConfig . apiModel = apiModel
586
586
thisConfig . apiBaseUrl = apiBaseUrl
587
587
thisConfig . accessToken = accessToken
588
+ thisConfig . reverseProxy = reverseProxy
588
589
thisConfig . timeoutMs = timeoutMs
589
590
thisConfig . socksProxy = socksProxy
590
591
thisConfig . socksAuth = socksAuth
0 commit comments