@@ -3,7 +3,7 @@ import jwt from 'jsonwebtoken'
33import * as dotenv from 'dotenv'
44import { ObjectId } from 'mongodb'
55import type { RequestProps } from './types'
6- import type { ChatContext , ChatMessage } from './chatgpt'
6+ import type { ChatMessage } from './chatgpt'
77import { abortChatProcess , chatConfig , chatReplyProcess , containsSensitiveWords , initAuditService } from './chatgpt'
88import { auth , getUserId } from './middleware/auth'
99import { clearApiKeyCache , clearConfigCache , getApiKeys , getCacheApiKeys , getCacheConfig , getOriginConfig } from './storage/config'
@@ -335,46 +335,6 @@ router.post('/chat-clear', auth, async (req, res) => {
335335 }
336336} )
337337
338- router . post ( '/chat' , auth , async ( req , res ) => {
339- try {
340- const { roomId, uuid, regenerate, prompt, options = { } } = req . body as
341- { roomId : number ; uuid : number ; regenerate : boolean ; prompt : string ; options ?: ChatContext }
342- const message = regenerate
343- ? await getChat ( roomId , uuid )
344- : await insertChat ( uuid , prompt , roomId , options as ChatOptions )
345- const response = await chatReply ( prompt , options )
346- if ( response . status === 'Success' ) {
347- if ( regenerate && message . options . messageId ) {
348- const previousResponse = message . previousResponse || [ ]
349- previousResponse . push ( { response : message . response , options : message . options } )
350- await updateChat ( message . _id as unknown as string ,
351- response . data . text ,
352- response . data . id ,
353- response . data . detail ?. usage as UsageResponse ,
354- previousResponse as [ ] )
355- }
356- else {
357- await updateChat ( message . _id as unknown as string ,
358- response . data . text ,
359- response . data . id ,
360- response . data . detail ?. usage as UsageResponse )
361- }
362-
363- if ( response . data . usage ) {
364- await insertChatUsage ( new ObjectId ( req . headers . userId as string ) ,
365- roomId ,
366- message . _id ,
367- response . data . id ,
368- response . data . detail ?. usage as UsageResponse )
369- }
370- }
371- res . send ( response )
372- }
373- catch ( error ) {
374- res . send ( error )
375- }
376- } )
377-
378338router . post ( '/chat-process' , [ auth , limiter ] , async ( req , res ) => {
379339 res . setHeader ( 'Content-type' , 'application/octet-stream' )
380340
0 commit comments