From c0defafa6e0fec0d4c2a8fe0dff3d8a01dc69061 Mon Sep 17 00:00:00 2001 From: Lijuan Tang Date: Sun, 31 May 2026 19:26:22 -0700 Subject: [PATCH] fix(graphrag-llm): accept non-OpenAI service_tier values 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 #2389 --- .../next-release/patch-2026053119245844167500.json | 4 ++++ packages/graphrag-llm/graphrag_llm/types/types.py | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 .semversioner/next-release/patch-2026053119245844167500.json diff --git a/.semversioner/next-release/patch-2026053119245844167500.json b/.semversioner/next-release/patch-2026053119245844167500.json new file mode 100644 index 0000000000..a3849c8fc5 --- /dev/null +++ b/.semversioner/next-release/patch-2026053119245844167500.json @@ -0,0 +1,4 @@ +{ + "type": "patch", + "description": "Allow non-OpenAI service_tier values in LLMCompletionResponse so indexing does not fail with LiteLLM-routed providers (e.g. Gemini via OpenRouter)." +} \ No newline at end of file diff --git a/packages/graphrag-llm/graphrag_llm/types/types.py b/packages/graphrag-llm/graphrag_llm/types/types.py index 0980cba3aa..e2b8c2213d 100644 --- a/packages/graphrag-llm/graphrag_llm/types/types.py +++ b/packages/graphrag-llm/graphrag_llm/types/types.py @@ -91,6 +91,12 @@ class LLMCompletionResponse(ChatCompletion, Generic[ResponseFormat]): provided ResponseFormat model. """ + # Widen OpenAI's strict `service_tier` literal. Non-OpenAI providers routed + # through LiteLLM (e.g. Gemini via OpenRouter) return values outside OpenAI's + # enum, which would otherwise fail pydantic validation when constructing this + # model. graphrag-llm does not use this field. See issue #2389. + service_tier: str | None = None # type: ignore + formatted_response: ResponseFormat | None = None # type: ignore """Formatted response according to the specified response_format json schema."""