Skip to content

refactor(providers): remove deprecated text-completion provider helpers#1924

Open
adityasingh2400 wants to merge 2 commits into
NVIDIA-NeMo:developfrom
adityasingh2400:adityasingh2400/remove-text-completion-deprecations
Open

refactor(providers): remove deprecated text-completion provider helpers#1924
adityasingh2400 wants to merge 2 commits into
NVIDIA-NeMo:developfrom
adityasingh2400:adityasingh2400/remove-text-completion-deprecations

Conversation

@adityasingh2400
Copy link
Copy Markdown

@adityasingh2400 adityasingh2400 commented May 23, 2026

Closes #1774.

Removes the text-completion provider surface that was deprecated for the 0.23.0 release. On the public side this drops register_llm_provider and get_llm_provider_names from nemoguardrails/llm/providers along with the matching methods on LangChainFramework. Internally it removes the _llm_providers registry, _discover_langchain_community_llm_providers, _patch_acall_method_to, _get_text_completion_provider, _init_text_completion_model, _init_gpt35_turbo_instruct, and the mode parameter that flowed through init_llm_model, LangChainFramework.create_model, and init_langchain_model. The CLI provider picker now shows only chat-completion providers, the warnings.catch_warnings suppression around the deprecated calls is gone, and the custom LLM provider documentation no longer covers BaseLLM registration. Existing tests for the deprecated paths are removed; tests for the surrounding live paths are kept or updated to the chat-only flow and pass against the new initializer chain.

The 0.22.0 release just shipped, so the surface change lands cleanly on develop for 0.23.0.

Summary by CodeRabbit

  • Breaking Changes

    • Text completion (LLM) providers removed; only chat completion providers supported
    • register_llm_provider removed; use register_chat_provider instead
    • Custom providers must inherit from BaseChatModel instead of BaseLLM
  • Documentation

    • Updated configuration guide to reflect chat-only support and removal of text completion providers
  • Examples

    • Updated Hugging Face pipeline examples (Dolly, Falcon, Llama2, Mosaic, Vicuna) to use chat provider registration
  • CLI

    • Simplified provider selection to chat completion only

Review Change Stack

Closes NVIDIA-NeMo#1774.

Drops the deprecated text-completion provider surface scheduled for
removal in 0.23.0: register_llm_provider and get_llm_provider_names
from nemoguardrails/llm/providers, the matching methods on
LangChainFramework, the _llm_providers registry,
_discover_langchain_community_llm_providers, _patch_acall_method_to,
_get_text_completion_provider, _init_text_completion_model,
_init_gpt35_turbo_instruct, and the mode parameter on init_llm_model
and LangChainFramework.create_model. The CLI provider picker now lists
only chat completion providers and the docs no longer reference BaseLLM
custom registration. Tests that exercised the removed paths are
updated, converted to chat equivalents, or removed.

Signed-off-by: Aditya Singh <adisin650@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

Documentation preview

https://nvidia-nemo.github.io/Guardrails/review/pr-1924

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 23, 2026

📝 Walkthrough

Walkthrough

This PR removes deprecated text completion provider support and refactors LLM initialization to chat-model-only operations. It eliminates the mode parameter, removes text-completion initializers and provider-discovery infrastructure, updates example configurations, simplifies the CLI, and removes related test coverage across the codebase.

Changes

Text Completion Removal and Chat-Only Refactoring

