🍁JavaScript SDK
Mindplug is the easiest solution to creating and managing embeddings. Add long term memory to your LLMs, perform semantic data analysis and easily filter data based on metadata. Connect your app to external web sources using our smart endpoint.
Install Mindplug
NPM:
npm install mindplug
yarn:
yarn add mindplug
Initialize Mindplug
Obtain an API key from Mindplug dashboard.
import Mindplug from 'mindplug';
const mindplug = new Mindplug({mindplugKey: <SAMPLE KEY>});
If you don't yet have access, please book an onboarding call.
Store Data
All storage of data requires a db and a collection.
Store text. Requires content
mindplug.store({
db: "first database",
collection: "any collection",
content: "hello, sample text to store",
});
Store PDF file. Requires an object of type File under 50MB
mindplug.storePDF({
db: "first database",
collection: "any collection",
file: <SAMPLE FILE>
});
Store webpage. Requires the webpage url
mindplug.storeWeb({
db: "first database",
collection: "any collection",
url: "https://mindplug.io"
});
Store audio. Requires a MP3 or WAV file under 20MB
// must pass an openaiKey to constructor
mindplug.storeAudio({
db: "first database",
collection: "any collection",
file: <SAMPLE FILE>
});
Storing - Advanced Techniques
A metadata
of type JSON and a chunkSize
of type number may also be passed to each storage function. Metadata is used to easily filter for data. Chunk size is used to split large data into smaller batches. By default the data is split in about 1024 character chunks.
mindplug.store({
db: "first database",
collection: "any collection",
content: "hello, sample text to store",
metadata: {
purpose: "to learn"
},
chunkSize: 512
});
Query Data
Semantic search. Search stored data by meaning of text.
mindplug.query({
db: "first database",
collection: "any collection",
search: "What fruit is in the fridge?"
});
Query by vector ids.
mindplug.queryByIds({
db: "first database",
collection: "any collection",
vectorIds: ["ID-1", "ID-2"]
});
Query by collection. Returns the recent 10 vectors from the collection.
mindplug.queryByCollection({
db: "first database",
collection: "any collection"
});
Query - Advanced Techniques
By default, mindplug returns the 3 best matches for the searched data. You can change this by passing a count
parameter. You can also filter the stored data based on metadata by passing in a metadataFilters
parameter.
mindplug.query({
db: "first database",
collection: "any collection",
search: "What are the benefits of Solana blockchain?",
metadataFilters: {
genre: ["technology", "blockchain"]
},
count: 1
});
For more information on using metadataFilters, please see our API documentation
Delete data
Delete by vector ids.
mindplug.deleteByIds({
db: "first database",
collection: "any collection",
vectorIds: ["ID-1", "ID-2"]
});
Delete by upload id. Upload id is returned every time new data is stored
mindplug.deleteByUploadId({
db: "first database",
collection: "any collection",
uploadId: "UPLOAD-ID"
});
Delete collection. Also deletes all vectors stored within.
mindplug.deleteCollection({
db: "first database",
collection: "any collection"
});
Delete project. Also deletes all collections and vectors stored within.
mindplug.deleteProject({
db: "first database"
});
List data
List Collections.
mindplug.listCollections({
db: "first database"
});
List projects.
mindplug.listProjects();
Smart Google Search
Google search from select sources.
mindplug.searchWeb({
search: "How to cook pasta?"
});
You can easily manage all your data in the Mindplug dashboard.
Smart - Parsing Webpage
Get all text from a webpage given its URL.
mindplug.parseWebpage({
url: "https://mindplug.io"
});
Returns all text on the webpage.
Last updated