ragrank.integrations.llm

ragrank.integrations.openai.openai_llm

Module for integrating OpenAI language model

All of the openai integrations

class ragrank.integrations.openai.OpenaiLLM(*, llm_config: LLMConfig = None)

Represents an OpenAI Language Model (LLM) for generating text.

This class provides methods to interact with the OpenAI language model to generate text based on user input.

name

The name of the language model.

Type:

str

generate_text()

Generates text using the OpenAI language model.

generate_text(text: str, llm_name: str = 'gpt-3.5-turbo', initial_msg: str = 'You are a helpful assistant') LLMResult

Generate text using the OpenAI language model.

Parameters:
  • text (str) – The user’s input text.

  • llm_name (str, optional) – Name of the language model. Defaults to “gpt-3.5-turbo”.

  • initial_msg (str, optional) – Initial message for the conversation. Defaults to “You are a helpful assistant”.

Returns:

Result containing the generated text and other metadata.

Return type:

LLMResult

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_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 language model.

Returns:

The name of the language model.

Return type:

str