Layer / File(s) Summary
Documentation and example configuration updates
docs/configure-rails/custom-initialization/custom-llm-providers.md, examples/configs/llm/hf_pipeline_*/config.py
Removed text completion provider documentation and guidance; updated five Hugging Face pipeline examples to use register_chat_provider instead of register_llm_provider.
LangChain initializer refactoring to chat-only
nemoguardrails/integrations/langchain/langchain_initializer.py
Removed text-completion initializer, simplified ModelInitMethod/ModelInitializer to return only BaseChatModel, and refactored init_langchain_model signature and _handle_model_special_cases dispatch for chat-only initialization.
Remove mode parameter from LLM model initialization
nemoguardrails/llm/models/initializer.py
Removed mode parameter from init_llm_model public API and stopped injecting mode into model kwargs.
Provider framework and registry cleanup
nemoguardrails/integrations/langchain/llm_adapter.py, nemoguardrails/integrations/langchain/providers/providers.py
Simplified LangChainFramework.get_provider_names() to return only chat providers and removed LLM provider methods; removed text-completion discovery, LLM registration, and async patching infrastructure.
Remove deprecated provider APIs from public exports
nemoguardrails/llm/providers/__init__.py, nemoguardrails/integrations/langchain/providers/__init__.py
Deleted register_llm_provider and get_llm_provider_names exports; updated package exports to include only chat provider APIs.
CLI provider selection simplification
nemoguardrails/cli/__init__.py, nemoguardrails/cli/providers.py
Removed select_provider_with_type, ProviderType enum, and mode-branching logic; updated find_providers command to select single chat providers.
Framework wiring and configuration updates
nemoguardrails/integrations/langchain/llm_adapter.py, nemoguardrails/rails/llm/llmrails.py, nemoguardrails/evaluate/utils.py
Updated framework to strip mode from kwargs and removed explicit mode arguments from LLM initialization calls.
Core LangChain initializer test refactoring
tests/integrations/langchain/llm/models/test_langchain_initializer.py
Rewrote mock fixtures and tests to cover only three initializer paths (special-cases, chat-completion, community-chat); updated all tests to use new signature without mode parameter.
Initialization scenarios test refactoring
tests/integrations/langchain/llm/models/test_langchain_init_scenarios.py
Refactored test suite to focus on chat-mode initialization with simplified test classes and new register_special_provider helper; removed text-completion and broad parameterized test coverage.
Initialization methods and special cases test cleanup
tests/integrations/langchain/llm/models/test_langchain_initialization_methods.py, tests/integrations/langchain/llm/models/test_langchain_special_cases.py
Removed TestTextCompletionInitializer class and GPT-3.5 Turbo Instruct / text-completion OpenAI test coverage.
Provider registration and discovery test cleanup
tests/integrations/langchain/llm/providers/test_providers.py, tests/integrations/langchain/llm/providers/test_deprecated_providers.py, tests/integrations/langchain/llm/providers/test_trtllm_provider.py
Refactored test_providers.py to test only chat providers and removed LLM provider tests; deleted test_deprecated_providers.py and test_trtllm_provider.py.
LangChain integration test updates
tests/integrations/langchain/llm/test_langchain_integration.py
Removed LLM-related imports and fixtures; removed LLM provider discovery tests and OpenAI text-completion/mode-based test coverage.
Version compatibility test refactoring
tests/integrations/langchain/llm/test_version_compatibility.py
Removed LLM provider constants, critical LLM provider tests, and LLM compatibility checks; added chat-only registry stability test.
Custom chat model test config implementation
tests/integrations/langchain/test_configs/with_custom_chat_model/config.yml, tests/integrations/langchain/test_configs/with_custom_chat_model/custom_chat_model.py
Rewrote CustomChatModel to implement _generate/_agenerate chat hooks; updated config to use custom_chat_model engine.
Remove custom LLM test configuration
tests/integrations/langchain/test_configs/with_custom_llm/config.py, tests/integrations/langchain/test_configs/with_custom_llm/config.yml, tests/integrations/langchain/test_configs/with_custom_llm/custom_llm.py
Deleted CustomLLM implementation and registration config; emptied YAML and Python config files.
Custom provider test updates
tests/integrations/langchain/test_custom_llm.py, tests/integrations/langchain/test_server_streaming.py, tests/integrations/langchain/test_streaming.py
Updated custom provider tests to register and test only chat providers; removed text-completion provider test coverage.
Framework provider registry test updates
tests/llm/frameworks/test_registry.py
Removed LLM provider deprecation tests and fixture LLM backup logic; added chat-provider-only get_provider_names() assertion.
Provider selection CLI test updates
tests/cli/test_cli_main.py, tests/cli/test_llm_providers.py, tests/test_provider_selection.py
Updated tests to mock and assert only select_provider (single chat provider); removed select_provider_with_type test coverage.
Remaining test import and assertion updates
tests/integrations/langchain/test_langchain_llm_adapter.py, tests/test_imports.py, tests/test_providers.py, tests/test_supported_llm_providers.py
Updated imports and assertions to remove LLM provider references and align with chat-provider-only expectations.

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly Related PRs

  • NVIDIA-NeMo/Guardrails#1772: Overlaps with LangChain initializer and provider wiring refactoring (langchain_initializer.py, llm_adapter.py), potentially addressing related modernization of initialization/provider logic.

Suggested Labels

refactoring

Suggested Reviewers

  • tgasser-nv
