-
Notifications
You must be signed in to change notification settings - Fork 358
/
Copy pathrequest.ts
22 lines (21 loc) · 888 Bytes
/
request.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { getProviderHelper } from "../../lib/getProviderHelper";
import type { InferenceTask, Options, RequestArgs } from "../../types";
import { innerRequest } from "../../utils/request";
/**
* Primitive to make custom calls to the inference provider
* @deprecated Use specific task functions instead. This function will be removed in a future version.
*/
export async function request<T>(
args: RequestArgs,
options?: Options & {
/** In most cases (unless we pass a endpointUrl) we know the task */
task?: InferenceTask;
}
): Promise<T> {
console.warn(
"The request method is deprecated and will be removed in a future version of huggingface.js. Use specific task functions instead."
);
const providerHelper = getProviderHelper(args.provider ?? "hf-inference", options?.task);
const result = await innerRequest<T>(args, providerHelper, options);
return result.data;
}