Get StartedStep 1 - Setup1.2 Setup with SDK (Admin API)

Setup with SDK (Admin API)

This guide will walk you through setting up Unbody programmatically using our SDK and Admin API. The SDK provides more flexibility and control over your project configuration compared to the dashboard.

Installation

Install Unbody’s core packages to get started:

npm install unbody

Import Dependencies

First, import the necessary modules from Unbody’s SDK packages. Unbody provides several APIs for different purposes:

// Manage resources and orchestration
import { UnbodyAdmin } from '@unbody/admin';
// Import custom data
import { UnbodyPushAPI } from '@unbody/push';

Configure Project Settings

Create a new instance of ProjectSettings and configure your project’s capabilities:

import { ProjectSettings } from '@unbody/admin';
 
const projectSettings = new ProjectSettings();
 
projectSettings
  // Vectorizers
  .set(new TextVectorizer(TextVectorizer.OpenAI.TextEmbedding35Small))
  .set(new ImageVectorizer(ImageVectorizer.Unbody.ImgVec))
 
  // Generative modules
  .set(new Generative(Generative.Cohere.CommandPlus))
 
  // Utilities
  .set(new Reranker(Reranker.Cohere.EnglishV3))
 
  // Enhancers - text
  .set(new AutoSummary(AutoSummary.OpenAI.GPT4o))
  .set(new AutoEntities(AutoEntities.Unbody.Bert))
 
  // Enhancers - visuals
  .set(new AutoVision(AutoVision.OpenAI.GPT4v))
 
  // Parsers & chunkers
  .set(new PdfParser(PdfParser.Pdf2Image.Default));

Create and Save Project

Initialize your project with the configured settings and save it:

const project = admin.projects.ref({
  id: "",
  name: "",
  settings: projectSettings
});
 
project.save();

Add Data Source

Create, save, and update your data source:

const source = project.sources.ref({
  type: 'push_api',
  name: "..."
});
 
source.save();
source.update();

The source.update() method helps you refresh and sync your data source. Make sure to monitor the source status to ensure proper initialization and data processing.

Next

Ready to start building with your programmatically configured Unbody project?

©2024 Unbody