Skip to content

fix(graphrag-llm): accept non-OpenAI service_tier values in LLMCompletionResponse#2390

Open
LijuanTang94 wants to merge 1 commit into
microsoft:mainfrom
LijuanTang94:fix/issue-2389
Open

fix(graphrag-llm): accept non-OpenAI service_tier values in LLMCompletionResponse#2390
LijuanTang94 wants to merge 1 commit into
microsoft:mainfrom
LijuanTang94:fix/issue-2389

Conversation

@LijuanTang94
Copy link
Copy Markdown

Closes #2389

Problem

Non-OpenAI providers routed through LiteLLM (e.g. Gemini via OpenRouter) return a service_tier value outside OpenAI's strict literal (auto/default/flex/scale/priority). Because LLMCompletionResponse extends openai.types.chat.ChatCompletion, constructing it via LLMCompletionResponse(**response.model_dump()) in lite_llm_completion.py fails with a pydantic literal_error, breaking the extract_graph workflow:

1 validation error for LLMCompletionResponse
service_tier
  Input should be 'auto', 'default', 'flex', 'scale' or 'priority'

Fix

service_tier is an OpenAI-specific field that graphrag-llm does not use. This overrides it in the LLMCompletionResponse subclass to accept str | 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

  • Constructing LLMCompletionResponse with a non-OpenAI service_tier (e.g. an OpenRouter value) now succeeds instead of raising.
  • Standard OpenAI values (default) and None still work.
  • The content computed field is unaffected.
  • ruff check / ruff format --check pass; semversioner change file added.

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
@LijuanTang94 LijuanTang94 requested a review from a team as a code owner June 1, 2026 02:26
@LijuanTang94
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LLMCompletionResponse rejects non-OpenAI service_tier values from LiteLLM providers

1 participant