Add Hugging Face as a chat provider
Lets users with an existing Hugging Face account chat through HF's Inference Providers router without signing up for another provider. Model IDs are namespaced hf:org/model-name to avoid inferProvider's OpenRouter "/" heuristic misrouting them; curated model list plus a "Custom Model ID…" entry point stand in for HF's lack of a catalog/ pricing API.
This commit is contained in:
@@ -639,6 +639,10 @@ Don't narrate future actions ("Let me...") - just use the tools.
|
||||
nonisolated static func inferProvider(from modelId: String) -> Settings.Provider? {
|
||||
// Apple Foundation Models
|
||||
if modelId.hasPrefix("apple-") { return .appleOnDevice }
|
||||
// Hugging Face models are namespaced "hf:org/model-name" — must be checked before the
|
||||
// generic "/"-contains heuristic below, since HF IDs are structurally identical to
|
||||
// OpenRouter's "vendor/model" shape and would otherwise be misrouted.
|
||||
if modelId.hasPrefix(HuggingFaceProvider.idPrefix) { return .huggingface }
|
||||
// OpenRouter models always contain a "/" (e.g. "anthropic/claude-3-5-sonnet")
|
||||
if modelId.contains("/") { return .openrouter }
|
||||
// Anthropic direct (e.g. "claude-sonnet-4-5-20250929")
|
||||
|
||||
Reference in New Issue
Block a user