JSPM

  • Created
  • Published
  • Downloads 521743
  • Score
    100M100P100Q207223F
  • License Apache-2.0

A complete RAG pipeline in your browser, server, or edge network with support for full-text, vector, and hybrid search in less than 2kb.

Package Exports

  • @orama/orama
  • @orama/orama/components
  • @orama/orama/internals
  • @orama/orama/package.json
  • @orama/orama/trees

Readme

Orama

A complete RAG pipeline in your browser, server or edge network with support for full-text, vector, and hybrid search in less than 2kb.

Tests

If you need more info, help, or want to provide general feedback on Orama, join the Orama Slack channel

Highlighted features

Installation

You can install Orama using npm, yarn, pnpm, bun:

npm i @orama/orama

Or import it directly in a browser module:

<html>
  <body>
    <script type="module">
      import { create, insert, search } from 'https://cdn.jsdelivr.net/npm/@orama/orama@latest/+esm'
    </script>
  </body>
</html>

With Deno, you can just use the same CDN URL or use npm specifiers:

import { create, search, insert } from 'npm:@orama/orama'

Read the complete documentation at https://docs.orama.com.

Usage

Orama is quite simple to use. The first thing to do is to create a new database instance and set an indexing schema:

import { create, insert, remove, search, searchVector } from '@orama/orama'

const db = create({
  schema: {
    name: 'string',
    description: 'string',
    price: 'number',
    embedding: 'vector[1536]', // Vector size must be expressed during schema initialization
    meta: {
      rating: 'number',
    },
  },
})

insert(db, {
  name: 'Noise cancelling headphones',
  description: 'Best noise cancelling headphones on the market',
  price: 99.99,
  embedding: [0.2432, 0.9431, 0.5322, 0.4234, ...],
  meta: {
    rating: 4.5
  }
})

const results = search(db, {
  term: 'Best headphones'
})

// {
//   elapsed: {
//     raw: 21492,
//     formatted: '21μs',
//   },
//   hits: [
//     {
//       id: '41013877-56',
//       score: 0.925085832971998432,
//       document: {
//         name: 'Noise cancelling headphones',
//         description: 'Best noise cancelling headphones on the market',
//         price: 99.99,
//         embedding: [0.2432, 0.9431, 0.5322, 0.4234, ...],
//         meta: {
//           rating: 4.5
//         }
//       }
//     }
//   ],
//   count: 1
// }

Orama currently supports 10 different data types:

| Type | Description example | | ---------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | | string | A string of characters. | 'Hello world' | | number | A numeric value, either float or integer. | 42 | | boolean | A boolean value. | true | | enum | An enum value. | 'drama' | | geopoint | A geopoint value. | { lat: 40.7128, lon: 74.0060 } | | string[] | An array of strings. | ['red', 'green', 'blue'] | | number[] | An array of numbers. | [42, 91, 28.5] | | boolean[] | An array of booleans. | [true, false, false] | | enum[] | An array of enums. | ['comedy', 'action', 'romance'] | | vector[<size>] | A vector of numbers to perform vector search on. | [0.403, 0.192, 0.830] |

Official Docs

Read the complete documentation at https://docs.orama.com/open-source.

Official Orama Plugins

Write your own plugin: https://docs.orama.com/open-source/plugins/writing-your-own-plugins

License

Orama is licensed under the Apache 2.0 license.