0.1.3 • Published 1 year 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
1 year ago
0.1.2
1 year ago
0.1.1
1 year ago
0.1.0
1 year ago
0.0.9
1 year ago
0.0.89
1 year ago
0.0.88
1 year ago
0.0.87
1 year ago
0.0.86
1 year ago
0.0.85
1 year ago
0.0.84
1 year ago
0.0.83
1 year ago
0.0.82
1 year ago
0.0.81
1 year ago
0.0.80
1 year ago
0.0.79
1 year ago
0.0.78
1 year ago
0.0.77
1 year ago
0.0.76
1 year ago
0.0.75
1 year ago
0.0.7
1 year ago
0.0.6
1 year ago
0.0.5
1 year ago
0.0.4
1 year ago
0.0.3
1 year ago
0.0.2
1 year ago
0.0.1
1 year ago