@@ -244,22 +244,22 @@ router.post('/chat', auth, async (req, res) => {
244244 await updateChat ( message . _id as unknown as string ,
245245 response . data . text ,
246246 response . data . id ,
247- response . data . detail . usage as UsageResponse ,
247+ response . data . detail ? .usage as UsageResponse ,
248248 previousResponse )
249249 }
250250 else {
251251 await updateChat ( message . _id as unknown as string ,
252252 response . data . text ,
253253 response . data . id ,
254- response . data . detail . usage as UsageResponse )
254+ response . data . detail ? .usage as UsageResponse )
255255 }
256256
257257 if ( response . data . usage ) {
258258 await insertChatUsage ( req . headers . userId as string ,
259259 roomId ,
260260 message . _id ,
261261 response . data . id ,
262- response . data . detail . usage as UsageResponse )
262+ response . data . detail ? .usage as UsageResponse )
263263 }
264264 }
265265 res . send ( response )
@@ -341,22 +341,22 @@ router.post('/chat-process', [auth, limiter], async (req, res) => {
341341 await updateChat ( message . _id as unknown as string ,
342342 result . data . text ,
343343 result . data . id ,
344- result . data . detail . usage as UsageResponse ,
344+ result . data . detail ? .usage as UsageResponse ,
345345 previousResponse )
346346 }
347347 else {
348348 await updateChat ( message . _id as unknown as string ,
349349 result . data . text ,
350350 result . data . id ,
351- result . data . detail . usage as UsageResponse )
351+ result . data . detail ? .usage as UsageResponse )
352352 }
353353
354- if ( result . data . detail . usage ) {
354+ if ( result . data . detail ? .usage ) {
355355 await insertChatUsage ( req . headers . userId as string ,
356356 roomId ,
357357 message . _id ,
358358 result . data . id ,
359- result . data . detail . usage as UsageResponse )
359+ result . data . detail ? .usage as UsageResponse )
360360 }
361361 }
362362 catch ( error ) {
@@ -575,7 +575,7 @@ router.post('/verifyadmin', async (req, res) => {
575575
576576router . post ( '/setting-base' , rootAuth , async ( req , res ) => {
577577 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
579579
580580 if ( apiKey == null && accessToken == null )
581581 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) => {
585585 thisConfig . apiModel = apiModel
586586 thisConfig . apiBaseUrl = apiBaseUrl
587587 thisConfig . accessToken = accessToken
588+ thisConfig . reverseProxy = reverseProxy
588589 thisConfig . timeoutMs = timeoutMs
589590 thisConfig . socksProxy = socksProxy
590591 thisConfig . socksAuth = socksAuth
0 commit comments