runbios-sdk 0.2.14-dev.244 → 0.2.14-dev.246
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 +28 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/resources/inference.d.ts +4 -1
- package/dist/resources/inference.js +41 -1
- package/dist/resources/models.d.ts +5 -1
- package/dist/resources/models.js +26 -0
- package/dist/types.d.ts +16 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -251,6 +251,34 @@ const compat = await client.models.getAdapterCompatibility({
|
|
|
251
251
|
});
|
|
252
252
|
```
|
|
253
253
|
|
|
254
|
+
#### Models this credential can invoke
|
|
255
|
+
|
|
256
|
+
`client.models.list()` reads the unified `GET /v1/models` roster with the SDK's
|
|
257
|
+
platform API key: serverless pool models and workspace deployments appear only
|
|
258
|
+
when that key's scopes permit them. `client.models.retrieve(id)` uses the same
|
|
259
|
+
scope and workspace boundary. The trainable `models.search()` / `models.get()`
|
|
260
|
+
registry above is separate; a registry result does not guarantee that this
|
|
261
|
+
credential can invoke it.
|
|
262
|
+
|
|
263
|
+
When a dedicated inference key is configured separately, use
|
|
264
|
+
`client.inference.listModels()` and `client.inference.retrieveModel(id)`: they
|
|
265
|
+
use the exact inference key and base URL selected for chat completions. Model
|
|
266
|
+
ids containing `author/name` are encoded safely. A partially readable list
|
|
267
|
+
includes `usf_unreachable_sources`; an unavailable source is not proof there
|
|
268
|
+
are no models in it. Neither SDK retries a failed inference request for you.
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
const available = await client.inference.listModels();
|
|
272
|
+
for (const model of available.data) console.log(model.id);
|
|
273
|
+
if (available.usf_unreachable_sources?.length) {
|
|
274
|
+
console.log('Some model sources were unreachable; retry discovery before concluding they are empty.');
|
|
275
|
+
}
|
|
276
|
+
if (available.data.length) {
|
|
277
|
+
const detail = await client.inference.retrieveModel(available.data[0].id);
|
|
278
|
+
console.log(detail.id);
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
254
282
|
### Datasets
|
|
255
283
|
|
|
256
284
|
```typescript
|
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.14-dev.
|
|
39
|
+
export declare const VERSION = "0.2.14-dev.246";
|
|
40
40
|
export declare class RunBiOS {
|
|
41
41
|
/** Search models, fetch configs, check adapter compatibility. */
|
|
42
42
|
readonly models: Models;
|
|
@@ -75,7 +75,7 @@ export { Training } from './resources/training.js';
|
|
|
75
75
|
export { Wallet } from './resources/wallet.js';
|
|
76
76
|
export { GPU, type GPURecommendation } from './resources/gpu.js';
|
|
77
77
|
export { Inference, validateChatRequest, parseSSE, buildInferenceRequest, contextSizingBasis, type ContextSizingBasis, CONTEXT_DEFAULT_CEILING, CONTEXT_EDITABLE_FLOOR, type ChatMessage, type FunctionTool, type ChatCompletionParams, type ChatCompletionResponse, type ChatCompletionChunk, type ServerlessUsageWindow, type ServerlessTimeseriesMetric, type ServerlessWorkspaceLimits, type ServerlessUsageEnvelope, type ServerlessUsageOverviewResponse, type ServerlessUsageRowsResponse, type ServerlessUsageTimeseriesResponse, type ServerlessUsageDailyResponse, type ServerlessSavingsTotals, type ServerlessSavingsPeriod, type ServerlessUsageSavingsResponse, } from './resources/inference.js';
|
|
78
|
-
export type { BiOSConfig, PaginatedResponse, ApiErrorBody, AvailableGpuAlternative, CapacityMinimumRequirement, InferenceBookingAccepted, Model, ModelSearchParams, ModelSearchResponse, ModelDetailResponse, ModelConfig, Dataset, DatasetListParams, DatasetListResponse, DatasetUploadParams, DatasetPreview, DatasetPreviewParams, DatasetImportHFParams, DatasetRegisterHFParams, DatasetHubSearchParams, DatasetHubPreviewParams, DatasetValidation, DatasetFormatVariant, DatasetFormatSpec, DatasetFormatSpecs, DatasetStorageUsage, TrainingMethod, RLHFAlgorithm, AdapterType, TrainingJobStatus, TrainingStatusFilter, TrainingCreateParams, TrainingListParams, TrainingListResponse, TrainingJob, TrainingMetrics, TrainingResourceMetrics, TrainingDeviceMetrics, MetricPoint, MetricGraphConfig, TrainingCheckpoint, TrainingLogs, TrainingLogEntry, TrainingStopResponse, TrainingResumeResponse, CanonicalTrainingRequest, TrainingPreflightDataset, TrainingPreflightWarning, TrainingPreflightResponse, TrainingCapabilityChoice, TrainingConfigFieldCapability, TrainingCapabilities, GPUChoice, WalletBalance, Transaction, TransactionListResponse, TransactionListParams, GPUInfo, GPUPricingResponse, GPUOptionsParams, TrainingRecommendParams, TrainingAdvisorVerdict, TrainingAdvisorRecommendation, TrainingAdvisorUserShape, TrainingAdvisorJustification, TrainingAdvisorBasis, GPUOption, GPUOptionSuggestion, GPUOptionsResponse, InferenceStatus, InferenceCreateParams, InferenceUpdateParams, InferenceDeployment, InferenceDeploymentSummary, InferenceCreateResponse, InferenceListResponse, InferenceUpdateResponse, InferenceLifecycleResponse, InferenceDeleteResponse, InferenceGPUOptionMarket, InferenceGPUOption, InferenceGPUAlternative, InferenceGPUOptionsParams, InferenceGPUOptionsResponse, InferenceCanonicalRequest, InferencePreflightWarning, InferencePreflightResponse, AdapterCompatibility, AdapterCompatibilityResponse, AdapterCompatibilityParams, SupportedArchitecture, ArchitectureScope, SupportedArchitecturesResponse, ApiKey, ApiKeyScope, ApiKeyIntrospection, Organization, OrgMember, OrgInvite, Workspace, Integration, IntegrationCreateParams, StorageUsage, StorageObject, PromptTokensDetails, ChatCompletionUsage, TrainingCadence, TrainingCombinator, ServingKind, TrainingRulePausedReason, LoopTrainingMethod, TrainType, GradersScope, TrainingTrigger, TrainingRecipe, TrainingRunState, TrainingVerdict, TrainingDecision, NotifyState, EvaluationStatus, EvaluationItemStatus, EvaluationWinner, EvaluationWarningCode, ConsentVia, TrainingToolCall, TrainingMessage, TrainingRuleServing, TrainingGPURung, TrainingRule, TrainingRuleConsent, TrainingRulePreflightRefusal, TrainingRuleKeyRef, TrainingRuleKeyCheck, TrainingRulePreflight, TrainingRuleBuildSpec, TrainingRuleTriggerInput, TrainingRuleTrainingInput, TrainingRuleDeployInput, TrainingRuleMoneyInput, TrainingRuleEvaluationInput, TrainingRulePromotionInput, TrainingRuleAcceptTerms, TrainingRulePreflightRequest, TrainingRuleCreateRequest, TrainingRuleUpdateRequest, TrainingRuleConsentRequest, TrainingRuleListParams, TrainingRunPromoteRequest, TrainingRunRejectRequest, TrainingRunRollbackRequest, TrainingRunCancelRequest, TrainingRunListParams, TrainingRun, TrainingRunSummary, TrainingRunEvent, TrainingRunLinks, TrainingRunActions, EvaluationRef, EvaluationDecoding, EvaluationJudgeDimension, EvaluationDimensionScore, EvaluationGraderScore, EvaluationWarning, EvaluationMargin, JudgeAgreementDimension, JudgeAgreement, Evaluation, EvaluationItemSide, EvaluationItem, EvaluationItemListParams, JudgeAgreementParams, AgentSettings, AgentSettingsRequest, BenchmarkStatus, BenchmarkSourceKind, BenchmarkRunStatus, BenchmarkScoring, BenchmarkDimensionScore, Benchmark, BenchmarkItem, BenchmarkRun, BenchmarkHistoryPoint, BenchmarkSource, BenchmarkCreateParams, BenchmarkListParams, BenchmarkItemListParams, BenchmarkHistoryParams, BenchmarkRetireParams, TrainingRuleBenchmarkRequest, InferenceAlias, InferenceAliasRequest, TrainingRuleListResponse, TrainingRuleResponse, TrainingRuleMutationResponse, TrainingRuleDeleteResponse, TrainingRunListResponse, TrainingRunResponse, TrainingRunActionResponse, EvaluationItemsResponse, AgentSettingsResponse, InferenceAliasListResponse, InferenceAliasResponse, InferenceAliasDeleteResponse, BenchmarkListResponse, BenchmarkItemsResponse, BenchmarkHistoryResponse, TrainingRuleRunRefusalCode, TrainingRuleMonthlyLimitRefusal, LoopDatasetDeleteRefusalCode, PipelineStatus, PipelineRecipeExploration, PipelineActiveRun, PipelineVersion, Pipeline, PipelineListResponse, PipelineResponse, } from './types.js';
|
|
78
|
+
export type { BiOSConfig, PaginatedResponse, ApiErrorBody, AvailableGpuAlternative, CapacityMinimumRequirement, InferenceBookingAccepted, Model, ModelSearchParams, ModelSearchResponse, ModelDetailResponse, InferenceModel, InferenceModelListResponse, ModelConfig, Dataset, DatasetListParams, DatasetListResponse, DatasetUploadParams, DatasetPreview, DatasetPreviewParams, DatasetImportHFParams, DatasetRegisterHFParams, DatasetHubSearchParams, DatasetHubPreviewParams, DatasetValidation, DatasetFormatVariant, DatasetFormatSpec, DatasetFormatSpecs, DatasetStorageUsage, TrainingMethod, RLHFAlgorithm, AdapterType, TrainingJobStatus, TrainingStatusFilter, TrainingCreateParams, TrainingListParams, TrainingListResponse, TrainingJob, TrainingMetrics, TrainingResourceMetrics, TrainingDeviceMetrics, MetricPoint, MetricGraphConfig, TrainingCheckpoint, TrainingLogs, TrainingLogEntry, TrainingStopResponse, TrainingResumeResponse, CanonicalTrainingRequest, TrainingPreflightDataset, TrainingPreflightWarning, TrainingPreflightResponse, TrainingCapabilityChoice, TrainingConfigFieldCapability, TrainingCapabilities, GPUChoice, WalletBalance, Transaction, TransactionListResponse, TransactionListParams, GPUInfo, GPUPricingResponse, GPUOptionsParams, TrainingRecommendParams, TrainingAdvisorVerdict, TrainingAdvisorRecommendation, TrainingAdvisorUserShape, TrainingAdvisorJustification, TrainingAdvisorBasis, GPUOption, GPUOptionSuggestion, GPUOptionsResponse, InferenceStatus, InferenceCreateParams, InferenceUpdateParams, InferenceDeployment, InferenceDeploymentSummary, InferenceCreateResponse, InferenceListResponse, InferenceUpdateResponse, InferenceLifecycleResponse, InferenceDeleteResponse, InferenceGPUOptionMarket, InferenceGPUOption, InferenceGPUAlternative, InferenceGPUOptionsParams, InferenceGPUOptionsResponse, InferenceCanonicalRequest, InferencePreflightWarning, InferencePreflightResponse, AdapterCompatibility, AdapterCompatibilityResponse, AdapterCompatibilityParams, SupportedArchitecture, ArchitectureScope, SupportedArchitecturesResponse, ApiKey, ApiKeyScope, ApiKeyIntrospection, Organization, OrgMember, OrgInvite, Workspace, Integration, IntegrationCreateParams, StorageUsage, StorageObject, PromptTokensDetails, ChatCompletionUsage, TrainingCadence, TrainingCombinator, ServingKind, TrainingRulePausedReason, LoopTrainingMethod, TrainType, GradersScope, TrainingTrigger, TrainingRecipe, TrainingRunState, TrainingVerdict, TrainingDecision, NotifyState, EvaluationStatus, EvaluationItemStatus, EvaluationWinner, EvaluationWarningCode, ConsentVia, TrainingToolCall, TrainingMessage, TrainingRuleServing, TrainingGPURung, TrainingRule, TrainingRuleConsent, TrainingRulePreflightRefusal, TrainingRuleKeyRef, TrainingRuleKeyCheck, TrainingRulePreflight, TrainingRuleBuildSpec, TrainingRuleTriggerInput, TrainingRuleTrainingInput, TrainingRuleDeployInput, TrainingRuleMoneyInput, TrainingRuleEvaluationInput, TrainingRulePromotionInput, TrainingRuleAcceptTerms, TrainingRulePreflightRequest, TrainingRuleCreateRequest, TrainingRuleUpdateRequest, TrainingRuleConsentRequest, TrainingRuleListParams, TrainingRunPromoteRequest, TrainingRunRejectRequest, TrainingRunRollbackRequest, TrainingRunCancelRequest, TrainingRunListParams, TrainingRun, TrainingRunSummary, TrainingRunEvent, TrainingRunLinks, TrainingRunActions, EvaluationRef, EvaluationDecoding, EvaluationJudgeDimension, EvaluationDimensionScore, EvaluationGraderScore, EvaluationWarning, EvaluationMargin, JudgeAgreementDimension, JudgeAgreement, Evaluation, EvaluationItemSide, EvaluationItem, EvaluationItemListParams, JudgeAgreementParams, AgentSettings, AgentSettingsRequest, BenchmarkStatus, BenchmarkSourceKind, BenchmarkRunStatus, BenchmarkScoring, BenchmarkDimensionScore, Benchmark, BenchmarkItem, BenchmarkRun, BenchmarkHistoryPoint, BenchmarkSource, BenchmarkCreateParams, BenchmarkListParams, BenchmarkItemListParams, BenchmarkHistoryParams, BenchmarkRetireParams, TrainingRuleBenchmarkRequest, InferenceAlias, InferenceAliasRequest, TrainingRuleListResponse, TrainingRuleResponse, TrainingRuleMutationResponse, TrainingRuleDeleteResponse, TrainingRunListResponse, TrainingRunResponse, TrainingRunActionResponse, EvaluationItemsResponse, AgentSettingsResponse, InferenceAliasListResponse, InferenceAliasResponse, InferenceAliasDeleteResponse, BenchmarkListResponse, BenchmarkItemsResponse, BenchmarkHistoryResponse, TrainingRuleRunRefusalCode, TrainingRuleMonthlyLimitRefusal, LoopDatasetDeleteRefusalCode, PipelineStatus, PipelineRecipeExploration, PipelineActiveRun, PipelineVersion, Pipeline, PipelineListResponse, PipelineResponse, } from './types.js';
|
|
79
79
|
/** The closed set of run states a training run never leaves. */
|
|
80
80
|
export { TERMINAL_RUN_STATES } from './types.js';
|
|
81
81
|
/** The most versions a pipeline may be set to make. */
|
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.14-dev.
|
|
39
|
+
export const VERSION = '0.2.14-dev.246';
|
|
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 { InferenceDeployment, InferenceDeploymentSummary, InferenceBookingAccepted, InferenceCreateParams, InferenceCreateResponse, InferenceDeleteResponse, InferenceGPUOptionsParams, InferenceGPUOptionsResponse, InferenceLifecycleResponse, InferenceListParams, InferenceListResponse, InferenceNotificationListResponse, InferencePreflightResponse, InferenceUpdateResponse, InferenceUpdateParams, InferenceAlias, InferenceAliasRequest, InferenceAliasDeleteResponse } from '../types.js';
|
|
2
|
+
import type { InferenceDeployment, InferenceDeploymentSummary, InferenceModel, InferenceModelListResponse, InferenceBookingAccepted, InferenceCreateParams, InferenceCreateResponse, InferenceDeleteResponse, InferenceGPUOptionsParams, InferenceGPUOptionsResponse, InferenceLifecycleResponse, InferenceListParams, InferenceListResponse, InferenceNotificationListResponse, InferencePreflightResponse, InferenceUpdateResponse, InferenceUpdateParams, InferenceAlias, InferenceAliasRequest, InferenceAliasDeleteResponse } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Serving context-length policy, owned and enforced by the server. Mirrored
|
|
5
5
|
* here for documentation only -- never to pre-empt a server verdict.
|
|
@@ -330,6 +330,9 @@ export declare class Inference {
|
|
|
330
330
|
getGPUOptions(params: InferenceGPUOptionsParams): Promise<InferenceGPUOptionsResponse>;
|
|
331
331
|
private prepare;
|
|
332
332
|
private abortContext;
|
|
333
|
+
private modelRead;
|
|
334
|
+
listModels(inferenceKey?: string): Promise<InferenceModelListResponse>;
|
|
335
|
+
retrieveModel(modelId: string, inferenceKey?: string): Promise<InferenceModel>;
|
|
333
336
|
chatCompletions(params: ChatCompletionParams): Promise<ChatCompletionResponse>;
|
|
334
337
|
streamChatCompletions(params: ChatCompletionParams): AsyncGenerator<ChatCompletionChunk>;
|
|
335
338
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ApiError, GpuRejectionError, gpuRejectionCodeForReason, envApiKey, envBaseUrl, envInferenceKey } from '../client.js';
|
|
2
|
-
import { readNativeMaxContext } from './models.js';
|
|
2
|
+
import { asInferenceModel, asInferenceModelList, readNativeMaxContext } from './models.js';
|
|
3
3
|
import { normalizeGPUPlacement } from './gpu-priorities.js';
|
|
4
4
|
const FUNCTION_NAME = /^[A-Za-z0-9_-]{1,64}$/;
|
|
5
5
|
const ROLES = new Set(['system', 'developer', 'user', 'assistant', 'tool', 'function']);
|
|
@@ -830,6 +830,46 @@ export class Inference {
|
|
|
830
830
|
remove: () => signal?.removeEventListener('abort', relay),
|
|
831
831
|
};
|
|
832
832
|
}
|
|
833
|
+
async modelRead(path, inferenceKey) {
|
|
834
|
+
const key = inferenceKey || this.key;
|
|
835
|
+
if (!key)
|
|
836
|
+
throw new Error('an inferenceKey is required');
|
|
837
|
+
const abort = this.abortContext();
|
|
838
|
+
try {
|
|
839
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
840
|
+
method: 'GET',
|
|
841
|
+
headers: { Authorization: `Bearer ${key}`, Accept: 'application/json', 'X-Request-ID': crypto.randomUUID() },
|
|
842
|
+
signal: abort.controller.signal,
|
|
843
|
+
});
|
|
844
|
+
if (!response.ok)
|
|
845
|
+
throw await apiError(response);
|
|
846
|
+
try {
|
|
847
|
+
return await response.json();
|
|
848
|
+
}
|
|
849
|
+
catch {
|
|
850
|
+
throw new ApiError(response.status, { error: { code: 'INVALID_MODEL_RESPONSE', message: 'Inference model discovery returned invalid JSON.' } });
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
catch (error) {
|
|
854
|
+
if (abort.controller.signal.aborted && !(error instanceof ApiError)) {
|
|
855
|
+
throw new ApiError(0, { error: String(abort.controller.signal.reason || 'Inference model discovery aborted') });
|
|
856
|
+
}
|
|
857
|
+
throw error;
|
|
858
|
+
}
|
|
859
|
+
finally {
|
|
860
|
+
clearTimeout(abort.timeoutId);
|
|
861
|
+
abort.remove();
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
async listModels(inferenceKey) {
|
|
865
|
+
return asInferenceModelList(await this.modelRead('/v1/models', inferenceKey));
|
|
866
|
+
}
|
|
867
|
+
async retrieveModel(modelId, inferenceKey) {
|
|
868
|
+
const id = typeof modelId === 'string' ? modelId.trim() : '';
|
|
869
|
+
if (!id)
|
|
870
|
+
throw new Error('RunBiOS: modelId is required to retrieve an inference model');
|
|
871
|
+
return asInferenceModel(await this.modelRead(`/v1/models/${encodeURIComponent(id)}`, inferenceKey));
|
|
872
|
+
}
|
|
833
873
|
async chatCompletions(params) {
|
|
834
874
|
const prepared = this.prepare(params, false);
|
|
835
875
|
const abort = this.abortContext(prepared.signal);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpClient } from '../client.js';
|
|
2
|
-
import type { ModelDetailResponse, ModelSearchParams, ModelSearchResponse, ModelConfig, AdapterCompatibilityParams, AdapterCompatibilityResponse, ArchitectureScope, SupportedArchitecturesResponse } from '../types.js';
|
|
2
|
+
import type { InferenceModel, InferenceModelListResponse, ModelDetailResponse, ModelSearchParams, ModelSearchResponse, ModelConfig, AdapterCompatibilityParams, AdapterCompatibilityResponse, ArchitectureScope, SupportedArchitecturesResponse } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Access the Run BiOS model catalog -- search models, fetch
|
|
5
5
|
* training-relevant configuration, and check adapter compatibility.
|
|
@@ -8,6 +8,8 @@ export declare class Models {
|
|
|
8
8
|
private readonly _http;
|
|
9
9
|
/** @internal */
|
|
10
10
|
constructor(_http: HttpClient);
|
|
11
|
+
list(): Promise<InferenceModelListResponse>;
|
|
12
|
+
retrieve(modelId: string): Promise<InferenceModel>;
|
|
11
13
|
/**
|
|
12
14
|
* Search the Run BiOS model catalog -- the platform's own hosted, verified
|
|
13
15
|
* models. Every result is mirrored in Run BiOS storage and can be trained and
|
|
@@ -98,6 +100,8 @@ export declare class Models {
|
|
|
98
100
|
scope?: ArchitectureScope;
|
|
99
101
|
}): Promise<SupportedArchitecturesResponse>;
|
|
100
102
|
}
|
|
103
|
+
export declare function asInferenceModelList(value: unknown): InferenceModelListResponse;
|
|
104
|
+
export declare function asInferenceModel(value: unknown): InferenceModel;
|
|
101
105
|
/** Registry detail path for an `author/name` catalog id, else undefined. @internal */
|
|
102
106
|
export declare function modelDetailPath(modelId: string): string | undefined;
|
|
103
107
|
/**
|
package/dist/resources/models.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ApiError } from '../client.js';
|
|
1
2
|
/**
|
|
2
3
|
* Access the Run BiOS model catalog -- search models, fetch
|
|
3
4
|
* training-relevant configuration, and check adapter compatibility.
|
|
@@ -8,6 +9,15 @@ export class Models {
|
|
|
8
9
|
constructor(_http) {
|
|
9
10
|
this._http = _http;
|
|
10
11
|
}
|
|
12
|
+
async list() {
|
|
13
|
+
return asInferenceModelList(await this._http.fetchGet('/v1/models'));
|
|
14
|
+
}
|
|
15
|
+
async retrieve(modelId) {
|
|
16
|
+
const id = typeof modelId === 'string' ? modelId.trim() : '';
|
|
17
|
+
if (!id)
|
|
18
|
+
throw new Error('RunBiOS: modelId is required to retrieve an inference model');
|
|
19
|
+
return asInferenceModel(await this._http.fetchGet(`/v1/models/${encodeURIComponent(id)}`));
|
|
20
|
+
}
|
|
11
21
|
/**
|
|
12
22
|
* Search the Run BiOS model catalog -- the platform's own hosted, verified
|
|
13
23
|
* models. Every result is mirrored in Run BiOS storage and can be trained and
|
|
@@ -135,6 +145,22 @@ export class Models {
|
|
|
135
145
|
return this._http.fetchGet(`/api/public/serving-architectures?${q}`);
|
|
136
146
|
}
|
|
137
147
|
}
|
|
148
|
+
export function asInferenceModelList(value) {
|
|
149
|
+
const response = value && typeof value === 'object' ? value : null;
|
|
150
|
+
const data = response?.data;
|
|
151
|
+
if (response?.object !== 'list' || !Array.isArray(data) ||
|
|
152
|
+
!data.every(row => row && typeof row.id === 'string' && row.id.trim())) {
|
|
153
|
+
throw new ApiError(0, { error: { code: 'INVALID_MODELS_RESPONSE', message: 'Inference model discovery returned an invalid list; retry instead of treating it as empty.' } });
|
|
154
|
+
}
|
|
155
|
+
return value;
|
|
156
|
+
}
|
|
157
|
+
export function asInferenceModel(value) {
|
|
158
|
+
const model = value && typeof value === 'object' ? value : null;
|
|
159
|
+
if (model?.object !== 'model' || typeof model?.id !== 'string' || !model.id.trim()) {
|
|
160
|
+
throw new ApiError(0, { error: { code: 'INVALID_MODEL_RESPONSE', message: 'Inference model retrieval returned an invalid model; retry or list available models.' } });
|
|
161
|
+
}
|
|
162
|
+
return value;
|
|
163
|
+
}
|
|
138
164
|
/** Registry detail path for an `author/name` catalog id, else undefined. @internal */
|
|
139
165
|
export function modelDetailPath(modelId) {
|
|
140
166
|
const repo = (modelId || '').trim().replace(/^\/+|\/+$/g, '');
|
package/dist/types.d.ts
CHANGED
|
@@ -215,6 +215,22 @@ export interface ModelDetailResponse {
|
|
|
215
215
|
*/
|
|
216
216
|
primary_revision?: string;
|
|
217
217
|
}
|
|
218
|
+
export interface InferenceModel {
|
|
219
|
+
id: string;
|
|
220
|
+
object: string;
|
|
221
|
+
owned_by?: string;
|
|
222
|
+
created?: number;
|
|
223
|
+
[field: string]: unknown;
|
|
224
|
+
}
|
|
225
|
+
export interface InferenceModelListResponse {
|
|
226
|
+
object: string;
|
|
227
|
+
data: InferenceModel[];
|
|
228
|
+
usf_unreachable_sources?: Array<{
|
|
229
|
+
source: string;
|
|
230
|
+
reason: string;
|
|
231
|
+
}>;
|
|
232
|
+
[field: string]: unknown;
|
|
233
|
+
}
|
|
218
234
|
export interface ModelSearchParams {
|
|
219
235
|
/**
|
|
220
236
|
* Search text. Becomes the registry's `q` filter -- the ONLY search
|