Last updated

/iblai-vibe-agent-dataset

Mirrored from iblai/vibe · skills/agents/iblai-vibe-agent-dataset/SKILL.md. This page is generated — edit it in the repository, not here.

Add the agent Datasets tab -- the agent's knowledge base. Scope: per agent. Each resource is a training document attached to the agent, and the agent answers from every trained document for every user who chats with it. The tab is a searchable table (five rows per page) with an Add Resource button that opens the SDK's own resource picker. This is one tab in the agent-settings family indexed by /iblai-vibe-agent; it shares the AgentSettingsProvider wrapper with every other tab.

Datasets -- name (links to the source), type, tokens, retrain interval, visibility, and a training switch. Add Resource shows only when the user holds the create grant on the agent's documents (Step 2).

Datasets tab -- table
Datasets tab -- table

Add Resources -- one tile per source: PowerPoint, OneDrive, Google Drive, Dropbox, YouTube, URL, PDF, DOCX, Excel, CSV, GitHub, TXT, Markdown, Audio, Video, Image, Web Crawler, ZIP, Course. disabledResourceTypes greys tiles out and makes them unclickable; it does not hide them.

Google Drive -- the tile opens Google's own file picker over Add Resources. Clicking outside Google's box or pressing Escape closes only Google's box. When the browser blocks Google's cookies (Firefox Total Cookie Protection, Brave Shields), Google first shows Allow cookies: clicking it brings up the browser's Allow / Block prompt. If the picker has not loaded after 10 seconds, Add Resources shows one red line, "Your browser blocked Google Drive. Try again and click Allow cookies in the Google window.", with a Try Again button that reopens it.

Datasets tab -- Add Resources
Datasets tab -- Add Resources

Source dialog -- each tile opens its own dialog (here URL). Submit queues the resource ("Document has been queued for training"); the row shows "In progress" until training finishes.

Datasets tab -- URL dialog
Datasets tab -- URL dialog

Schedule Retraining -- the clock in Interval opens a retrain schedule (daily, weekly, monthly, or a custom number of days). It is enabled only for trained documents that can be re-fetched (URLs, YouTube, GitHub, crawls); uploaded files and cloud-drive documents cannot be retrained.

Datasets tab -- Schedule Retraining
Datasets tab -- Schedule Retraining

Untrain, then delete -- switching a trained row off untrains it and then offers Delete Dataset. Switching an untrained row on asks whether to Train it (web crawls take an optional User-Agent) or Delete it.

Datasets tab -- Delete Dataset
Datasets tab -- Delete Dataset

Common setup (brand, conventions, env files, verification): see docs/skill-setup.md.

Prerequisites

  • Auth set up (/iblai-vibe-auth, or vibe-starter).
  • AgentSettingsProvider wraps the route (/iblai-vibe-agent §1).
  • @iblai/iblai-js@^2.62.1 (resolves @iblai/web-containers 1.62.1). Check with pnpm why @iblai/web-containers. The Google Drive behaviour below (Allow cookies, Try Again) needs 2.62.2 or later.
  • A real agent UUID. Ask the user; never invent one.
  • For the Google Drive tile: the organization's drive data-source credential (client_id, developer_key; see /iblai-api-integration). The client_id must be a Google OAuth client id of the form <project-number>-<x>.apps.googleusercontent.com with the drive.file scope: the picker sends the leading number (the Cloud project number) as appId, which lets the app open the files a user picks.

Step 1: Check Environment

Look for iblai.env in the project root with PLATFORM, DOMAIN, and TOKEN. If it is missing, tell the user: "You need an iblai.env with your platform configuration. Download the template and fill in your values: curl -o iblai.env https://raw.githubusercontent.com/iblai/vibe/refs/heads/main/iblai.env"

Step 2: Mount AgentDatasetsTab

Add Resource is gated on the RBAC grant /mentors/<agent db id>/documents/#create, read from the provider's rbacPermissions -- even with enableRBAC={false}. Without the grant the table renders but the button never shows. Load the grants for the agent and pass them to a nested provider:

// app/(app)/agents/[mentorId]/datasets/page.tsx
"use client";

import { useEffect, useState } from "react";
import {
  AgentDatasetsTab,
  AgentSettingsProvider,
  useAgentSettings,
} from "@iblai/iblai-js/web-containers/next";
import {
  useGetMentorSettingsQuery,
  useGetRbacPermissionsMutation,
} from "@iblai/iblai-js/data-layer";

export default function AgentDatasetsPage() {
  const settings = useAgentSettings();
  const { tenantKey, mentorId, username } = settings;
  const [grants, setGrants] = useState<object>({});
  const [getRbacPermissions] = useGetRbacPermissionsMutation();
  const { data } = useGetMentorSettingsQuery({
    mentor: mentorId,
    org: tenantKey,
    // @ts-expect-error userId is accepted at runtime
    userId: username,
  });
  const mentorDbId = (data as { mentor_id?: number } | undefined)?.mentor_id;

  useEffect(() => {
    if (!mentorDbId) return;
    getRbacPermissions({
      requestBody: {
        platform_key: tenantKey,
        resources: [`/mentors/${mentorDbId}/documents/`],
      },
    })
      .unwrap()
      .then((permissions) => setGrants({ ...permissions }))
      .catch(() => {});
  }, [mentorDbId, tenantKey, getRbacPermissions]);

  return (
    <div className="flex h-full flex-col bg-white">
      <AgentSettingsProvider {...settings} rbacPermissions={grants}>
        <AgentDatasetsTab maxUploadSizeMb={50} />
      </AgentSettingsProvider>
    </div>
  );
}