🚥 Pre-merge checks | ✅ 4 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Test Results For Major Changes ⚠️ Warning PR contains major breaking changes (removed public APIs, changed function signatures, modified 45+ files) but lacks explicit test results or execution information in the PR description. Include test execution results, CI workflow status, or explicit statement confirming tests pass with the major API changes in the PR description.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor(providers): remove deprecated text-completion provider helpers' directly and clearly describes the main purpose of the PR, which is removing deprecated text-completion (LLM) provider APIs.
Linked Issues check ✅ Passed All objectives from issue #1774 have been comprehensively addressed: deprecated functions (register_llm_provider, get_llm_provider_names) removed [#1774], internal registries and helpers removed [#1774], initializer parameters removed [#1774], CLI simplified [#1774], and tests updated/removed [#1774].
Out of Scope Changes check ✅ Passed All changes are scoped to removing deprecated text-completion provider code. No unrelated features or refactorings are introduced outside the specified deprecation removal objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
tests/integrations/langchain/llm/models/test_langchain_init_scenarios.py (1)

246-253: 💤 Low value

Remove redundant direct assignment to _chat_providers.

Line 250 duplicates what registry.register_chat(provider, None) already does on line 249. The register_chat method sets _chat_providers[name] = None when provider_cls is None.

♻️ Suggested fix
     def test_none_provider_handled(self, registry):
         """Provider registered as None doesn't crash."""
         provider = "_test_none"
         registry.register_chat(provider, None)
-        _chat_providers[provider] = None

         with pytest.raises((ModelInitializationError, TypeError, AttributeError)):
             init_langchain_model("test-model", provider, {})
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/integrations/langchain/llm/models/test_langchain_init_scenarios.py`
around lines 246 - 253, Remove the redundant direct assignment to the
module-global _chat_providers in the test_none_provider_handled function: keep
the call to registry.register_chat(provider, None) (which already sets
_chat_providers[name] = None) and delete the subsequent line
"_chat_providers[provider] = None" so the test only uses registry.register_chat
and avoids duplicating internal state setup.
nemoguardrails/integrations/langchain/langchain_initializer.py (1)

21-21: 💤 Low value

Remove unused Union import.

After the refactor to chat-only types, Union is no longer used in this file. All return types are now Optional[BaseChatModel] or BaseChatModel.

♻️ Suggested fix
-from typing import Any, Callable, Dict, Optional, Union
+from typing import Any, Callable, Dict, Optional
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nemoguardrails/integrations/langchain/langchain_initializer.py` at line 21,
The import list in langchain_initializer.py still includes an unused symbol
`Union`; remove `Union` from the typing import so the line reads only the used
names (e.g., `Any, Callable, Dict, Optional`), and ensure any functions or
return annotations (such as those returning `Optional[BaseChatModel]` or
`BaseChatModel`) remain unchanged; update the `from typing import ...` statement
to drop `Union` and run tests/linting to confirm no other references exist.
tests/integrations/langchain/llm/models/test_langchain_special_cases.py (1)

86-89: 💤 Low value

Minor: Extra space in skip reason.

There's a double space in "Requires NVIDIA" on line 88.

✏️ Suggested fix
     `@pytest.mark.skipif`(
         not has_nvidia_ai_endpoints(),
-        reason="Requires  NVIDIA AI Endpoints package",
+        reason="Requires NVIDIA AI Endpoints package",
     )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/integrations/langchain/llm/models/test_langchain_special_cases.py`
around lines 86 - 89, The skip decorator's reason string contains a double
space; update the pytest.mark.skipif(reason="Requires  NVIDIA AI Endpoints
package") to remove the extra space so it reads "Requires NVIDIA AI Endpoints
package" (locate the decorator using pytest.mark.skipif and the
has_nvidia_ai_endpoints() check).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@nemoguardrails/integrations/langchain/langchain_initializer.py`:
- Line 21: The import list in langchain_initializer.py still includes an unused
symbol `Union`; remove `Union` from the typing import so the line reads only the
used names (e.g., `Any, Callable, Dict, Optional`), and ensure any functions or
return annotations (such as those returning `Optional[BaseChatModel]` or
`BaseChatModel`) remain unchanged; update the `from typing import ...` statement
to drop `Union` and run tests/linting to confirm no other references exist.

In `@tests/integrations/langchain/llm/models/test_langchain_init_scenarios.py`:
- Around line 246-253: Remove the redundant direct assignment to the
module-global _chat_providers in the test_none_provider_handled function: keep
the call to registry.register_chat(provider, None) (which already sets
_chat_providers[name] = None) and delete the subsequent line
"_chat_providers[provider] = None" so the test only uses registry.register_chat
and avoids duplicating internal state setup.

