fix: update example notebooks to use current graphrag_llm API#2327
Open
octo-patch wants to merge 1 commit intomicrosoft:mainfrom
Open
fix: update example notebooks to use current graphrag_llm API#2327octo-patch wants to merge 1 commit intomicrosoft:mainfrom
octo-patch wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…icrosoft#2301) Replace deprecated imports (ModelType, LanguageModelConfig, ModelManager) with the current graphrag_llm equivalents (ModelConfig, create_completion, create_embedding). Also fix LanceDBVectorStore import path in local_search.ipynb.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2301
Problem
The example notebooks (
local_search.ipynb,global_search.ipynb,drift_search.ipynb,global_search_with_dynamic_community_selection.ipynb) use removed/renamed APIs that no longer exist in the current codebase:from graphrag.config.enums import ModelType→ModelTypewas removed fromenums.pyfrom graphrag.config.models.language_model_config import LanguageModelConfig→ module does not existfrom graphrag.language_model.manager import ModelManager→ module does not existfrom graphrag_vectors import LanceDBVectorStore→LanceDBVectorStoreis not exported from the top-levelgraphrag_vectorspackageThese broken imports cause
ImportErrorandNameErrorwhen users try to run the example notebooks.Solution
Replace deprecated imports and model creation patterns with the current
graphrag_llmAPI:ModelType+LanguageModelConfig→ModelConfigfromgraphrag_llm.configModelManager().get_or_create_chat_model(...)→create_completion(config)fromgraphrag_llm.completionModelManager().get_or_create_embedding_model(...)→create_embedding(config)fromgraphrag_llm.embeddingget_tokenizer(config)→chat_model.tokenizer(tokenizer is already available on the model object)from graphrag_vectors import LanceDBVectorStore→from graphrag_vectors.lancedb import LanceDBVectorStoreThese replacements align the notebooks with how the
query/factory.pyinternally constructs models.Testing
Verified the corrected imports match what is actually exported by the current
graphrag_llmandgraphrag_vectorspackages in the repository.