zylon-ai/private-gpt · error · ImportError

OpenAI Responses LLM dependencies are not installed. Install

Error message

OpenAI Responses LLM dependencies are not installed. Install with `uv sync --inexact --extra llm-openai`.

What it means

ImportError from the lazy loader in the OpenAI-like Responses factory: importing PatchedOpenAILikeResponsesLLM failed. Despite serving OpenAI-compatible endpoints (vLLM, Ollama), this factory's patched class depends on the 'llm-openai' extra, not llm-openai-compatible, because it builds on the OpenAI SDK's Responses implementation.

Source

Thrown at private_gpt/components/llm/factories/responses/openailike.py:19

from typing import Any, cast

from llama_index.core.llms import LLM

from private_gpt.components.llm.factories.base import LLMFactory
from private_gpt.components.llm.tokenizers.tokenizer_base import TokenizerBase
from private_gpt.settings.settings import LLMModelConfig, Settings
from private_gpt.utils.dependencies import format_missing_dependency_message


def _load_patched_openai_like_responses() -> type[Any]:
    try:
        from private_gpt.components.llm.custom.openailikeresponses import (
            PatchedOpenAILikeResponsesLLM,
        )

        return PatchedOpenAILikeResponsesLLM
    except ImportError as e:
        raise ImportError(
            format_missing_dependency_message(
                "OpenAI Responses LLM",
                extras="llm-openai",
            )
        ) from e


class OpenAILikeResponsesFactory(LLMFactory):
    """Responses API factory for OpenAI-compatible endpoints (vLLM, Ollama, etc.)."""

    def __init__(self, settings: Settings):
        super().__init__(settings)
        self.openai_settings = settings.openai

    def _create_llm(
        self, model_config: LLMModelConfig, tokenizer: TokenizerBase | None = None
    ) -> tuple[LLM, str | None]:
        PatchedOpenAILikeResponsesLLM = _load_patched_openai_like_responses()

View on GitHub (pinned to 4a030776a3)

Solutions

  1. Run `uv sync --inexact --extra llm-openai` (this Responses variant needs the openai extra even for like-endpoints).
  2. Upgrade the openai package if the extra is present but old.
  3. Alternatively route OpenAI-compatible endpoints through the completions factories with the llm-openai-compatible extra if you don't need the Responses API.

Example fix

# before
uv sync --inexact --extra llm-openai-compatible

# after
uv sync --inexact --extra llm-openai-compatible --extra llm-openai
Defensive patterns

Strategy: validation

Validate before calling

def openai_extra_available() -> bool:
    try:
        import openai  # noqa: F401
        return True
    except ImportError:
        return False

Try / catch

try:
    factory = OpenAILikeResponsesFactory(settings)
except ImportError as e:
    if 'llm-openai' in str(e):
        raise SystemExit('Run: uv sync --inexact --extra llm-openai') from e
    raise

Prevention

When it happens

Trigger: Routing Responses-API traffic to an OpenAI-compatible endpoint without the llm-openai extra installed, or with an openai SDK lacking the classes the custom openailikeresponses module imports.

Common situations: Assuming the 'openai-like' route needs only the llm-openai-compatible extra; slim installs; older pinned openai SDK versions predating Responses support.

Related errors


AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15). Data as JSON: /api/errors/0961fe3b848e01ae. Report an issue: GitHub.