This repository was archived by the owner on Aug 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +17
-10
lines changed
Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -294,17 +294,24 @@ export class r2rClient {
294294 console . log ( "Sending RAG request:" , JSON . stringify ( request , null , 2 ) ) ;
295295 console . log ( "Request headers:" , this . axiosInstance . defaults . headers ) ;
296296
297- if ( request . rag_generation_config ?. stream ) {
298- return this . streamRag ( request ) ;
299- } else {
300- try {
301- const response = await this . axiosInstance . post ( "/rag" , request ) ;
302- return response . data ;
303- } catch ( error ) {
304- console . error ( "Error in rag request:" , error ) ;
305- throw error ;
297+
298+ private async streamRag (
299+ request : R2RRAGRequest
300+ ) : Promise < ReadableStream < Uint8Array > | null > {
301+ const response = await fetch ( `${ this . baseUrl } /rag` , {
302+ method : 'POST' ,
303+ headers : {
304+ 'Content-Type' : 'application/json' ,
305+ // Add any other headers you need, like authentication
306+ } ,
307+ body : JSON . stringify ( request ) ,
308+ } ) ;
309+
310+ if ( ! response . ok ) {
311+ throw new Error ( `HTTP error! status: ${ response . status } ` ) ;
306312 }
307- }
313+
314+ return response . body ;
308315 }
309316
310317 @feature ( "streamingRag" )
You can’t perform that action at this time.
0 commit comments