-
Notifications
You must be signed in to change notification settings - Fork 556
feat: support zai as inference provider #1766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
4dbf5a9
ce90628
4eda47a
ccd45ca
fb1d2e3
3a4b909
4d3f227
2931b6b
de7ea60
0d0e6d1
c501744
0763c96
42926d2
df4703a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,4 +37,5 @@ export const HARDCODED_MODEL_INFERENCE_MAPPING: Record< | |
| sambanova: {}, | ||
| scaleway: {}, | ||
| together: {}, | ||
| zai: {}, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /** | ||
| * See the registered mapping of HF model ID => ZAI model ID here: | ||
| * | ||
| * https://huggingface.co/api/partners/zai/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 zai 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 zai, please open an issue on the present repo | ||
| * and we will tag zai team members. | ||
| * | ||
| * Thanks! | ||
| */ | ||
| import { BaseConversationalTask, BaseTextGenerationTask } from "./providerHelper.js"; | ||
| import type { HeaderParams } from "../types.js"; | ||
|
|
||
| const ZAI_API_BASE_URL = "https://api.z.ai/api/paas/v4"; | ||
|
|
||
| export class ZaiTextGenerationTask extends BaseTextGenerationTask { | ||
| constructor() { | ||
| super("zai", ZAI_API_BASE_URL); | ||
| } | ||
|
|
||
| override prepareHeaders(params: HeaderParams, binary: boolean): Record<string, string> { | ||
| const headers = super.prepareHeaders(params, binary); | ||
| headers["x-source-channel"] = "hugging_face"; | ||
| return headers; | ||
| } | ||
|
|
||
| override makeRoute(): string { | ||
| return "/chat/completions"; | ||
tomsun28 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
||
|
|
||
| export class ZaiConversationalTask extends BaseConversationalTask { | ||
| constructor() { | ||
| super("zai", ZAI_API_BASE_URL); | ||
| } | ||
|
|
||
| override makeRoute(): string { | ||
| return "/chat/completions"; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.