From 586f0993c687b25d5202e51e25844234319a4489 Mon Sep 17 00:00:00 2001 From: NolanTrem <34580718+NolanTrem@users.noreply.github.com> Date: Tue, 30 Jul 2024 16:40:55 -0700 Subject: [PATCH] Move rag chat to rag agent --- .../r2rClientIntegrationSuperUser.test.ts | 4 ++-- package-lock.json | 2 +- package.json | 2 +- src/models.tsx | 2 +- src/r2rClient.ts | 20 +++++++++---------- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/__tests__/r2rClientIntegrationSuperUser.test.ts b/__tests__/r2rClientIntegrationSuperUser.test.ts index 0f0f9a0..8cca3e8 100644 --- a/__tests__/r2rClientIntegrationSuperUser.test.ts +++ b/__tests__/r2rClientIntegrationSuperUser.test.ts @@ -67,7 +67,7 @@ describe("r2rClient Integration Tests", () => { { role: "user", content: "Tell me about Raskolnikov." }, ]; - await expect(client.ragChat({ messages })).resolves.not.toThrow(); + await expect(client.ragAgent({ messages })).resolves.not.toThrow(); }, 30000); test("Generate RAG Chat response with streaming", async () => { @@ -81,7 +81,7 @@ describe("r2rClient Integration Tests", () => { rag_generation_config: { stream: true }, }; - const stream = await client.ragChat(streamingConfig); + const stream = await client.ragAgent(streamingConfig); expect(stream).toBeDefined(); expect(stream instanceof ReadableStream).toBe(true); diff --git a/package-lock.json b/package-lock.json index 199635a..8b61ed7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "r2r-js", - "version": "1.2.12", + "version": "1.2.13", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 7d8b093..8f85abe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "r2r-js", - "version": "1.2.12", + "version": "1.2.13", "description": "", "main": "dist/index.js", "browser": "dist/index.browser.js", diff --git a/src/models.tsx b/src/models.tsx index aa21638..d0cb370 100644 --- a/src/models.tsx +++ b/src/models.tsx @@ -132,7 +132,7 @@ export interface R2RLogsRequest { max_runs_requested: number; } -export interface R2RRAGChatRequest { +export interface R2RRAGAgentRequest { messages: Message[]; vector_search_settings?: { use_vector_search: boolean; diff --git a/src/r2rClient.ts b/src/r2rClient.ts index 481b29c..a24684c 100644 --- a/src/r2rClient.ts +++ b/src/r2rClient.ts @@ -23,7 +23,7 @@ import { R2RUpdatePromptRequest, R2RIngestFilesRequest, R2RSearchRequest, - R2RRAGChatRequest, + R2RRAGAgentRequest, R2RRAGRequest, R2RDeleteRequest, R2RAnalyticsRequest, @@ -698,8 +698,8 @@ export class r2rClient { return response; } - @feature("ragChat") - async ragChat(params: { + @feature("ragAgent") + async ragAgent(params: { messages: Message[]; use_vector_search?: boolean; search_filters?: Record; @@ -726,7 +726,7 @@ export class r2rClient { include_title_if_available = true, } = params; - const request: R2RRAGChatRequest = { + const request: R2RRAGAgentRequest = { messages, vector_search_settings: { use_vector_search, @@ -744,20 +744,18 @@ export class r2rClient { }; if (rag_generation_config && rag_generation_config.stream) { - return this.streamRagChat(request); + return this.streamRagAgent(request); } else { - console.log("RAG Chat Request:", JSON.stringify(request, null, 2)); - return await this._makeRequest("POST", "rag_chat", { data: request }); + return await this._makeRequest("POST", "rag_agent", { data: request }); } } - @feature("streamingRagChat") - private async streamRagChat( - request: R2RRAGChatRequest, + private async streamRagAgent( + request: R2RRAGAgentRequest, ): Promise> { this._ensureAuthenticated(); - return this._makeRequest>("POST", "rag_chat", { + return this._makeRequest>("POST", "rag_agent", { data: request, headers: { "Content-Type": "application/json",