Using the Frame SDK
The Frame SDK provides a simple Typescript-based interface for interacting with your deployment. At its core, the SDK revolves around the concept of a document.
What is a “Document”?
In Frame, a “document” represents a unit of data that gets embedded and stored in your vector database. Because Frame is multimodal, a document can be:
- A piece of text (e.g., a paragraph, product description)
- An image (e.g., a photo or screenshot)
- A combination of both text and image (e.g., an image with a caption)
We developed Frame to be flexible, allowing developers to adapt the platform to their specific embedding needs.
Installation
npm install frame-v1Usage
import { Client } from "frame-v1`";
const frame = new Client({ apiKey: "<YOUR_API_KEY>", baseURL: "https://<YOUR_API_ENDPOINT>.com",});
// Example usageframe.getDocuments().then((response) => { console.log(response);});getDocuments
Gets a list of documents with optional arguments to paginate results.
Arguments:
limitnumber (optional)offsetnumber (optional)
By default, limit is 20 and offset is 0.
Example:
frame.getDocuments();frame.getDocuments({ limit: 10, offset: 15 });getDocumentById
Find a specific document by its ID.
Arguments:
idnumber (required)
Example
frame.getDocumentById(3);createDocuments
Add new documents. A document may optionally omit a URL or a description, but at least one of either must exist.
Arguments:
documentsarray (required)
Example
const documents = [ { url: "https://media.newyorker.com/photos/59095c501c7a8e33fb38c107/master/pass/Monkey-Selfie-DailyShouts.jpg", description: "foo", metadata: { title: "bar", altText: "baz", }, }, { url: "https://media.newyorker.com/photos/59095bb86552fa0be682d9d0/master/pass/Monkey-Selfie.jpg", },];
frame.createDocuments(documents);deleteDocumentById
Delete a specific document by its ID.
Arguments:
idnumber (required)
Example
frame.deleteDocumentById(1);searchDocuments
Search similar documents based on input, with optional arguments for topK (number of results) and similarity threshold (0.0 - 1.0).
By default, topK is 10 and threshold is 0.
Arguments:
urlstring (at least one of url or description must exist)descriptionstring (at least one of url or description must exist)thresholdnumber (optional)topKnumber (optional)
Example
const query = { url: "https://example.com/monalisa.jpeg", description: "An image of a sitting woman", threshold: 0.3, topK: 5,};
frame.searchDocuments(query);getRecommendations
Get similar documents based on a document’s ID.
By default, topK is 10 and threshold is 0.
Arguments:
idnumber (required)topKnumber (optional)thresholdnumber (optional)
Example
frame.getRecommendations(1, { topK: 5, threshold: 0.3 });