In `@tests/integrations/langchain/llm/models/test_langchain_special_cases.py`:
- Around line 86-89: The skip decorator's reason string contains a double space;
update the pytest.mark.skipif(reason="Requires  NVIDIA AI Endpoints package") to
remove the extra space so it reads "Requires NVIDIA AI Endpoints package"
(locate the decorator using pytest.mark.skipif and the has_nvidia_ai_endpoints()
check).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4f4b98ba-869c-4659-8c86-6d7b3bca093e

📥 Commits

Reviewing files that changed from the base of the PR and between e3715f9 and bbd91d1.

📒 Files selected for processing (42)
  • docs/configure-rails/custom-initialization/custom-llm-providers.md
  • examples/configs/llm/hf_pipeline_dolly/config.py
  • examples/configs/llm/hf_pipeline_falcon/config.py
  • examples/configs/llm/hf_pipeline_llama2/config.py
  • examples/configs/llm/hf_pipeline_mosaic/config.py
  • examples/configs/llm/hf_pipeline_vicuna/config.py
  • nemoguardrails/cli/__init__.py
  • nemoguardrails/cli/providers.py
  • nemoguardrails/evaluate/utils.py
  • nemoguardrails/integrations/langchain/langchain_initializer.py
  • nemoguardrails/integrations/langchain/llm_adapter.py
  • nemoguardrails/integrations/langchain/providers/__init__.py
  • nemoguardrails/integrations/langchain/providers/providers.py
  • nemoguardrails/llm/models/initializer.py
  • nemoguardrails/llm/providers/__init__.py
  • nemoguardrails/rails/llm/llmrails.py
  • tests/cli/test_cli_main.py
  • tests/cli/test_llm_providers.py
  • tests/integrations/langchain/llm/models/test_langchain_init_scenarios.py
  • tests/integrations/langchain/llm/models/test_langchain_initialization_methods.py
  • tests/integrations/langchain/llm/models/test_langchain_initializer.py
  • tests/integrations/langchain/llm/models/test_langchain_special_cases.py
  • tests/integrations/langchain/llm/providers/test_deprecated_providers.py
  • tests/integrations/langchain/llm/providers/test_providers.py
  • tests/integrations/langchain/llm/providers/test_trtllm_provider.py
  • tests/integrations/langchain/llm/test_langchain_integration.py
  • tests/integrations/langchain/llm/test_version_compatibility.py
  • tests/integrations/langchain/test_configs/with_custom_chat_model/config.yml
  • tests/integrations/langchain/test_configs/with_custom_chat_model/custom_chat_model.py
  • tests/integrations/langchain/test_configs/with_custom_llm/config.co
  • tests/integrations/langchain/test_configs/with_custom_llm/config.py
  • tests/integrations/langchain/test_configs/with_custom_llm/config.yml
  • tests/integrations/langchain/test_configs/with_custom_llm/custom_llm.py
  • tests/integrations/langchain/test_custom_llm.py
  • tests/integrations/langchain/test_langchain_llm_adapter.py
  • tests/integrations/langchain/test_server_streaming.py
  • tests/integrations/langchain/test_streaming.py
  • tests/llm/frameworks/test_registry.py
  • tests/test_imports.py
  • tests/test_provider_selection.py
  • tests/test_providers.py
  • tests/test_supported_llm_providers.py
💤 Files with no reviewable changes (13)
  • nemoguardrails/integrations/langchain/providers/init.py
  • tests/integrations/langchain/test_configs/with_custom_llm/config.co
  • tests/integrations/langchain/llm/providers/test_deprecated_providers.py
  • tests/integrations/langchain/llm/providers/test_trtllm_provider.py
  • tests/integrations/langchain/test_configs/with_custom_llm/config.yml
  • tests/integrations/langchain/test_configs/with_custom_llm/custom_llm.py
  • nemoguardrails/rails/llm/llmrails.py
  • tests/test_supported_llm_providers.py
  • tests/integrations/langchain/test_configs/with_custom_llm/config.py
  • tests/test_providers.py
  • nemoguardrails/evaluate/utils.py
  • nemoguardrails/llm/providers/init.py
  • tests/integrations/langchain/test_custom_llm.py

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 23, 2026

Greptile Summary

