File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ import { ragflow } from '../services/ragflowService.js' ;
2+
3+ export async function chatController ( req , res ) {
4+ try {
5+ const { sessionId, prompt } = req . body ;
6+
7+ if ( ! sessionId || ! prompt ) {
8+ return res . status ( 400 ) . json ( { error : "Missing sessionId or prompt" } ) ;
9+ }
10+
11+ console . log ( `Processing chat for session: ${ sessionId } with prompt: ${ prompt } ` ) ;
12+
13+ const response = await ragflow ( sessionId , prompt ) ;
14+
15+ if ( ! response ) {
16+ return res . status ( 500 ) . json ( { error : "Failed to process request with RAGFlow" } ) ;
17+ }
18+
19+ return res . json ( { sessionId, response } ) ;
20+
21+ } catch ( error ) {
22+ console . error ( "Error in chatController:" , error ) ;
23+ return res . status ( 500 ) . json ( { error : "Internal server error" } ) ;
24+ }
25+ }
You can’t perform that action at this time.
0 commit comments