@huggingface/inference
Version:
Typescript client for the Hugging Face Inference Providers and Inference Endpoints
125 lines • 5.91 kB
TypeScript
/**
* See the registered mapping of HF model ID => Together model ID here:
*
* https://huggingface.co/api/partners/together/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 Together 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 Together, please open an issue on the present repo
* and we will tag Together team members.
*
* Thanks!
*/
import type { AutomaticSpeechRecognitionOutput, ChatCompletionOutput, FeatureExtractionOutput, TextGenerationOutput, TextGenerationOutputFinishReason } from "@huggingface/tasks";
import type { BodyParams, OutputType, RequestArgs } from "../types.js";
import { BaseConversationalTask, BaseTextGenerationTask, TaskProviderHelper, type AutomaticSpeechRecognitionTaskHelper, type FeatureExtractionTaskHelper, type ImageToImageTaskHelper, type ImageToVideoTaskHelper, type TextToImageTaskHelper, type TextToSpeechTaskHelper, type TextToVideoTaskHelper } from "./providerHelper.js";
import type { ChatCompletionInput } from "../../../tasks/dist/commonjs/index.js";
import type { AutomaticSpeechRecognitionArgs } from "../tasks/audio/automaticSpeechRecognition.js";
import type { ImageToImageArgs } from "../tasks/cv/imageToImage.js";
import type { ImageToVideoArgs } from "../tasks/cv/imageToVideo.js";
interface TogetherTextCompletionOutput extends Omit<ChatCompletionOutput, "choices"> {
choices: Array<{
text: string;
finish_reason: TextGenerationOutputFinishReason;
seed: number;
logprobs: unknown;
index: number;
}>;
}
interface TogetherImageGeneration {
data: Array<{
b64_json?: string;
url?: string;
}>;
}
interface TogetherEmbeddingsResponse {
data: Array<{
embedding: number[];
index: number;
object: string;
}>;
model: string;
object: string;
}
interface TogetherAudioTranscriptionSegment {
id: number;
start: number;
end: number;
text: string;
}
interface TogetherAudioTranscriptionResponse {
text: string;
segments?: TogetherAudioTranscriptionSegment[];
}
interface TogetherVideoJobResponse {
id: string;
status?: string;
outputs?: {
video_url?: string;
};
error?: {
message?: string;
};
}
export declare class TogetherConversationalTask extends BaseConversationalTask {
constructor();
preparePayload(params: BodyParams<ChatCompletionInput>): Record<string, unknown>;
}
export declare class TogetherTextGenerationTask extends BaseTextGenerationTask {
constructor();
preparePayload(params: BodyParams): Record<string, unknown>;
getResponse(response: TogetherTextCompletionOutput): Promise<TextGenerationOutput>;
}
export declare class TogetherTextToImageTask extends TaskProviderHelper implements TextToImageTaskHelper {
constructor();
makeRoute(): string;
preparePayload(params: BodyParams): Record<string, unknown>;
/** Task label used in malformed-response errors. Overridden by subclasses. */
protected get imageTaskLabel(): string;
getResponse(response: TogetherImageGeneration, url?: string, headers?: HeadersInit, outputType?: OutputType, signal?: AbortSignal): Promise<string | Blob | Record<string, unknown>>;
}
export declare class TogetherImageToImageTask extends TogetherTextToImageTask implements ImageToImageTaskHelper {
protected get imageTaskLabel(): string;
preparePayload(params: BodyParams<ImageToImageArgs>): Record<string, unknown>;
preparePayloadAsync(args: ImageToImageArgs): Promise<RequestArgs>;
getResponse(response: TogetherImageGeneration, url?: string, headers?: HeadersInit, outputType?: OutputType): Promise<Blob>;
}
/** Shared base for Together's async video tasks (text-to-video, image-to-video). */
declare abstract class TogetherVideoTask extends TaskProviderHelper {
constructor();
makeRoute(): string;
getResponse(response: TogetherVideoJobResponse, url?: string, headers?: Record<string, string>, _outputType?: OutputType, signal?: AbortSignal): Promise<Blob>;
}
export declare class TogetherTextToVideoTask extends TogetherVideoTask implements TextToVideoTaskHelper {
preparePayload(params: BodyParams): Record<string, unknown>;
}
export declare class TogetherImageToVideoTask extends TogetherVideoTask implements ImageToVideoTaskHelper {
preparePayload(params: BodyParams<ImageToVideoArgs>): Record<string, unknown>;
preparePayloadAsync(args: ImageToVideoArgs): Promise<RequestArgs>;
}
export declare class TogetherFeatureExtractionTask extends TaskProviderHelper implements FeatureExtractionTaskHelper {
constructor();
makeRoute(): string;
preparePayload(params: BodyParams): Record<string, unknown>;
getResponse(response: TogetherEmbeddingsResponse): Promise<FeatureExtractionOutput>;
}
export declare class TogetherTextToSpeechTask extends TaskProviderHelper implements TextToSpeechTaskHelper {
constructor();
makeRoute(): string;
preparePayload(params: BodyParams): Record<string, unknown>;
getResponse(response: Blob): Promise<Blob>;
}
export declare class TogetherAutomaticSpeechRecognitionTask extends TaskProviderHelper implements AutomaticSpeechRecognitionTaskHelper {
constructor();
makeRoute(): string;
preparePayload(params: BodyParams): Record<string, unknown>;
makeBody(params: BodyParams): BodyInit;
preparePayloadAsync(args: AutomaticSpeechRecognitionArgs): Promise<RequestArgs>;
getResponse(response: TogetherAudioTranscriptionResponse): Promise<AutomaticSpeechRecognitionOutput>;
}
export {};
//# sourceMappingURL=together.d.ts.map