This PR removes the deprecated text-completion provider surface ahead of the 0.23.0 release, dropping register_llm_provider, get_llm_provider_names, _llm_providers, _discover_langchain_community_llm_providers, _patch_acall_method_to, _get_text_completion_provider, _init_text_completion_model, _init_gpt35_turbo_instruct, and the mode parameter from the initialization chain. The CLI provider picker, documentation, and tests are all updated to the chat-only flow.

  • The mode parameter is purged end-to-end: removed from init_llm_model, from LangChainFramework.create_model (which now silently pops it for back-compat with existing configs), and from LLMRails.
  • ModelInitializer is simplified to three initializers (_handle_model_special_cases_init_chat_completion_model_init_community_chat_models), and the supported_modes guard is gone.
  • The trtllm provider subtree (providers/trtllm/) is now unreferenced by any active code path; server/schemas/utils.py still lists trt_llm in PROVIDERS, which will surface as a runtime error for any config that sets engine: trt_llm (noted in a prior review thread).

Confidence Score: 4/5

The core deletion is clean and internally consistent, but the trtllm provider subtree and its server-schema entry are stranded, and the five hf_pipeline examples register a BaseLLM subclass through the new chat-only path.

The initializer chain, CLI, and public API changes are all correct and well-tested. Two loose ends remain: the trtllm directory is unreachable dead code, and server/schemas/utils.py still advertises trt_llm as a valid engine while the initialization chain will now raise a RuntimeError for any config that sets engine: trt_llm. Both were called out in prior review comments but are unresolved in the current head commit.

nemoguardrails/server/schemas/utils.py (trt_llm entry), nemoguardrails/integrations/langchain/providers/trtllm/ (entire subtree), examples/configs/llm/hf_pipeline_*/config.py (five files registering BaseLLM as a chat provider)

Important Files Changed

Filename Overview
nemoguardrails/integrations/langchain/langchain_initializer.py Removes _init_text_completion_model, _init_gpt35_turbo_instruct, _SPECIAL_MODEL_INITIALIZERS, and the mode parameter from the entire initializer chain; simplifies ModelInitializer to three chat-only initializers.
nemoguardrails/integrations/langchain/providers/providers.py Drops _llm_providers, _discover_langchain_community_llm_providers, _patch_acall_method_to, register_llm_provider, get_llm_provider_names, and _get_text_completion_provider; the trtllm import removed leaving the subtree as dead code.
nemoguardrails/integrations/langchain/llm_adapter.py Removes register_llm_provider and get_llm_provider_names from LangChainFramework; create_model now silently pops mode from kwargs for backward compatibility with existing configs.
nemoguardrails/llm/providers/init.py Fully removes the deprecated register_llm_provider and get_llm_provider_names public API; register_chat_provider and get_chat_provider_names remain as the sole public surface.
nemoguardrails/llm/models/initializer.py Removes mode parameter from init_llm_model; no longer injects mode into model_kwargs before delegating to the framework.
nemoguardrails/rails/llm/llmrails.py Removes mode='chat' and mode=llm_config.mode from both init_llm_model call sites; the rest of the initialization path is unchanged.
nemoguardrails/cli/providers.py Drops select_provider_type, select_provider_with_type, and the two-step provider-type picker; find_providers now calls select_provider() directly against chat-only providers.
examples/configs/llm/hf_pipeline_dolly/config.py Calls register_chat_provider with a BaseLLM subclass; all five hf_pipeline examples share this mismatch (covered in prior review thread).

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["init_llm_model(model_name, provider_name, kwargs)"] --> B["LangChainFramework.create_model()"]
    B --> C["kwargs.pop('mode', None)\n(back-compat silent drop)"]
    C --> D["init_langchain_model(model_name, provider_name, kwargs)"]
    D --> E["#1 _handle_model_special_cases\n(nvidia_ai_endpoints / nim)"]
    E -->|"returns model"| Z["LangChainLLMAdapter(raw_llm)"]
    E -->|"returns None"| F["#2 _init_chat_completion_model\n(langchain init_chat_model)"]
    F -->|"returns model"| Z
    F -->|"returns None"| G["#3 _init_community_chat_models\n(community chat models)"]
    G -->|"returns model"| Z
    G -->|"returns None"| H["ModelInitializationError"]
Loading

Reviews (2): Last reviewed commit: "fix(providers): address CI lint and test..." | Re-trigger Greptile

HFPipelineDolly = get_llm_instance_wrapper(llm_instance=get_dolly_v2_3b_llm(), llm_type="hf_pipeline_dolly")

