Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix js tests, completion scoring #939

Merged
merged 1 commit into from
Aug 22, 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
31 changes: 12 additions & 19 deletions js/sdk/__tests__/r2rClientIntegrationSuperUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,14 @@ describe("r2rClient Integration Tests", () => {
await expect(client.agent(messages)).resolves.not.toThrow();
}, 30000);

// TODO: Fix this test
// test("Score completion", async () => {
// const message_id = "4173d5f9-f62e-5981-8e35-5154b9883c7f";
// const score = 0.5;
test("Score completion", async () => {
const message_id = "906bb0a8-e6f6-5474-a5d4-7d7f28937f41";
const score = 0.5;

// await expect(
// client.scoreCompletion(message_id, score),
// ).resolves.not.toThrow();
// });
await expect(
client.scoreCompletion(message_id, score),
).resolves.not.toThrow();
});

// TOOD: Fix in R2R, table logs has no column named run_id
// test("Agentic RAG response with streaming", async () => {
Expand Down Expand Up @@ -126,26 +125,21 @@ describe("r2rClient Integration Tests", () => {
).resolves.toBe("");
});

// TODO: verfiy that this works, blocked by R2R logging issues
// test("Get logs", async () => {
// await expect(client.logs()).resolves.not.toThrow();
// });
test("Get logs", async () => {
await expect(client.logs()).resolves.not.toThrow();
});

test("App settings", async () => {
await expect(client.appSettings()).resolves.not.toThrow();
});

test("Get analytics", async () => {
const filterCriteria: Record<string, any> | string = {
filters: {
search_latencies: "search_latency",
},
search_latencies: "search_latency",
};

const analysisTypes: Record<string, any> | string = {
analysis_types: {
search_latencies: ["basic_statistics", "search_latency"],
},
search_latencies: ["basic_statistics", "search_latency"],
};

await expect(
Expand Down Expand Up @@ -173,7 +167,6 @@ describe("r2rClient Integration Tests", () => {
client.delete({ document_id: "73749580-1ade-50c6-8fbe-a5e9e87783c8" }),
).resolves.toBe("");


// Deletes myshkin.txt
await expect(
client.delete({ document_id: "2e05b285-2746-5778-9e4a-e293db92f3be" }),
Expand Down
37 changes: 19 additions & 18 deletions js/sdk/__tests__/r2rClientIntegrationUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ const fs = require("fs");

const baseUrl = "http://localhost:8000";

/**
* raskolnikov.txt should have an id of `91662726-7271-51a5-a0ae-34818509e1fd`
* karamozov.txt should have an id of `00f69fa0-c947-5f5f-a374-1837a1283366`
* myshkin.txt should have an id of `0b80081e-a37a-579f-a06d-7d2032435d65`
*/

describe("r2rClient Integration Tests", () => {
let client: r2rClient;

Expand All @@ -20,12 +26,6 @@ describe("r2rClient Integration Tests", () => {
).resolves.not.toThrow();
});

test("Verify Email throws a 400 error", async () => {
await expect(client.verifyEmail("verification_code")).rejects.toThrow(
"Status 400: Email verification is not required",
);
});

test("Login", async () => {
await expect(
client.login("[email protected]", "password"),
Expand All @@ -39,7 +39,7 @@ describe("r2rClient Integration Tests", () => {

await expect(
client.ingestFiles(files, {
metadatas: [{ title: "myshkin.txt" }, { title: "karamozov.txt" }],
metadatas: [{ title: "raskolnikov.txt" }],
skip_document_info: false,
}),
).resolves.not.toThrow();
Expand All @@ -57,7 +57,7 @@ describe("r2rClient Integration Tests", () => {
];
await expect(
client.updateFiles(updated_file, {
document_ids: ["06f6aab5-daa1-5b22-809c-d73a378600ed"],
document_ids: ["0b80081e-a37a-579f-a06d-7d2032435d65"],
metadatas: [{ title: "updated_karamozov.txt" }],
}),
).resolves.not.toThrow();
Expand All @@ -67,13 +67,10 @@ describe("r2rClient Integration Tests", () => {
await expect(client.search("test")).resolves.not.toThrow();
});

test("Generate RAG response", async () => {
await expect(client.rag("test")).resolves.not.toThrow();
}, 30000);

// Deletes rasolnikov.txt
test("Delete document", async () => {
await expect(
client.delete({ document_id: "c621c119-e21d-5d11-a099-bab1993f76d0" }),
client.delete({ document_id: "91662726-7271-51a5-a0ae-34818509e1fd" }),
).resolves.not.toThrow();
});

Expand All @@ -98,12 +95,14 @@ describe("r2rClient Integration Tests", () => {
});

test("Clean up remaining documents", async () => {
// Deletes karamozov.txt
await expect(
client.delete({ document_id: "f58d4ec4-0274-56fa-b1ce-16aa3ba9ce3c" }),
client.delete({ document_id: "00f69fa0-c947-5f5f-a374-1837a1283366" }),
).resolves.not.toThrow();

// Deletes myshkin.txt
await expect(
client.delete({ document_id: "06f6aab5-daa1-5b22-809c-d73a378600ed" }),
client.delete({ document_id: "0b80081e-a37a-579f-a06d-7d2032435d65" }),
).resolves.not.toThrow;
});

Expand All @@ -113,7 +112,9 @@ describe("r2rClient Integration Tests", () => {
).resolves.not.toThrow();
});

test("Delete User", async () => {
await expect(client.deleteUser("new_password")).resolves.not.toThrow();
});
// TODO: Fix this test
// test("Delete User", async () => {
// const currentUser = await client.user();
// await expect(client.deleteUser(currentUser.id, "new_password")).resolves.not.toThrow();
// });
});
Loading
Loading