Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 35bc773

Browse files
authored
Merge pull request #31 from SciPhi-AI/emrgnt-cmplxty-patch-1
Update r2rClient.ts
2 parents 2953f3c + 178e867 commit 35bc773

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/r2rClient.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff 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")

0 commit comments

Comments
 (0)