llamaIndex - ✅(Solved) Fix [Bug]: `llama_index.core` top-level legacy exports are listed in `__all__` but missing at runtime [1 pull requests, 4 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
run-llama/llama_index#21132Fetched 2026-04-08 01:21:41
View on GitHub
Comments
4
Participants
3
Timeline
6
Reactions
0
Author
Timeline (top)
commented ×3cross-referenced ×1mentioned ×1subscribed ×1

Error Message

ImportError: cannot import name 'GPTKnowledgeGraphIndex' from 'llama_index.core' ImportError: cannot import name 'SummaryPrompt' from 'llama_index.core' AttributeError: module 'llama_index.core' has no attribute 'GPTKnowledgeGraphIndex'

Root Cause

At runtime, these currently fail because:

  • GPTKnowledgeGraphIndex is listed in llama_index.core.indices.__all__, but is not actually imported/bound there
  • legacy prompt aliases such as SummaryPrompt, TreeInsertPrompt, RefinePrompt, etc. exist in llama_index.core.prompts.prompts, but are not re-exported through llama_index.core.prompts or llama_index.core

Fix Action

Fixed

PR fix notes

PR #21133: fix: restore missing legacy exports in llama_index.core

Description (problem / solution / changelog)

Description

This PR fixes a top-level export regression in llama_index.core.

Several legacy names were still listed in llama_index.core.__all__, but were no longer actually bound at runtime. As a result, imports such as from llama_index.core import GPTKnowledgeGraphIndex, from llama_index.core import SummaryPrompt, and even from llama_index.core import * could fail at runtime.

This change restores those legacy exports by:

  • re-binding GPTKnowledgeGraphIndex as a legacy alias of KnowledgeGraphIndex
  • re-exporting legacy prompt aliases from llama_index.core.prompts
  • wiring those restored names back into the top-level llama_index.core export surface
  • adding regression tests for the affected public exports

This is a compatibility-focused bug fix and does not introduce any new dependencies.

Fixes #21132

New Package?

  • Yes
  • No

Version Bump?

  • Yes
  • No

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Added regression coverage for the affected public exports.

Tested with:

  • pytest tests/test_public_exports.py -q

  • pytest tests/agent/react/test_react_chat_formatter.py -q

  • I added new unit tests to cover this change

  • I believe this change is already covered by existing unit tests

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added Google Colab support for the newly added notebooks.
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I ran uv run make format; uv run make lint to appease the lint gods

Changed files

  • llama-index-core/llama_index/core/__init__.py (modified, +9/-0)
  • llama-index-core/llama_index/core/indices/__init__.py (modified, +1/-0)
  • llama-index-core/llama_index/core/indices/knowledge_graph/__init__.py (modified, +3/-0)
  • llama-index-core/llama_index/core/prompts/__init__.py (modified, +18/-0)
  • llama-index-core/tests/test_public_exports.py (added, +38/-0)

Code Example

from llama_index.core import GPTKnowledgeGraphIndex
from llama_index.core import SummaryPrompt
from llama_index.core import *

---

from llama_index.core import GPTKnowledgeGraphIndex

---

from llama_index.core import SummaryPrompt

---

from llama_index.core import *

---

ImportError: cannot import name 'GPTKnowledgeGraphIndex' from 'llama_index.core'
ImportError: cannot import name 'SummaryPrompt' from 'llama_index.core'
AttributeError: module 'llama_index.core' has no attribute 'GPTKnowledgeGraphIndex'
RAW_BUFFERClick to expand / collapse

Bug Description

Several legacy exports are still listed in llama_index.core.__all__, but are no longer actually bound at runtime.

This causes import failures for names that appear to be part of the public API, for example:

from llama_index.core import GPTKnowledgeGraphIndex
from llama_index.core import SummaryPrompt
from llama_index.core import *

At runtime, these currently fail because:

  • GPTKnowledgeGraphIndex is listed in llama_index.core.indices.__all__, but is not actually imported/bound there
  • legacy prompt aliases such as SummaryPrompt, TreeInsertPrompt, RefinePrompt, etc. exist in llama_index.core.prompts.prompts, but are not re-exported through llama_index.core.prompts or llama_index.core

This also means from llama_index.core import * can fail with AttributeError because __all__ references names that are missing from the module object.

Version

0.14.18

Steps to Reproduce

  1. Create a clean environment and install/import llama-index-core
  2. Run:
from llama_index.core import GPTKnowledgeGraphIndex
  1. Run:
from llama_index.core import SummaryPrompt
  1. Run:
from llama_index.core import *

Relevant Logs/Tracbacks

ImportError: cannot import name 'GPTKnowledgeGraphIndex' from 'llama_index.core'
ImportError: cannot import name 'SummaryPrompt' from 'llama_index.core'
AttributeError: module 'llama_index.core' has no attribute 'GPTKnowledgeGraphIndex'

extent analysis

Fix Plan

To resolve the import failures, we need to update the __all__ list in llama_index.core to only include names that are actually bound at runtime. We also need to re-export the necessary names from submodules.

Step-by-Step Solution

  • Update llama_index.core.__init__.py to import and re-export the necessary names:
from .indices import GPTKnowledgeGraphIndex
from .prompts.prompts import SummaryPrompt, TreeInsertPrompt, RefinePrompt

__all__ = [
    'GPTKnowledgeGraphIndex',
    'SummaryPrompt',
    'TreeInsertPrompt',
    'RefinePrompt',
    # ... other valid names
]
  • Remove any names from __all__ that are not actually bound at runtime.

Example Use Case

After applying the fix, the following imports should work:

from llama_index.core import GPTKnowledgeGraphIndex
from llama_index.core import SummaryPrompt
from llama_index.core import *

Verification

To verify that the fix worked, run the steps to reproduce the issue again. The imports should no longer fail with ImportError or AttributeError.

Extra Tips

  • Make sure to update the documentation to reflect the changes to the public API.
  • Consider using a linter or code analyzer to detect similar issues in the future.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

llamaIndex - ✅(Solved) Fix [Bug]: `llama_index.core` top-level legacy exports are listed in `__all__` but missing at runtime [1 pull requests, 4 comments, 3 participants]