This repository has been archived by the owner on Aug 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from SciPhi-AI/Nolan/UpdateJS
Update JS client for Auth
- Loading branch information
Showing
11 changed files
with
797 additions
and
343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules/ | ||
dist/ | ||
.DS_Store | ||
.DS_Store | ||
**/.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,13 @@ describe("r2rClient Integration Tests", () => { | |
}); | ||
|
||
test("Health check", async () => { | ||
await expect(client.healthCheck()).resolves.not.toThrow(); | ||
await expect(client.health()).resolves.not.toThrow(); | ||
}); | ||
|
||
test("Login", async () => { | ||
await expect( | ||
client.login("[email protected]", "change_me_immediately"), | ||
).resolves.not.toThrow(); | ||
}); | ||
|
||
test("Ingest file", async () => { | ||
|
@@ -37,11 +43,11 @@ describe("r2rClient Integration Tests", () => { | |
|
||
test("Update files", async () => { | ||
const updated_file = [ | ||
{ path: "examples/data/folder/myshkin.txt", name: "myshkin.txt" }, | ||
{ path: "examples/data/folder/myshkin.txt", name: "super_myshkin.txt" }, | ||
]; | ||
await expect( | ||
client.updateFiles(updated_file, { | ||
document_ids: ["48e29904-3010-54fe-abe5-a4f3fba59110"], | ||
document_ids: ["f3c6afa5-fc58-58b7-b797-f7148e5253c3"], | ||
metadatas: [{ title: "updated_karamozov.txt" }], | ||
}), | ||
).resolves.not.toThrow(); | ||
|
@@ -53,19 +59,19 @@ describe("r2rClient Integration Tests", () => { | |
|
||
test("Generate RAG response", async () => { | ||
await expect(client.rag({ query: "test" })).resolves.not.toThrow(); | ||
}); | ||
}, 10000); | ||
|
||
test("Delete document", async () => { | ||
await expect( | ||
client.delete(["document_id"], ["153a0857-efc4-57dd-b629-1c7d58c24a93"]), | ||
client.delete(["document_id"], ["cb6e55f3-cb3e-5646-ad52-42f06eb321f5"]), | ||
).resolves.not.toThrow(); | ||
}); | ||
|
||
test("Get logs", async () => { | ||
await expect(client.logs()).resolves.not.toThrow(); | ||
}); | ||
|
||
test("Get app settings", async () => { | ||
test("App settings", async () => { | ||
await expect(client.appSettings()).resolves.not.toThrow(); | ||
}); | ||
|
||
|
@@ -97,18 +103,21 @@ describe("r2rClient Integration Tests", () => { | |
|
||
test("Get document chunks", async () => { | ||
await expect( | ||
client.documentChunks("48e29904-3010-54fe-abe5-a4f3fba59110"), | ||
client.documentChunks("43eebf9c-c2b4-59e5-993a-054bf4a5c423"), | ||
).resolves.not.toThrow(); | ||
}); | ||
|
||
afterAll(async () => { | ||
// Clean up | ||
await client.delete( | ||
["document_id", "document_id"], | ||
[ | ||
"48e29904-3010-54fe-abe5-a4f3fba59110", | ||
"102e815f-3998-5373-8d7d-a07795266ed6", | ||
], | ||
); | ||
test("Clean up remaining documents", async () => { | ||
await expect( | ||
client.delete(["document_id"], ["43eebf9c-c2b4-59e5-993a-054bf4a5c423"]), | ||
).resolves.not.toThrow(); | ||
|
||
await expect( | ||
client.delete(["document_id"], ["f3c6afa5-fc58-58b7-b797-f7148e5253c3"]), | ||
).resolves.not.toThrow; | ||
}); | ||
|
||
test("Logout", async () => { | ||
await expect(client.logout()).resolves.not.toThrow(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import { r2rClient } from "../src/index"; | ||
import { FilterCriteria, AnalysisTypes } from "../src/models"; | ||
const fs = require("fs"); | ||
|
||
const baseUrl = "http://localhost:8000"; | ||
|
||
describe("r2rClient Integration Tests", () => { | ||
let client: r2rClient; | ||
|
||
beforeAll(async () => { | ||
client = new r2rClient(baseUrl); | ||
}); | ||
|
||
test("Health check", async () => { | ||
await expect(client.health()).resolves.not.toThrow(); | ||
}); | ||
|
||
test("Register user", async () => { | ||
await expect( | ||
client.register("[email protected]", "password"), | ||
).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"), | ||
).resolves.not.toThrow(); | ||
}); | ||
|
||
test("Ingest file", async () => { | ||
const files = [ | ||
{ path: "examples/data/raskolnikov.txt", name: "raskolnikov.txt" }, | ||
]; | ||
|
||
await expect( | ||
client.ingestFiles(files, { | ||
metadatas: [{ title: "myshkin.txt" }, { title: "karamozov.txt" }], | ||
skip_document_info: false, | ||
}), | ||
).resolves.not.toThrow(); | ||
}); | ||
|
||
test("Ingest files in folder", async () => { | ||
const files = ["examples/data/folder"]; | ||
|
||
await expect(client.ingestFiles(files)).resolves.not.toThrow(); | ||
}); | ||
|
||
test("Update files", async () => { | ||
const updated_file = [ | ||
{ path: "examples/data/folder/myshkin.txt", name: "myshkin.txt" }, | ||
]; | ||
await expect( | ||
client.updateFiles(updated_file, { | ||
document_ids: ["06f6aab5-daa1-5b22-809c-d73a378600ed"], | ||
metadatas: [{ title: "updated_karamozov.txt" }], | ||
}), | ||
).resolves.not.toThrow(); | ||
}); | ||
|
||
test("Search documents", async () => { | ||
await expect(client.search("test")).resolves.not.toThrow(); | ||
}); | ||
|
||
test("Generate RAG response", async () => { | ||
await expect(client.rag({ query: "test" })).resolves.not.toThrow(); | ||
}, 10000); | ||
|
||
test("Delete document", async () => { | ||
await expect( | ||
client.delete(["document_id"], ["c621c119-e21d-5d11-a099-bab1993f76d0"]), | ||
).resolves.not.toThrow(); | ||
}); | ||
|
||
test("Only a superuser can call app settings", async () => { | ||
await expect(client.appSettings()).rejects.toThrow( | ||
"Status 403: Only a superuser can call the `app_settings` endpoint.", | ||
); | ||
}); | ||
|
||
test("Get documents overview", async () => { | ||
await expect(client.documentsOverview()).resolves.not.toThrow(); | ||
}); | ||
|
||
test("Logout", async () => { | ||
await expect(client.logout()).resolves.not.toThrow(); | ||
}); | ||
|
||
test("Login after logout", async () => { | ||
await expect( | ||
client.login("[email protected]", "password"), | ||
).resolves.not.toThrow(); | ||
}); | ||
|
||
test("Clean up remaining documents", async () => { | ||
await expect( | ||
client.delete(["document_id"], ["f58d4ec4-0274-56fa-b1ce-16aa3ba9ce3c"]), | ||
).resolves.not.toThrow(); | ||
|
||
await expect( | ||
client.delete(["document_id"], ["06f6aab5-daa1-5b22-809c-d73a378600ed"]), | ||
).resolves.not.toThrow; | ||
}); | ||
|
||
test("Change password", async () => { | ||
await expect( | ||
client.changePassword("password", "new_password"), | ||
).resolves.not.toThrow(); | ||
}); | ||
|
||
test("Delete User", async () => { | ||
await expect(client.deleteUser("new_password")).resolves.not.toThrow(); | ||
}); | ||
}); |
Binary file not shown.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.