0.1.3 • Published 11 months ago
ic-use-blueband-db v0.1.3
IC-Blueband-db
React library for interacting with the Blueband-db
. It exports functions to load indexes into system memory, save new items and compare similarity between saved documents and prompts using in-memory operations.
Getting Started
Prerequisites
{
"blueband_db_provider": {
"type": "custom",
"candid": "https://github.com/acgodson/blueband-db/releases/download/v0.0.9/blueband-db-backend.did",
"wasm": "https://github.com/acgodson/blueband-db/releases/download/v0.0.9/blueband-db-backend.wasm.gz"
}
}
Usage
1. Initialize an Index
Connect to the actor and initialize an index:
import {actor} from "./provider_actor_path";
import { useBlueBand } from "ic-use-blueband";
const ReactComponent = () = {
const { initializeIndex} = useBlueband();
const collectionId = "unique collection_id";
cons config = {
collection: collectionId,
api_key: OPENAI_KEY,
/*chunk options*/
}
await initializeIndex(actor, config);
2. Add Items
Add documents to the index:
const { AddItem, Query } = useBlueband();
const title = "Document Title or Url";
const content = "Document content...";
await AddItem(title, content);
3. Query Items
Query the index to find documents similar to a given prompt:
const { Query } = useBlueband();
const results = await Query("query text");
//Results are ranked by similarity scores:
// [
// {
// "title": "Document Title",
// "id": "document_id",
// "score": 0.951178544877223,
// "chunks": 1,
// "sections": [
// /*...*/
// ],
// "tokens": 156
// },
// {
// "title": "Document Title",
// "id": "document_id",
// "score": 0.726565512777365,
// "chunks": 4,
// "sectio ns": [
// /*...*/
// ],
// "tokens": 500
// }
// ]
0.1.3
11 months ago
0.1.2
11 months ago
0.1.1
11 months ago
0.1.0
11 months ago
0.0.9
11 months ago
0.0.89
11 months ago
0.0.88
11 months ago
0.0.87
11 months ago
0.0.86
11 months ago
0.0.85
11 months ago
0.0.84
11 months ago
0.0.83
11 months ago
0.0.82
11 months ago
0.0.81
11 months ago
0.0.80
11 months ago
0.0.79
11 months ago
0.0.78
11 months ago
0.0.77
11 months ago
0.0.76
11 months ago
0.0.75
11 months ago
0.0.7
11 months ago
0.0.6
11 months ago
0.0.5
11 months ago
0.0.4
11 months ago
0.0.3
11 months ago
0.0.2
11 months ago
0.0.1
11 months ago