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

Move rag chat to rag agent #49

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions __tests__/r2rClientIntegrationSuperUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 9 additions & 11 deletions src/r2rClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
R2RUpdatePromptRequest,
R2RIngestFilesRequest,
R2RSearchRequest,
R2RRAGChatRequest,
R2RRAGAgentRequest,
R2RRAGRequest,
R2RDeleteRequest,
R2RAnalyticsRequest,
Expand Down Expand Up @@ -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<string, any>;
Expand All @@ -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,
Expand All @@ -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<ReadableStream<Uint8Array>> {
this._ensureAuthenticated();

return this._makeRequest<ReadableStream<Uint8Array>>("POST", "rag_chat", {
return this._makeRequest<ReadableStream<Uint8Array>>("POST", "rag_agent", {
data: request,
headers: {
"Content-Type": "application/json",
Expand Down
Loading