Project Files
dist / dataset.d.ts
/**
* @file dataset.ts
* @description HuggingFace Datasets Server REST API client.
*
* Uses the HF Datasets Server (datasets-server.huggingface.co) to discover
* dataset configs/splits and fetch sample rows. Uses only Node.js built-in
* fetch() — no additional npm dependencies.
*
* Endpoints used:
* - GET /splits → discover available configs and splits
* - GET /rows → fetch consecutive rows by offset/length
* - GET /search → BM25 full-text search across rows
*
* @module dataset
*/
import type { LoadDatasetParams, LoadDatasetResult } from "./types";
interface SplitsResponseSplit {
readonly dataset: string;
readonly config: string;
readonly split: string;
}
interface SplitsResponse {
readonly splits: readonly SplitsResponseSplit[];
}
interface RowEntry {
readonly row_idx: number;
readonly row: Record<string, unknown>;
readonly truncated_cells: readonly string[];
}
/**
* Fetch available configs and splits for a given dataset.
*
* @param dataset - HF dataset name (e.g. "squad", "ibm/duorc").
* @param signal - Optional AbortSignal.
* @returns The parsed splits response.
*/
export declare function fetchSplits(dataset: string, signal?: AbortSignal): Promise<SplitsResponse>;
/**
* Fetch a consecutive block of rows from a dataset split.
*
* @param dataset - HF dataset name.
* @param config - Dataset config/subset name.
* @param split - Split name ("train", "test", "validation").
* @param offset - Row offset to start from (0-based).
* @param length - Number of rows to fetch (max 100).
* @param signal - Optional AbortSignal.
* @returns An object with the rows array and total row count.
*/
export declare function fetchRows(dataset: string, config: string, split: string, offset: number, length: number, signal?: AbortSignal): Promise<{
readonly rows: readonly RowEntry[];
readonly totalRows: number;
}>;
/**
* BM25 full-text search across rows in a dataset split.
*
* @param dataset - HF dataset name.
* @param config - Dataset config/subset name.
* @param split - Split name.
* @param query - Search query text.
* @param length - Number of results to return (max 100).
* @param signal - Optional AbortSignal.
* @returns An object with matching rows and an estimate of total matches.
*/
export declare function searchRows(dataset: string, config: string, split: string, query: string, length: number, signal?: AbortSignal): Promise<{
readonly rows: readonly RowEntry[];
readonly totalRows: number;
}>;
/**
* Main entry point: load samples from a HuggingFace dataset.
*
* Orchestration flow:
* 1. If no config was provided, call `/splits` to discover available configs.
* - Exactly one config → use it automatically.
* - Multiple configs → throw with a message listing choices.
* - No configs → throw with available splits info.
* 2. If a query is provided, call `/search`; otherwise call `/rows`.
* 3. Format the returned rows into the standard result structure.
*
* @param params - LoadDatasetParams from the tool invocation.
* @param signal - Optional AbortSignal from LM Studio for cancellation.
* @returns A LoadDatasetResult with samples, metadata, and formatted text.
*/
export declare function loadDataset(params: LoadDatasetParams, signal?: AbortSignal): Promise<LoadDatasetResult>;
export {};
//# sourceMappingURL=dataset.d.ts.map