zylon-ai/private-gpt · error · ImportError

OpenAI-like Responses LLM dependencies are not installed. In

Error message

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

What it means

ImportError raised lazily by _load_openai_like_responses_base when importing llama_index.llms.openai_like fails or lacks the OpenAILikeResponses attribute. The message tells you exactly which optional extra to install (llm-openai-compatible). Raised at class-definition time via _load_patched_openai_responses usage paths.

Source

Thrown at private_gpt/components/llm/custom/openailikeresponses.py:23

    from llama_index.llms.openai_like import (  # type: ignore[import-not-found,import-untyped]  # ty:ignore[unresolved-import]
        OpenAILikeResponses as OpenAILikeResponsesBase,
    )

    from private_gpt.components.llm.custom.openairesponses import (
        PatchedOpenAIResponsesLLM,
    )


def _load_openai_like_responses_base() -> type[Any]:
    try:
        return cast(
            type[Any],
            importlib.import_module("llama_index.llms.openai_like").OpenAILikeResponses,
        )
    except (ImportError, AttributeError) as e:
        from private_gpt.utils.dependencies import format_missing_dependency_message

        raise ImportError(
            format_missing_dependency_message(
                "OpenAI-like Responses LLM",
                extras="llm-openai-compatible",
            )
        ) from e


def _load_patched_openai_responses() -> type[Any]:
    from private_gpt.components.llm.custom.openairesponses import (
        PatchedOpenAIResponsesLLM,
    )

    return PatchedOpenAIResponsesLLM


if not TYPE_CHECKING:
    OpenAILikeResponsesBase = _load_openai_like_responses_base()
    PatchedOpenAIResponsesLLM = _load_patched_openai_responses()

View on GitHub (pinned to 4a030776a3)

Solutions

  1. Install the extra exactly as the message says: uv sync --inexact --extra llm-openai-compatible.
  2. Verify the import works in the same environment: python -c "import llama_index.llms.openai_like; print(llama_index.llms.openai_like.OpenAILikeResponses)".
  3. If the attribute is missing rather than the module (AttributeError path), pin llama-index to the version this project expects.
  4. Rebuild the deployment image after adding the extra.

Example fix

# before
uv sync --inexact

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

Strategy: try-catch

Validate before calling

def openai_like_responses_available() -> bool:
    try:
        import llama_index.llms.openai_like  # noqa: F401
        return hasattr(llama_index.llms.openai_like, 'OpenAILikeResponses')
    except ImportError:
        return False

Try / catch

try:
    from private_gpt.components.llm.custom.openailikeresponses import OpenAILikeResponsesLLM
except ImportError as e:
    if 'llm-openai-compatible' in str(e):
        raise RuntimeError('run: uv sync --inexact --extra llm-openai-compatible') from e

Prevention

When it happens

Trigger: Selecting/configuring the OpenAI-like Responses LLM backend while the llama-index openai-like integration package is not installed — e.g. profile set to openai_like_responses without the extra, or a deployment installed with a trimmed dependency set.

Common situations: Custom docker images built with only some LLM extras; upgrading/downgrading llama-index breaking the integration module; typos in profiles that fall back to this backend.

Related errors


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