fix(graphrag-llm): accept non-OpenAI service_tier values in LLMCompletionResponse#2390
Open
LijuanTang94 wants to merge 1 commit into
Open
fix(graphrag-llm): accept non-OpenAI service_tier values in LLMCompletionResponse#2390LijuanTang94 wants to merge 1 commit into
LijuanTang94 wants to merge 1 commit into
Conversation
Non-OpenAI providers routed through LiteLLM (e.g. Gemini via OpenRouter) return a service_tier value outside OpenAI's strict literal, which made LLMCompletionResponse(**response.model_dump()) fail pydantic validation and broke the extract_graph workflow. graphrag-llm does not use this field, so widen it to str | None in the subclass. Closes microsoft#2389
Author
|
@microsoft-github-policy-service agree |
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.
Closes #2389
Problem
Non-OpenAI providers routed through LiteLLM (e.g. Gemini via OpenRouter) return a
service_tiervalue outside OpenAI's strict literal (auto/default/flex/scale/priority). BecauseLLMCompletionResponseextendsopenai.types.chat.ChatCompletion, constructing it viaLLMCompletionResponse(**response.model_dump())inlite_llm_completion.pyfails with a pydanticliteral_error, breaking theextract_graphworkflow:Fix
service_tieris an OpenAI-specific field that graphrag-llm does not use. This overrides it in theLLMCompletionResponsesubclass to acceptstr | None, so non-standard provider values no longer fail validation. This is more robust than stripping the field on a single conversion path, as it covers every place the model is constructed.Verification
LLMCompletionResponsewith a non-OpenAIservice_tier(e.g. an OpenRouter value) now succeeds instead of raising.default) andNonestill work.contentcomputed field is unaffected.ruff check/ruff format --checkpass; semversioner change file added.