Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions nemoguardrails/llm/models/langchain_initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ def _init_text_completion_model(
if provider_cls is None:
raise ValueError()
kwargs = _update_model_kwargs(provider_cls, model_name, kwargs)
# remove stream_usage parameter as it's not supported by text completion APIs
# (e.g., OpenAI's AsyncCompletions.create() doesn't accept this parameter)
kwargs.pop("stream_usage", None)
Copy link

Copilot AI Jul 10, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider extracting the "stream_usage" key into a shared constant or documenting it in the function docstring to avoid magic strings and make the removal rationale more discoverable.

Suggested change
kwargs.pop("stream_usage", None)
kwargs.pop(STREAM_USAGE_KEY, None)

Copilot uses AI. Check for mistakes.
return provider_cls(**kwargs)


Expand Down