register_llm_provider("hf_pipeline_dolly", HFPipelineDolly)
register_chat_provider("hf_pipeline_dolly", HFPipelineDolly)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 BaseLLM subclass registered as a chat provider

get_llm_instance_wrapper returns a WrapperLLM class that inherits from LangChain's LLM (a BaseLLM subclass), not from BaseChatModel. After this PR, all five hf_pipeline_* examples now call register_chat_provider with this class, so it lands in _chat_providers and is returned from _init_community_chat_models.

At runtime, LangChainLLMAdapter.generate_async calls llm.ainvoke(messages) on a BaseLLM instance; LangChain converts the chat message list to a flat string before dispatching to the text-completion endpoint. The adapter then receives a raw string response and falls back to content = str(response). The same mismatch applies to all five hf_pipeline_* configs (dolly, falcon, llama2, mosaic, vicuna).

These examples will silently produce incorrect output rather than raising a type error. They either need a proper BaseChatModel wrapper or should be removed alongside the text-completion surface.

Prompt To Fix With AI
This is a comment left during a code review.
Path: examples/configs/llm/hf_pipeline_dolly/config.py
Line: 65

Comment:
**`BaseLLM` subclass registered as a chat provider**

`get_llm_instance_wrapper` returns a `WrapperLLM` class that inherits from LangChain's `LLM` (a `BaseLLM` subclass), not from `BaseChatModel`. After this PR, all five `hf_pipeline_*` examples now call `register_chat_provider` with this class, so it lands in `_chat_providers` and is returned from `_init_community_chat_models`.

At runtime, `LangChainLLMAdapter.generate_async` calls `llm.ainvoke(messages)` on a `BaseLLM` instance; LangChain converts the chat message list to a flat string before dispatching to the text-completion endpoint. The adapter then receives a raw string response and falls back to `content = str(response)`. The same mismatch applies to all five `hf_pipeline_*` configs (`dolly`, `falcon`, `llama2`, `mosaic`, `vicuna`).

These examples will silently produce incorrect output rather than raising a type error. They either need a proper `BaseChatModel` wrapper or should be removed alongside the text-completion surface.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 86 to 87
_chat_providers: Dict[str, Type[BaseChatModel]]

_llm_providers.update(_discover_langchain_community_llm_providers())
_patch_acall_method_to(_llm_providers)
_chat_providers = _discover_langchain_community_chat_providers()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Orphaned trtllm module and stale server-layer reference

TRTLLM was the sole hard-coded entry in the now-removed _llm_providers = {"trt_llm": TRTLLM}. After this PR the entire providers/trtllm/ subtree (llm.py, client.py, __init__.py) is no longer imported, registered, or exercised by any non-deleted code. It is dead code.

Additionally, nemoguardrails/server/schemas/utils.py line 77 still lists "trt_llm": {} in the PROVIDERS dict. That dict is consulted when the server enumerates supported model providers, so it advertises trt_llm as usable while the LLM initialisation chain will raise RuntimeError: Could not find chat provider 'trt_llm' for any config that sets engine: trt_llm.

Prompt To Fix With AI
This is a comment left during a code review.
Path: nemoguardrails/integrations/langchain/providers/providers.py
Line: 86-87

Comment:
**Orphaned `trtllm` module and stale server-layer reference**

`TRTLLM` was the sole hard-coded entry in the now-removed `_llm_providers = {"trt_llm": TRTLLM}`. After this PR the entire `providers/trtllm/` subtree (`llm.py`, `client.py`, `__init__.py`) is no longer imported, registered, or exercised by any non-deleted code. It is dead code.

Additionally, `nemoguardrails/server/schemas/utils.py` line 77 still lists `"trt_llm": {}` in the `PROVIDERS` dict. That dict is consulted when the server enumerates supported model providers, so it advertises `trt_llm` as usable while the LLM initialisation chain will raise `RuntimeError: Could not find chat provider 'trt_llm'` for any config that sets `engine: trt_llm`.

How can I resolve this? If you propose a fix, please make it concise.

…oval

Drop the now-unused Union import in langchain_initializer, apply ruff
format to the two files affected by the deprecation removal, and remove
the stale mode assertion from the API key environment variable test now
that init_llm_model no longer accepts a mode parameter.

Signed-off-by: Aditya Singh <adisin650@gmail.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

backlog: Remove text completion provider deprecations in 0.23.0

1 participant