The grant path uses the agent's numeric mentor_id from its settings, not the UUID. If your layout already loads grants into the provider, mount <AgentDatasetsTab /> directly.

Keep page and search in the URL (optional)

By default the tab keeps page and search in local state. To survive reloads and share links, control them:

"use client";

import { useRouter, useSearchParams } from "next/navigation";
import { AgentDatasetsTab } from "@iblai/iblai-js/web-containers/next";

export function UrlSyncedDatasets() {
  const router = useRouter();
  const params = useSearchParams();
  const page = Number(params.get("page") ?? "1") || 1;
  const search = params.get("q") ?? "";

  const replace = (next: Record<string, string | null>) => {
    const sp = new URLSearchParams(params.toString());
    for (const [key, value] of Object.entries(next)) {
      if (value) sp.set(key, value);
      else sp.delete(key);
    }
    router.replace(`?${sp.toString()}`);
  };

  return (
    <AgentDatasetsTab
      page={page}
      search={search}
      onPageChange={(p) => replace({ page: String(p) })}
      onSearchChange={(q) => replace({ q: q || null, page: null })}
    />
  );
}

onSearchChange implies a reset to page 1: drop the page param in it.

Step 3: Customize Labels (Optional)

The tab renders with the default agent-facing copy (AGENT_DATASETS_TAB_LABELS, localized through the SDK's i18n). Pass a partial labels object to change any string:

import { AgentDatasetsTab } from "@iblai/iblai-js/web-containers/next";

<AgentDatasetsTab
  labels={{
    header: { title: "Knowledge base" },
    addResource: { button: "Add source" },
  }}
/>;

Label groups (DatasetsTabLabels): header (title, description), infoBox, search.placeholder, addResource.button, table (the six column headings and emptyState), toasts (updateSuccess, updateError, deleteSuccess, deleteError, trainQueued, retrainSuccess, retrainError), deleteModal, trainOrDeleteModal (including the crawler userAgent* copy), and retrainScheduleModal. The Add Resources dialogs use the SDK's own copy.

Step 4: Use MCP Tools for Customization

get_component_info("AgentDatasetsTab")
get_component_info("AgentSettingsProvider")

<AgentDatasetsTab> Props

Import from @iblai/iblai-js/web-containers/next.

PropTypeRequiredDescription
labelsDeepPartial<DatasetsTabLabels>NoOverride user-visible strings
disabledResourceTypesstring[]NoTile ids to disable (greyed out, still shown) in Add Resources (powerpoint, onedrive, google-drive, dropbox, youtube, url, pdf, docx, excel, csv, github, text, markdown, audio, ...)
maxUploadSizeMbnumberNoUpload size limit for local files
dropboxExtensionsstring[]NoFile extensions the Dropbox picker offers
onSelect(dataset: Dataset) => voidNoPicker mode: called when a row is clicked
selectedDatasetIdstringNoPicker mode: highlight this row
pagenumberNoControlled page (1-based). Omit for internal paging
onPageChange(page: number) => voidNoFired with the requested page when page is controlled
searchstringNoControlled search text. Omit for internal search
onSearchChange(search: string) => voidNoFired with the debounced search; reset the page to 1 here
AddResourceModalComponentType<{ isOpen, onClose, keepParentOpen? }>NoDeprecated. Replaces the built-in Add Resources dialog
PaginationComponentComponentType<{ currentPage, totalPages, onPageChange, disabled }>NoDeprecated. Replaces the built-in pagination

From @iblai/iblai-js/web-containers/next:

  • AGENT_DATASETS_TAB_LABELS -- the default label bundle.
  • AgentDatasetsTabProps, DatasetsTabLabels, Dataset -- types.

How it saves

ActionRequest
LoadGET documents/pathways/{uuid}/?limit=5&offset=…&search=…
Add a resourcePOST documents/train/ (multipart/form-data, pathway = agent UUID, type per source)
Training switch off / onPUT documents/{id}/ with train: false / train: true (plus crawler_extra_headers when a User-Agent is set)
Visibility (eye icon)PUT documents/{id}/ with access: "public" or "private"
Schedule RetrainingPOST documents/{id}/settings/ with retrain_interval_days
DeleteDELETE documents/{id}/

All paths sit under /api/ai-index/orgs/{org}/users/{username}/.

Platform data

HookPurpose
useGetTrainingDocumentsQueryThe paged document list
useEditTrainingDocumentMutationTrain, untrain, visibility
useGetMentorSettingsQueryThe agent's mentor_id for the RBAC grant

REST twin: /iblai-api-agent-dataset.

Step 5: Verify

Run /iblai-vibe-ops-test before telling the user the work is ready, and give every page, control and state this skill added its own checkpoint — one Playwright test titled <ID> · … in e2e/journeys/, listed in e2e/coverage.json; pnpm e2e:coverage must pass:

  1. pnpm build -- must pass with zero errors.
  2. pnpm test -- vitest must pass.
  3. Touch test /agents/<uuid>/datasets in the browser as /iblai-vibe-ops-test says: the table renders and Add Resource shows; add a URL, wait for its switch to turn on, then switch it off and Delete it; read the console; check the phone width.

Important Notes

  • Per agent, not per user: every trained document feeds every chat with the agent.
  • No Add Resource button? The grant is missing: load /mentors/<mentor_id>/documents/ permissions (Step 2).
  • Shared provider: mount AgentSettingsProvider once at the layout level (/iblai-vibe-agent §1); the nested provider in Step 2 only adds grants.
  • Peer deps: sonner and @iblai/iblai-web-mentor (pnpm add sonner @iblai/iblai-web-mentor).
  • Brand guidelines: BRAND.md

Copyright © ibl.ai | support@iblai.zendesk.com