UNPKG

@burncloud/inference

Version:

Typescript client for the Hugging Face Inference Providers and Inference Endpoints

50 lines (49 loc) 2.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SambanovaFeatureExtractionTask = exports.SambanovaConversationalTask = void 0; /** * See the registered mapping of HF model ID => Sambanova model ID here: * * https://huggingface.co/api/partners/sambanova/models * * This is a publicly available mapping. * * If you want to try to run inference for a new model locally before it's registered on huggingface.co, * you can add it to the dictionary "HARDCODED_MODEL_ID_MAPPING" in consts.ts, for dev purposes. * * - If you work at Sambanova and want to update this mapping, please use the model mapping API we provide on huggingface.co * - If you're a community member and want to add a new supported HF model to Sambanova, please open an issue on the present repo * and we will tag Sambanova team members. * * Thanks! */ const InferenceOutputError_js_1 = require("../lib/InferenceOutputError.js"); const providerHelper_js_1 = require("./providerHelper.js"); class SambanovaConversationalTask extends providerHelper_js_1.BaseConversationalTask { constructor() { super("sambanova", "https://api.sambanova.ai"); } } exports.SambanovaConversationalTask = SambanovaConversationalTask; class SambanovaFeatureExtractionTask extends providerHelper_js_1.TaskProviderHelper { constructor() { super("sambanova", "https://api.sambanova.ai"); } makeRoute() { return `/v1/embeddings`; } async getResponse(response) { if (typeof response === "object" && "data" in response && Array.isArray(response.data)) { return response.data.map((item) => item.embedding); } throw new InferenceOutputError_js_1.InferenceOutputError("Expected Sambanova feature-extraction (embeddings) response format to be {'data' : list of {'embedding' : number[]}}"); } preparePayload(params) { return { model: params.model, input: params.args.inputs, ...params.args, }; } } exports.SambanovaFeatureExtractionTask = SambanovaFeatureExtractionTask;