mudler/LocalAI · error · ValueError

Unknown task '{task}'. Available tasks: {', '.join(sorted(al

Error message

Unknown task '{task}'. Available tasks: {', '.join(sorted(aliases.keys())[:20])}...

What it means

Raised by resolve_pipeline_class when no class_name was given, a task was given, and the task matches no alias exactly, no substring-partial alias match, and thus falls through to the error. The message lists up to 20 known task aliases (e.g. 'text-to-image', 'image-to-image').

Source

Thrown at backend/python/diffusers/diffusers_dynamic_loader.py:368

            f"Available pipelines: {', '.join(sorted(registry.keys())[:20])}..."
        )

    # 2. Task alias lookup
    if task:
        task_lower = task.lower().replace('_', '-')
        if task_lower in aliases:
            # Return the first matching pipeline for this task
            matching_classes = aliases[task_lower]
            if matching_classes:
                return registry[matching_classes[0]]

        # Try partial matching
        for alias, classes in aliases.items():
            if task_lower in alias or alias in task_lower:
                if classes:
                    return registry[classes[0]]

        raise ValueError(
            f"Unknown task '{task}'. "
            f"Available tasks: {', '.join(sorted(aliases.keys())[:20])}..."
        )

    # 3. Try to infer from HuggingFace Hub
    if model_id:
        try:
            from huggingface_hub import model_info
            info = model_info(model_id)

            # Check pipeline_tag
            if hasattr(info, 'pipeline_tag') and info.pipeline_tag:
                tag = info.pipeline_tag.lower().replace('_', '-')
                if tag in aliases:
                    matching_classes = aliases[tag]
                    if matching_classes:
                        return registry[matching_classes[0]]

View on GitHub (pinned to 44413a9d06)

Solutions

  1. Use a canonical alias from the error's 'Available tasks' list, e.g. 'text-to-image'.
  2. Prefer passing class_name= directly if you know the pipeline class — it skips task resolution entirely.
  3. If a model_id is available, omit task and let the loader infer from the HuggingFace model card pipeline_tag.
  4. Normalize your task string to lowercase-hyphenated form before calling.

Example fix

# before
load_diffusers_pipeline(task="txt2img", model_id="stabilityai/sd-turbo")

# after
load_diffusers_pipeline(task="text-to-image", model_id="stabilityai/sd-turbo")
Defensive patterns

Strategy: validation

Validate before calling

aliases = get_task_aliases()
norm = task.lower().replace('_', '-')
assert norm in aliases or any(norm in a or a in norm for a in aliases), f"unknown task {task!r}"

Type guard

def is_known_task(task: str) -> bool:
    aliases = get_task_aliases()
    t = task.lower().replace('_', '-')
    return t in aliases or any(t in a or a in t for a in aliases)

Try / catch

try:
    cls = resolve_pipeline_class(task=task, ...)
except ValueError as e:
    return error_reply(str(e))  # message lists available tasks

Prevention

When it happens

Trigger: Calling load_diffusers_pipeline(task=...) with an unrecognized task string such as 'txt2img', 'image-gen', or 'video-generation' when the alias map only contains canonical diffusers task tags.

Common situations: Passing shorthand CLI-style names instead of HuggingFace pipeline_tag conventions, a task tag from a newer diffusers version, or misspelled/case-mangled tasks (the code lowercases and replaces underscores with hyphens, so 'Text_To_Image' works but 'text to image' with spaces does not).

Related errors


AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15). Data as JSON: /api/errors/027db034604892c0. Report an issue: GitHub.