runbios-sdk 0.2.6 → 0.2.7-dev.205

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -320,8 +320,14 @@ const job = await client.training.create(request);
320
320
  const jobs = await client.training.list({ status: 'running' });
321
321
  const page = await client.training.listPage({ limit: 50, offset: 0 });
322
322
 
323
- // Get metrics
324
- const metrics = await client.training.getMetrics('job_abc123');
323
+ // Get a compact, model-readable report (metric averages/ranges/best steps and GPU averages/peaks)
324
+ const report = await client.training.getMetrics('job_abc123', { view: 'summary' });
325
+ for (const metric of report.metric_summaries ?? []) {
326
+ console.log(metric.label, metric.latest, metric.average, metric.best);
327
+ }
328
+
329
+ // Request a bounded curve only when you need its shape
330
+ const metrics = await client.training.getMetrics('job_abc123', { view: 'series', maxPoints: 200 });
325
331
  for (const point of metrics.metrics) console.log(point.step, point.loss);
326
332
 
327
333
  // Get checkpoints
package/dist/client.js CHANGED
@@ -340,7 +340,7 @@ export class HttpClient {
340
340
  constructor(config) {
341
341
  // Default host stays api.runbios.ai for now; cutover to api.runbios.ai is
342
342
  // planned once its DNS exists.
343
- this.baseUrl = (config.baseUrl || envBaseUrl() || 'https://api.runbios.ai').replace(/\/+$/, '');
343
+ this.baseUrl = (config.baseUrl || envBaseUrl() || 'https://api-dev.runbios.ai').replace(/\/+$/, '');
344
344
  this.apiKey = config.apiKey ?? envApiKey();
345
345
  this.accessToken = config.accessToken;
346
346
  this.orgId = config.orgId;
package/dist/index.d.ts CHANGED
@@ -36,7 +36,7 @@ import { Loop } from './resources/loop.js';
36
36
  * SDK version. Sent as part of the User-Agent header.
37
37
  * Must match package.json "version" -- enforced by a contract test.
38
38
  */
39
- export declare const VERSION = "0.2.6";
39
+ export declare const VERSION = "0.2.7-dev.205";
40
40
  export declare class RunBiOS {
41
41
  /** Search models, fetch configs, check adapter compatibility. */
42
42
  readonly models: Models;
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ import { Loop } from './resources/loop.js';
36
36
  * SDK version. Sent as part of the User-Agent header.
37
37
  * Must match package.json "version" -- enforced by a contract test.
38
38
  */
39
- export const VERSION = '0.2.6';
39
+ export const VERSION = '0.2.7-dev.205';
40
40
  export class RunBiOS {
41
41
  /** Search models, fetch configs, check adapter compatibility. */
42
42
  models;
@@ -1,5 +1,5 @@
1
1
  import type { HttpClient } from '../client.js';
2
- import type { Dataset, DatasetListParams, DatasetListResponse, DatasetUploadParams, DatasetPreview, DatasetPreviewParams, DatasetImportHFParams, DatasetRegisterHFParams, DatasetHubSearchParams, DatasetHubPreviewParams, DatasetValidation, DatasetFormatSpecs, DatasetStorageUsage } from '../types.js';
2
+ import type { Dataset, DatasetListParams, DatasetListResponse, DatasetUploadParams, DatasetPreview, DatasetPreviewParams, DatasetImportHFParams, DatasetRegisterHFParams, DatasetRegisterLoopParams, DatasetHubSearchParams, DatasetHubPreviewParams, DatasetValidation, DatasetFormatSpecs, DatasetStorageUsage } from '../types.js';
3
3
  /**
4
4
  * Manage training datasets -- upload files, import from HuggingFace,
5
5
  * preview contents, and manage storage.
@@ -9,7 +9,7 @@ export declare class Datasets {
9
9
  /** @internal */
10
10
  constructor(_http: HttpClient);
11
11
  /**
12
- * List datasets in the current organization/workspace.
12
+ * List ready datasets by default. Request processing, failed, or all explicitly.
13
13
  *
14
14
  * @example
15
15
  * ```ts
@@ -118,6 +118,30 @@ export declare class Datasets {
118
118
  * ```
119
119
  */
120
120
  registerHuggingFace(params: DatasetRegisterHFParams | Record<string, unknown>): Promise<Dataset>;
121
+ /**
122
+ * Turn a curated Conscious Loop set into a dataset training can use.
123
+ *
124
+ * Without this, using a loop set from code meant downloading the JSONL and
125
+ * uploading it again as an unrelated dataset. That works, and it throws away
126
+ * the one thing that made the set worth having: which conversations, which
127
+ * verdicts and which judges produced it. Registering keeps that link.
128
+ *
129
+ * The set is then put through the SAME validation every uploaded dataset
130
+ * gets, so it comes back `processing` rather than ready -- poll
131
+ * {@link getStatus} before training on it. Registering the same set and split
132
+ * twice is refused rather than billed twice, and an empty set is refused
133
+ * rather than registered as something that would fail inside the trainer.
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * const train = await client.datasets.registerLoop({
138
+ * loopDatasetId: 'd244894c-7ab4-4b3d-bfda-e0bb4c563ceb',
139
+ * name: 'extract-v1 distill SFT',
140
+ * split: 'train',
141
+ * });
142
+ * ```
143
+ */
144
+ registerLoop(params: DatasetRegisterLoopParams | Record<string, unknown>): Promise<Dataset>;
121
145
  /**
122
146
  * Get the processing status of a dataset.
123
147
  *
@@ -25,7 +25,7 @@ export class Datasets {
25
25
  this._http = _http;
26
26
  }
27
27
  /**
28
- * List datasets in the current organization/workspace.
28
+ * List ready datasets by default. Request processing, failed, or all explicitly.
29
29
  *
30
30
  * @example
31
31
  * ```ts
@@ -43,8 +43,7 @@ export class Datasets {
43
43
  q.set('workspace_id', params.workspaceId);
44
44
  if (params.datasetType)
45
45
  q.set('dataset_type', params.datasetType);
46
- if (params.status)
47
- q.set('status', params.status);
46
+ q.set('status', params.status ?? 'ready');
48
47
  if (params.query)
49
48
  q.set('q', params.query);
50
49
  if (params.sort)
@@ -260,6 +259,45 @@ export class Datasets {
260
259
  });
261
260
  return normalizeDataset(result);
262
261
  }
262
+ /**
263
+ * Turn a curated Conscious Loop set into a dataset training can use.
264
+ *
265
+ * Without this, using a loop set from code meant downloading the JSONL and
266
+ * uploading it again as an unrelated dataset. That works, and it throws away
267
+ * the one thing that made the set worth having: which conversations, which
268
+ * verdicts and which judges produced it. Registering keeps that link.
269
+ *
270
+ * The set is then put through the SAME validation every uploaded dataset
271
+ * gets, so it comes back `processing` rather than ready -- poll
272
+ * {@link getStatus} before training on it. Registering the same set and split
273
+ * twice is refused rather than billed twice, and an empty set is refused
274
+ * rather than registered as something that would fail inside the trainer.
275
+ *
276
+ * @example
277
+ * ```ts
278
+ * const train = await client.datasets.registerLoop({
279
+ * loopDatasetId: 'd244894c-7ab4-4b3d-bfda-e0bb4c563ceb',
280
+ * name: 'extract-v1 distill SFT',
281
+ * split: 'train',
282
+ * });
283
+ * ```
284
+ */
285
+ async registerLoop(params) {
286
+ const raw = params;
287
+ const loopDatasetId = String(raw.loopDatasetId || raw.loop_dataset_id || '');
288
+ if (!loopDatasetId)
289
+ throw new Error('RunBiOS: loopDatasetId is required');
290
+ const workspaceId = String(raw.workspaceId || raw.workspace_id || '')
291
+ || this._http.workspaceId
292
+ || await this._http.resolveWorkspaceId();
293
+ const result = await this._http.fetchPost('/api/datasets/register-loop', {
294
+ loop_dataset_id: loopDatasetId,
295
+ workspace_id: workspaceId,
296
+ split: raw.split ?? 'all',
297
+ ...(raw.name !== undefined && { name: raw.name }),
298
+ });
299
+ return normalizeDataset(result);
300
+ }
263
301
  /**
264
302
  * Get the processing status of a dataset.
265
303
  *
@@ -326,7 +326,7 @@ export class Inference {
326
326
  this.key = config.inferenceKey || envInferenceKey() || envApiKey();
327
327
  // Same default host as HttpClient (api.runbios.ai); api.runbios.ai cutover
328
328
  // is planned once its DNS exists — update both call sites together.
329
- this.baseUrl = (config.baseUrl || envBaseUrl() || 'https://api.runbios.ai').replace(/\/+$/, '');
329
+ this.baseUrl = (config.baseUrl || envBaseUrl() || 'https://api-dev.runbios.ai').replace(/\/+$/, '');
330
330
  this.timeout = config.timeout ?? 900_000;
331
331
  this._http = http;
332
332
  }
@@ -1,5 +1,5 @@
1
1
  import type { HttpClient } from '../client.js';
2
- import type { TrainingCreateParams, TrainingListParams, TrainingJob, TrainingListResponse, TrainingMetrics, TrainingCheckpoint, TrainingLogs, TrainingStopResponse, TrainingResumeResponse, TrainingPreflightResponse, TrainingRecommendParams, TrainingAdvisorVerdict, TrainingCapabilities } from '../types.js';
2
+ import type { TrainingCreateParams, TrainingListParams, TrainingJob, TrainingListResponse, TrainingMetrics, TrainingMetricsOptions, TrainingCheckpoint, TrainingLogs, TrainingStopResponse, TrainingResumeResponse, TrainingPreflightResponse, TrainingRecommendParams, TrainingAdvisorVerdict, TrainingCapabilities } from '../types.js';
3
3
  /**
4
4
  * Create, monitor, and manage fine-tuning training jobs.
5
5
  */
@@ -93,15 +93,17 @@ export declare class Training {
93
93
  * Get training metrics (loss curves, learning rate, throughput) for a job.
94
94
  *
95
95
  * @param id - Training job ID.
96
+ * @param options - Choose semantic summaries, a bounded series, or the backward-compatible full rows.
96
97
  *
97
98
  * @example
98
99
  * ```ts
99
- * const metrics = await client.training.getMetrics('job_abc123');
100
- * console.log(`Current loss: ${metrics.metrics.at(-1)?.loss}`);
101
- * console.log(`${metrics.metrics.length} metric points`);
100
+ * const report = await client.training.getMetrics('job_abc123', { view: 'summary' });
101
+ * console.log(report.metric_summaries?.find(metric => metric.key === 'loss'));
102
+ * const curve = await client.training.getMetrics('job_abc123', { view: 'series', maxPoints: 200 });
103
+ * console.log(`${curve.metrics.length} bounded metric points`);
102
104
  * ```
103
105
  */
104
- getMetrics(id: string): Promise<TrainingMetrics>;
106
+ getMetrics(id: string, options?: TrainingMetricsOptions): Promise<TrainingMetrics>;
105
107
  /**
106
108
  * List checkpoints saved during training.
107
109
  *
@@ -343,20 +343,38 @@ export class Training {
343
343
  * Get training metrics (loss curves, learning rate, throughput) for a job.
344
344
  *
345
345
  * @param id - Training job ID.
346
+ * @param options - Choose semantic summaries, a bounded series, or the backward-compatible full rows.
346
347
  *
347
348
  * @example
348
349
  * ```ts
349
- * const metrics = await client.training.getMetrics('job_abc123');
350
- * console.log(`Current loss: ${metrics.metrics.at(-1)?.loss}`);
351
- * console.log(`${metrics.metrics.length} metric points`);
350
+ * const report = await client.training.getMetrics('job_abc123', { view: 'summary' });
351
+ * console.log(report.metric_summaries?.find(metric => metric.key === 'loss'));
352
+ * const curve = await client.training.getMetrics('job_abc123', { view: 'series', maxPoints: 200 });
353
+ * console.log(`${curve.metrics.length} bounded metric points`);
352
354
  * ```
353
355
  */
354
- async getMetrics(id) {
355
- const result = await this._http.fetchGet(`/api/training/jobs/${encodeURIComponent(id)}/metrics`);
356
+ async getMetrics(id, options = {}) {
357
+ if (options.maxPoints !== undefined && (!Number.isInteger(options.maxPoints) || options.maxPoints < 1 || options.maxPoints > 1000)) {
358
+ throw new Error('RunBiOS: maxPoints must be an integer between 1 and 1000');
359
+ }
360
+ const query = new URLSearchParams();
361
+ if (options.view)
362
+ query.set('view', options.view);
363
+ if (options.maxPoints !== undefined)
364
+ query.set('max_points', String(options.maxPoints));
365
+ const encodedQuery = query.toString();
366
+ const suffix = encodedQuery ? `?${encodedQuery}` : '';
367
+ const result = await this._http.fetchGet(`/api/training/jobs/${encodeURIComponent(id)}/metrics${suffix}`);
356
368
  const metrics = Array.isArray(result.metrics)
357
369
  ? result.metrics
358
370
  : Array.isArray(result.steps) ? result.steps : [];
359
- return { ...result, metrics, graph_configs: result.graph_configs || [], steps: metrics };
371
+ return {
372
+ ...result,
373
+ metrics,
374
+ graph_configs: result.graph_configs || [],
375
+ metric_summaries: result.metric_summaries || [],
376
+ steps: metrics,
377
+ };
360
378
  }
361
379
  /**
362
380
  * List checkpoints saved during training.
package/dist/types.d.ts CHANGED
@@ -8,13 +8,13 @@ export interface BiOSConfig {
8
8
  orgId?: string;
9
9
  /** Workspace ID. Optional when using API keys (resolved from the key). Can override for multi-workspace keys. */
10
10
  workspaceId?: string;
11
- /** Base URL for the API. Falls back to the RUNBIOS_BASE_URL environment variable (legacy: BIOS_BASE_URL), then the canonical https://api.runbios.ai hostname. */
11
+ /** Base URL for the API. Falls back to the RUNBIOS_BASE_URL environment variable (legacy: BIOS_BASE_URL), then the canonical https://api-dev.runbios.ai hostname. */
12
12
  baseUrl?: string;
13
13
  /** Request timeout in milliseconds. Defaults to 30000. */
14
14
  timeout?: number;
15
15
  /** Default per-deployment inference key. Can be overridden per inference call. */
16
16
  inferenceKey?: string;
17
- /** Inference base URL. Defaults to baseUrl, then https://api.runbios.ai. */
17
+ /** Inference base URL. Defaults to baseUrl, then https://api-dev.runbios.ai. */
18
18
  inferenceBaseUrl?: string;
19
19
  /** End-to-end inference timeout in milliseconds. Defaults to 15 minutes. */
20
20
  inferenceTimeout?: number;
@@ -347,8 +347,8 @@ export interface DatasetListParams {
347
347
  workspaceId?: string;
348
348
  /** Filter by dataset type. */
349
349
  datasetType?: string;
350
- /** Lifecycle bucket: ready, processing, or failed. */
351
- status?: 'ready' | 'processing' | 'failed';
350
+ /** Lifecycle bucket. Defaults to ready; all is an explicit diagnostic view. */
351
+ status?: 'ready' | 'processing' | 'failed' | 'all';
352
352
  /** Case-insensitive name search. */
353
353
  query?: string;
354
354
  /** Server-side ordering. */
@@ -444,6 +444,21 @@ export interface DatasetRegisterHFParams {
444
444
  columnMapping?: Record<string, string>;
445
445
  importMode?: 'auto' | 'reference' | 'materialize';
446
446
  }
447
+ /** Parameters for registering a curated Conscious Loop set as a dataset. */
448
+ export interface DatasetRegisterLoopParams {
449
+ /** The Conscious Loop dataset to register. */
450
+ loopDatasetId: string;
451
+ /** Defaults to `loop-<first 8 of the loop id>`. */
452
+ name?: string;
453
+ /**
454
+ * Which rows to take. Defaults to `all`, because the loop already split the
455
+ * set by TIME and re-splitting a deliberate split throws that decision away.
456
+ * Register `train` and `holdout` separately to score a training job against
457
+ * the loop's own held-back rows; both can exist at once.
458
+ */
459
+ split?: 'all' | 'train' | 'holdout';
460
+ workspaceId?: string;
461
+ }
447
462
  /** Parameters for searching HuggingFace Hub datasets. */
448
463
  export interface DatasetHubSearchParams {
449
464
  /** Search query. */
@@ -822,13 +837,93 @@ export interface TrainingResourceMetrics {
822
837
  disk_total_gib: number | null;
823
838
  gpus: TrainingDeviceMetrics[];
824
839
  }
840
+ export interface TrainingResourceValueSummary {
841
+ average: number;
842
+ peak: number;
843
+ samples: number;
844
+ }
845
+ export interface TrainingDeviceResourceSummary {
846
+ memory_used_mib: TrainingResourceValueSummary | null;
847
+ memory_total_mib: number | null;
848
+ utilization_pct: TrainingResourceValueSummary | null;
849
+ temperature_c: TrainingResourceValueSummary | null;
850
+ }
851
+ export interface TrainingResourceSummary {
852
+ scope: 'attempt';
853
+ aggregation: 'sample_mean';
854
+ sample_count: number;
855
+ first_sampled_at: string | null;
856
+ last_sampled_at: string | null;
857
+ gpu_count: number | null;
858
+ gpu_memory_used_mib: TrainingResourceValueSummary | null;
859
+ gpu_memory_total_mib: number | null;
860
+ gpu_utilization_pct: TrainingResourceValueSummary | null;
861
+ gpu_temperature_c: TrainingResourceValueSummary | null;
862
+ host_ram_used_gib: TrainingResourceValueSummary | null;
863
+ host_ram_limit_gib: number | null;
864
+ host_ram_pct: TrainingResourceValueSummary | null;
865
+ host_cpu_usage_pct: TrainingResourceValueSummary | null;
866
+ host_cpu_limit_cores: number | null;
867
+ disk_used_gib: TrainingResourceValueSummary | null;
868
+ disk_total_gib: number | null;
869
+ gpus: TrainingDeviceResourceSummary[];
870
+ }
871
+ export interface TrainingMetricSummary {
872
+ key: string;
873
+ label: string;
874
+ unit: string;
875
+ goal: 'minimize' | 'maximize' | 'schedule' | 'progress' | 'observe' | string;
876
+ points: number;
877
+ first: number;
878
+ latest: number;
879
+ minimum: number;
880
+ maximum: number;
881
+ average: number;
882
+ change: number;
883
+ change_percent?: number;
884
+ first_step: number;
885
+ last_step: number;
886
+ best?: number;
887
+ best_step?: number;
888
+ }
889
+ export interface TrainingSeriesMeta {
890
+ view: 'full' | 'series' | 'summary';
891
+ x_axis: 'step';
892
+ included: boolean;
893
+ total_points: number;
894
+ returned_points: number;
895
+ downsampled: boolean;
896
+ sampling: 'none' | 'uniform';
897
+ }
898
+ export interface TrainingMetricsOptions {
899
+ view?: 'full' | 'series' | 'summary';
900
+ maxPoints?: number;
901
+ }
902
+ export interface TrainingMetricsRunContext {
903
+ status: string;
904
+ training_method?: string | null;
905
+ rlhf_type?: string | null;
906
+ train_type: string;
907
+ model_id: string;
908
+ model_revision: string;
909
+ current_step: number;
910
+ total_steps: number;
911
+ gpu_type: string;
912
+ gpu_count: number;
913
+ parameters: Record<string, unknown>;
914
+ omitted_parameter_keys: string[];
915
+ }
825
916
  /** Training metrics for a job. */
826
917
  export interface TrainingMetrics {
827
918
  metrics: MetricPoint[];
828
919
  training_method?: string | null;
829
920
  rlhf_type?: string | null;
830
921
  graph_configs: MetricGraphConfig[];
922
+ metric_summaries?: TrainingMetricSummary[];
831
923
  resource_metrics?: TrainingResourceMetrics | null;
924
+ resource_summary?: TrainingResourceSummary | null;
925
+ series_meta?: TrainingSeriesMeta;
926
+ run_context?: TrainingMetricsRunContext;
832
927
  /** @deprecated Use metrics. Populated as a compatibility alias. */
833
928
  steps?: MetricPoint[];
834
929
  }
@@ -852,6 +947,8 @@ export interface MetricGraphConfig {
852
947
  key: string;
853
948
  label: string;
854
949
  color: string;
950
+ unit?: string;
951
+ goal?: string;
855
952
  }
856
953
  /** A training checkpoint. */
857
954
  export interface TrainingCheckpoint {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runbios-sdk",
3
- "version": "0.2.6",
3
+ "version": "0.2.7-dev.205",
4
4
  "description": "Official TypeScript SDK for the Run BiOS training and deployment platform API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",