-
Notifications
You must be signed in to change notification settings - Fork 269
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
[Inference] [Providers] Enforce task in mapping + expose them #1109
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
be5123d
enforce task mapping
SBrandeis c4d8acb
test error case
SBrandeis d309548
lint + format
SBrandeis 455ea4b
example
SBrandeis 82ed7f9
format + lint
SBrandeis 4d0d9fb
expose the mappings through index
SBrandeis 882cc4a
Merge branch 'main' into inference/providers-task-mapping
SBrandeis e44c7de
fix: exported constants
SBrandeis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
export { HfInference, HfInferenceEndpoint } from "./HfInference"; | ||
export { InferenceOutputError } from "./lib/InferenceOutputError"; | ||
export { FAL_AI_SUPPORTED_MODEL_IDS } from "./providers/fal-ai"; | ||
export { REPLICATE_SUPPORTED_MODEL_IDS } from "./providers/replicate"; | ||
export { SAMBANOVA_SUPPORTED_MODEL_IDS } from "./providers/sambanova"; | ||
export { TOGETHER_SUPPORTED_MODEL_IDS } from "./providers/together"; | ||
export * from "./types"; | ||
export * from "./tasks"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
import type { ModelId } from "../types"; | ||
import type { ProviderMapping } from "./types"; | ||
|
||
export const FAL_AI_API_BASE_URL = "https://fal.run"; | ||
|
||
type FalAiId = string; | ||
|
||
/** | ||
* Mapping from HF model ID -> fal.ai app id | ||
*/ | ||
export const FAL_AI_MODEL_IDS: Partial<Record<ModelId, FalAiId>> = { | ||
/** text-to-image */ | ||
"black-forest-labs/FLUX.1-schnell": "fal-ai/flux/schnell", | ||
"black-forest-labs/FLUX.1-dev": "fal-ai/flux/dev", | ||
|
||
/** automatic-speech-recognition */ | ||
"openai/whisper-large-v3": "fal-ai/whisper", | ||
export const FAL_AI_SUPPORTED_MODEL_IDS: ProviderMapping<FalAiId> = { | ||
"text-to-image": { | ||
"black-forest-labs/FLUX.1-schnell": "fal-ai/flux/schnell", | ||
"black-forest-labs/FLUX.1-dev": "fal-ai/flux/dev", | ||
}, | ||
"automatic-speech-recognition": { | ||
"openai/whisper-large-v3": "fal-ai/whisper", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,16 @@ | ||
import type { ModelId } from "../types"; | ||
import type { ProviderMapping } from "./types"; | ||
|
||
export const REPLICATE_API_BASE_URL = "https://api.replicate.com"; | ||
|
||
type ReplicateId = string; | ||
|
||
/** | ||
* Mapping from HF model ID -> Replicate model ID | ||
* | ||
* Available models can be fetched with: | ||
* ``` | ||
* curl -s \ | ||
* -H "Authorization: Bearer $REPLICATE_API_TOKEN" \ | ||
* 'https://api.replicate.com/v1/models' | ||
* ``` | ||
*/ | ||
export const REPLICATE_MODEL_IDS: Partial<Record<ModelId, ReplicateId>> = { | ||
/** text-to-image */ | ||
"black-forest-labs/FLUX.1-schnell": "black-forest-labs/flux-schnell", | ||
"ByteDance/SDXL-Lightning": | ||
"bytedance/sdxl-lightning-4step:5599ed30703defd1d160a25a63321b4dec97101d98b4674bcc56e41f62f35637", | ||
export const REPLICATE_SUPPORTED_MODEL_IDS: ProviderMapping<ReplicateId> = { | ||
"text-to-image": { | ||
"black-forest-labs/FLUX.1-schnell": "black-forest-labs/flux-schnell", | ||
"ByteDance/SDXL-Lightning": | ||
"bytedance/sdxl-lightning-4step:5599ed30703defd1d160a25a63321b4dec97101d98b4674bcc56e41f62f35637", | ||
}, | ||
// "text-to-speech": { | ||
// "SWivid/F5-TTS": "x-lance/f5-tts:87faf6dd7a692dd82043f662e76369cab126a2cf1937e25a9d41e0b834fd230e" | ||
// }, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,23 @@ | ||
import type { ModelId } from "../types"; | ||
import type { ProviderMapping } from "./types"; | ||
|
||
export const SAMBANOVA_API_BASE_URL = "https://api.sambanova.ai"; | ||
|
||
/** | ||
* Note for reviewers: our goal would be to ask Sambanova to support | ||
* our model ids too, so we don't have to define a mapping | ||
* or keep it up-to-date. | ||
* | ||
* As a fallback, if the above is not possible, ask Sambanova to | ||
* provide the mapping as an fetchable API. | ||
*/ | ||
type SambanovaId = string; | ||
|
||
/** | ||
* https://community.sambanova.ai/t/supported-models/193 | ||
*/ | ||
export const SAMBANOVA_MODEL_IDS: Partial<Record<ModelId, SambanovaId>> = { | ||
export const SAMBANOVA_SUPPORTED_MODEL_IDS: ProviderMapping<SambanovaId> = { | ||
/** Chat completion / conversational */ | ||
"Qwen/Qwen2.5-Coder-32B-Instruct": "Qwen2.5-Coder-32B-Instruct", | ||
"Qwen/Qwen2.5-72B-Instruct": "Qwen2.5-72B-Instruct", | ||
"Qwen/QwQ-32B-Preview": "QwQ-32B-Preview", | ||
"meta-llama/Llama-3.3-70B-Instruct": "Meta-Llama-3.3-70B-Instruct", | ||
"meta-llama/Llama-3.2-1B": "Meta-Llama-3.2-1B-Instruct", | ||
"meta-llama/Llama-3.2-3B": "Meta-Llama-3.2-3B-Instruct", | ||
"meta-llama/Llama-3.2-11B-Vision-Instruct": "Llama-3.2-11B-Vision-Instruct", | ||
"meta-llama/Llama-3.2-90B-Vision-Instruct": "Llama-3.2-90B-Vision-Instruct", | ||
"meta-llama/Llama-3.1-8B-Instruct": "Meta-Llama-3.1-8B-Instruct", | ||
"meta-llama/Llama-3.1-70B-Instruct": "Meta-Llama-3.1-70B-Instruct", | ||
"meta-llama/Llama-3.1-405B-Instruct": "Meta-Llama-3.1-405B-Instruct", | ||
"meta-llama/Llama-Guard-3-8B": "Meta-Llama-Guard-3-8B", | ||
conversational: { | ||
"Qwen/Qwen2.5-Coder-32B-Instruct": "Qwen2.5-Coder-32B-Instruct", | ||
"Qwen/Qwen2.5-72B-Instruct": "Qwen2.5-72B-Instruct", | ||
"Qwen/QwQ-32B-Preview": "QwQ-32B-Preview", | ||
"meta-llama/Llama-3.3-70B-Instruct": "Meta-Llama-3.3-70B-Instruct", | ||
"meta-llama/Llama-3.2-1B-Instruct": "Meta-Llama-3.2-1B-Instruct", | ||
"meta-llama/Llama-3.2-3B-Instruct": "Meta-Llama-3.2-3B-Instruct", | ||
"meta-llama/Llama-3.2-11B-Vision-Instruct": "Llama-3.2-11B-Vision-Instruct", | ||
"meta-llama/Llama-3.2-90B-Vision-Instruct": "Llama-3.2-90B-Vision-Instruct", | ||
"meta-llama/Llama-3.1-8B-Instruct": "Meta-Llama-3.1-8B-Instruct", | ||
"meta-llama/Llama-3.1-70B-Instruct": "Meta-Llama-3.1-70B-Instruct", | ||
"meta-llama/Llama-3.1-405B-Instruct": "Meta-Llama-3.1-405B-Instruct", | ||
"meta-llama/Llama-Guard-3-8B": "Meta-Llama-Guard-3-8B", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { InferenceTask, ModelId } from "../types"; | ||
|
||
export type ProviderMapping<ProviderId extends string> = Partial< | ||
Record<InferenceTask | "conversational", Partial<Record<ModelId, ProviderId>>> | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(for moon's consumption, i presume?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes