Skip to content

Commit 0a68414

Browse files
committed
fix centml ls
1 parent 7b5521f commit 0a68414

File tree

2 files changed

+57
-44
lines changed

2 files changed

+57
-44
lines changed

packages/inference/src/providers/centml.ts

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,57 +10,62 @@ import { BaseConversationalTask, BaseTextGenerationTask } from "./providerHelper
1010
const CENTML_API_BASE_URL = "https://api.centml.com";
1111

1212
export class CentMLConversationalTask extends BaseConversationalTask {
13-
constructor() {
14-
super("centml", CENTML_API_BASE_URL);
15-
}
13+
constructor() {
14+
super("centml", CENTML_API_BASE_URL);
15+
}
1616

17-
override preparePayload(params: BodyParams): Record<string, unknown> {
18-
const { args, model } = params;
19-
return {
20-
...args,
21-
model,
22-
api_key: args.accessToken, // Use the accessToken from args
23-
};
24-
}
17+
override makeRoute(): string {
18+
return "openai/v1/chat/completions";
19+
}
2520

26-
override async getResponse(response: ChatCompletionOutput): Promise<ChatCompletionOutput> {
27-
if (
28-
typeof response === "object" &&
29-
Array.isArray(response?.choices) &&
30-
typeof response?.created === "number" &&
31-
typeof response?.id === "string" &&
32-
typeof response?.model === "string" &&
33-
typeof response?.usage === "object"
34-
) {
35-
return response;
36-
}
21+
override preparePayload(params: BodyParams): Record<string, unknown> {
22+
const { args, model } = params;
23+
return {
24+
...args,
25+
model,
26+
api_key: args.accessToken,
27+
};
28+
}
3729

38-
throw new InferenceOutputError("Expected ChatCompletionOutput");
39-
}
30+
override async getResponse(response: ChatCompletionOutput): Promise<ChatCompletionOutput> {
31+
if (
32+
typeof response === "object" &&
33+
Array.isArray(response?.choices) &&
34+
typeof response?.created === "number" &&
35+
typeof response?.id === "string" &&
36+
typeof response?.model === "string" &&
37+
typeof response?.usage === "object"
38+
) {
39+
return response;
40+
}
41+
42+
throw new InferenceOutputError("Expected ChatCompletionOutput");
43+
}
4044
}
4145

4246
export class CentMLTextGenerationTask extends BaseTextGenerationTask {
43-
constructor() {
44-
super("centml", CENTML_API_BASE_URL);
45-
}
47+
constructor() {
48+
super("centml", CENTML_API_BASE_URL);
49+
}
50+
51+
override makeRoute(): string {
52+
return "openai/v1/completions";
53+
}
4654

47-
override preparePayload(params: BodyParams): Record<string, unknown> {
48-
const { args, model } = params;
49-
return {
50-
...args,
51-
model,
52-
api_key: args.accessToken, // Use the accessToken from args
53-
};
54-
}
55+
override preparePayload(params: BodyParams): Record<string, unknown> {
56+
const { args, model } = params;
57+
return {
58+
...args,
59+
model,
60+
api_key: args.accessToken,
61+
};
62+
}
5563

56-
override async getResponse(response: TextGenerationOutput): Promise<TextGenerationOutput> {
57-
if (
58-
typeof response === "object" &&
59-
typeof response?.generated_text === "string"
60-
) {
61-
return response;
62-
}
64+
override async getResponse(response: TextGenerationOutput): Promise<TextGenerationOutput> {
65+
if (typeof response === "object" && typeof response?.generated_text === "string") {
66+
return response;
67+
}
6368

64-
throw new InferenceOutputError("Expected TextGenerationOutput");
65-
}
69+
throw new InferenceOutputError("Expected TextGenerationOutput");
70+
}
6671
}

packages/inference/src/providers/consts.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ export const HARDCODED_MODEL_INFERENCE_MAPPING: Record<
2121
*/
2222
"black-forest-labs": {},
2323
cerebras: {},
24+
centml: {
25+
"meta-llama/Llama-3.2-3B-Instruct": {
26+
hfModelId: "meta-llama/Llama-3.2-3B-Instruct",
27+
providerId: "meta-llama/Llama-3.2-3B-Instruct", // CentML expects same id
28+
status: "live", // or "staging" if you prefer the warning
29+
task: "conversational" // <-- WidgetType from @huggingface/tasks
30+
}
31+
},
2432
cohere: {},
2533
"fal-ai": {},
2634
"featherless-ai": {},

0 commit comments

Comments
 (0)