0.3.12 • Published 6 days ago

r2r-js v0.3.12

Weekly downloads
-
License
ISC
Repository
-
Last release
6 days ago

About

The official JavaScript client for R2R (Retrieval-Augmented Generation to Riches). R2R is designed to bridge the gap between local LLM experimentation and scalable, state of the art Retrieval-Augmented Generation (RAG). This JavaScript client provides a seamless interface to interact with the R2R RESTful API.

For a more complete view of R2R, check out the full documentation.

Key Features

  • 📁 Multimodal Support: Ingest files ranging from .txt, .pdf, .json to .png, .mp3, and more.
  • 🔍 Hybrid Search: Combine semantic and keyword search with reciprocal rank fusion for enhanced relevancy.
  • 🔗 Graph RAG: Automatically extract relationships and build knowledge graphs.
  • 🗂️ App Management: Efficiently manage documents and users with rich observability and analytics.
  • 🌐 Client-Server: RESTful API support out of the box.
  • 🧩 Configurable: Provision your application using intuitive configuration files.
  • 🔌 Extensible: Develop your application further with easy builder + factory pattern.
  • 🖥️ Dashboard: Use the R2R Dashboard, an open-source React+Next.js app for a user-friendly interaction with R2R.

Table of Contents

  1. Install
  2. R2R JavaScript Client Quickstart
  3. Community and Support
  4. Contributing

Install

npm install r2r-js

R2R JavaScript Client Quickstart

Initialize the R2R client

const { r2rClient } = require("r2r-js");

const client = new r2rClient("http://localhost:7272");

Login

const EMAIL = "admin@example.com";
const PASSWORD = "change_me_immediately";
console.log("Logging in...");
await client.login(EMAIL, PASSWORD);

Ingest files

const files = [
  { path: "examples/data/raskolnikov.txt", name: "raskolnikov.txt" },
  { path: "examples/data/karamozov.txt", name: "karamozov.txt" },
];

const ingestResult = await client.ingestFiles(files, {
  metadatas: [{ title: "raskolnikov.txt" }, { title: "karamozov.txt" }],
  user_ids: [
    "123e4567-e89b-12d3-a456-426614174000",
    "123e4567-e89b-12d3-a456-426614174000",
  ],
});
console.log(ingestResult);

Perform a search

const searchResult = await client.search("Who was Raskolnikov?");
console.log(searchResult);

Perform RAG

const ragResult = await client.rag({
  query: "Who was Raskolnikov?",
  use_vector_search: true,
  filters: {},
  search_limit: 10,
  use_hybrid_search: false,
  use_kg_search: false,
  kg_generation_config: {},
  rag_generation_config: {
    model: "gpt-4o",
    temperature: 0.0,
    stream: false,
  },
});
console.log(ragResult);

Stream a RAG Response

const streamingRagResult = await client.rag({
  query: "Who was Raskolnikov?",
  rag_generation_config: {
    stream: true,
  },
});

if (streamingRagResult instanceof ReadableStream) {
  const reader = streamingRagResult.getReader();
  while (true) {
    const { done, value } = await reader.read();
    if (done) break;
    console.log(new TextDecoder().decode(value));
  }
}

Community and Support

  • Discord: Chat live with maintainers and community members
  • Github Issues: Report bugs and request features

Explore our R2R Docs for tutorials and cookbooks on various R2R features and integrations.

Contributing

We welcome contributions of all sizes! Here's how you can help:

Our Contributors

0.3.12

6 days ago

0.3.11

11 days ago

0.3.9

14 days ago

0.3.10

13 days ago

0.3.5

1 month ago

0.3.8

18 days ago

0.3.7

25 days ago

0.3.2

2 months ago

0.3.1

2 months ago

0.3.4

1 month ago

0.3.3

2 months ago

1.2.0

4 months ago

1.0.19

4 months ago

1.0.18

4 months ago

1.0.17

4 months ago

1.0.16

4 months ago

1.2.8

4 months ago

1.2.7

4 months ago

1.0.9

4 months ago

1.2.6

4 months ago

1.0.8

4 months ago

1.2.5

4 months ago

1.0.7

4 months ago

1.2.4

4 months ago

1.0.6

4 months ago

1.2.3

4 months ago

1.2.2

4 months ago

1.2.1

4 months ago

1.0.22

4 months ago

1.0.21

4 months ago

1.0.20

4 months ago

1.0.26

4 months ago

1.0.25

4 months ago

1.0.24

4 months ago

1.0.23

4 months ago

1.0.29

4 months ago

1.0.28

4 months ago

1.0.27

4 months ago

0.3.0

2 months ago

1.2.12

3 months ago

1.0.33

4 months ago

1.2.13

3 months ago

1.0.32

4 months ago

1.2.10

3 months ago

1.0.31

4 months ago

1.2.11

3 months ago

1.0.30

4 months ago

1.0.37

4 months ago

1.0.36

4 months ago

1.2.14

3 months ago

1.0.35

4 months ago

1.2.15

3 months ago

1.0.34

4 months ago

1.1.1

4 months ago

1.1.0

4 months ago

1.0.38

4 months ago

1.2.9

4 months ago

1.0.11

4 months ago

1.0.10

4 months ago

1.0.15

4 months ago

1.0.14

4 months ago

1.0.13

4 months ago

1.0.12

4 months ago

1.0.5

6 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago