ragrank.integrations.langchain.langchain_llm_wrapper

Module for all of the langchain models in the langchain

class ragrank.integrations.langchain.langchain_llm_wrapper.LangchainLLMWrapper(*, llm_config: LLMConfig = None, llm: Any)

Wrapper class for Langchain Language Models.

llm

The Langchain Language Model.

Type:

LangchainBaseLLM

Properties:

name (str): Get the name of the Langchain LLM Wrapper. llm_name (str): Get the name of the wrapped Langchain LLM.

generate_text()

Generate text using the Langchain LLM.

generate_text(text: str) LLMResult

Generate text using the Langchain LLM.

Parameters:

text (str) – The input text.

Returns:

The generated text result.

Return type:

LLMResult

property llm_name: str

Get the name of the wrapped Langchain LLM.

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ConfigDict = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'llm': FieldInfo(annotation=Any, required=True, description='The Langchain Language Model.'), 'llm_config': FieldInfo(annotation=LLMConfig, required=False, default_factory=LLMConfig, repr=False)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

property name: str

Get the name of the Langchain LLM Wrapper.

classmethod validator(v: BaseLanguageModel) BaseLanguageModel

Validating the langchain base language seperately Doing this because of the conflict in the v1 pydantic module.

Raises:

TypeError – If the type of the langchain llm is not valid

class ragrank.integrations.langchain.langchain_llm_wrapper.RagrankPromptValue(*, prompt_str: str)

Wrapper class for prompts used with Ragrank.

prompt_str

The prompt string.

Type:

str

to_messages() List[BaseMessage]

Convert the prompt to a list of BaseMessage objects.

to_string() str

Convert the prompt to a string.