Skip to content

different-ai/embedbase-js

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.

⚠️🔥 (sdk is still in alpha, if you if you have some feedback readch out to ben@embedbase.xyz

Embedbase

Embedbase is an open-source API to compute ML embeddings. This SDK makes it easy to use Embedbase in your app.

Before you start, you need get a an API key at embedbase.xyz.

Note: we're working on a fully client-side SDK. In the meantime, you can use the hosted instance of Embedbase.

npm i embedbase-js

Table of contents

Design philosophy

  • Simple
  • Open-source
  • Composable (integrates well with LLM & various databases)

What's Included

  • Hosted Instance Working on top of Embedbase. Sign Up
  • Authentication and Authorization. Docs
  • Typescript SDK. Docs
    • Server-side embeddings computation
    • Local embeddings computation
  • Dashboard Docs
    • Search Datasets
    • Use the playground to get started
    • Visualize datasets (coming soon)

Why Embedbase

Embeddings are a powerful way to represent data. They can be used to create recommendation engines, search engines, and Q&A engines. Embedbase gives you and sdk & an api to create these systems without any ML knowledge.

Embedbase is fully open-source and is designed to accompany you from your first line of code to shipping your apps to millions of users.

What is it

This is the official typescript client for Embedbase. Embedbase is an open-source API to manage ML embeddings.

Who is it for

  • App developers who want to add ML to their apps without having to worry about the infrastructure
  • ML engineers who want to prototype classification systems

Installation

You can install embedbase-js via the terminal.

npm i embedbase-js

Initializing

import { createClient } from 'embedbase-js'

// you can find the api key at https://embedbase.xyz
const apiKey = 'your api key'
// this is using the hosted instance
const url = 'https://api.embedbase.xyz'

const embedbase = createClient(url, apiKey)

Searching datasets

// fetching data
const data = await embedbase
  .dataset('amazon-reviews')
  .search('best hot dogs accessories', { limit: 3 })

console.log(data)
// [
//   {
//       "similarity": 0.810843349,
//       "data": "The world is going to smell very different once electric      vehicles become commonplace"
//   },
//   {
//       "similarity": 0.794602573,
//       "data": "200 years ago, people would never have guessed that humans in the future would communicate by silently tapping on glass"
//   },
//   {
//       "similarity": 0.792932034,
//       "data": "The average car in space is nicer than the average car on Earth"
//   },
// ]

Adding Data

const data =
  await // embeddings are extremely good for retrieving unstructured data
  // in this example we store an unparsable html string
  embedbase.dataset('amazon-reviews').add(`
  <div>
    <span>Lightweight. Telescopic. Easy zipper case for storage. Didn't put in dishwasher. Still perfect after many uses.</span>
`)

console.log(data)
//
// {
//   "id": "eiew823",
//   "data": "Lightweight. Telescopic. Easy zipper case for storage.
//          Didn't put in dishwasher. Still perfect after many uses."
// }

Creating a "context"

createContext is very similar to .search but it returns strings instead of an object. This is useful if you want to easily feed it to GPT.

// you can create a context to store data
const data = await embedbase
  .dataset('my-documentation')
  .createContext('my-context')

console.log(data)
[
 "Embedbase API allows to store unstructured data...",
 "Embedbase API has 3 main functions a) provides a plug and play solution to store embeddings b) makes it easy to connect to get the right data into llms c)..",
 "Embedabase API is self-hostable...",
]

Adding metadata

const data =
  await
  embedbase.dataset('amazon-reviews').add(`
  <div>
    <span>Lightweight. Telescopic. Easy zipper case for storage. Didn't put in dishwasher. Still perfect after many uses.</span>
    // metadata can be anything you want that will appear in the search results later
`, {category: 'smallItems', user: 'bob'})

console.log(data)
//
// {
//   "id": "eiew823",
//   "data": "Lightweight. Telescopic. Easy zipper case for storage.
//          Didn't put in dishwasher. Still perfect after many uses.",
//   "metadata": {"category": "smallItems", "user": "bob"}
// }

Listing datasets

const data = await embedbase.datasets()
console.log(data)
// [{"datasetId": "amazon-reviews", "documentsCount": 2}]

How to create a recommendation engine

coming soon

How to build a search engine

coming soon

How to create a Q&A documentation

coming soon