nemoguardrails.integrations.langchain.llm_adapter
nemoguardrails.integrations.langchain.llm_adapter
Module Contents
Classes
Functions
Data
API
async
model_name
provider_name
provider_url
async
async
Bases: NamedTuple
finish_reason
model
request_id
stop_sequence
Helper to infer the model name based from an LLM instance.
Because not all models implement correctly _identifying_params from LangChain, we have to try to do this manually.
Infer provider name from the LLM’s module path.
This function extracts the provider name from LangChain package naming conventions:
- langchain_openai -> openai
- langchain_anthropic -> anthropic
- langchain_google_genai -> google_genai
- langchain_nvidia_ai_endpoints -> nvidia_ai_endpoints
- langchain_community.chat_models.ollama -> ollama
For patched/wrapped classes, checks base classes as well.
Parameters:
llm
The LLM instance
Returns: Optional[str]
The inferred provider name, or None if it cannot be determined