ragrank.prompt.base
base fo the the prompt module
- class ragrank.prompt.base.Prompt(*, name: str, instructions: str, examples: List[Dict[str, Any]] = None, input_keys: List[str], output_key: str)
Represents a prompt for the Language Learning Model (LLM).
- name
The name of the prompt.
- Type:
str
- instructions
The instructions for the prompt.
- Type:
str
- examples
List of example inputs and outputs.
- Type:
List[Example]
- input_keys
List of input keys.
- Type:
List[str]
- output_key
Key for the output.
- Type:
str
- get_examples(example_no: int | None = None) str
Retrieve examples from the prompt.
- Parameters:
example_no (Optional[int]) – The number of examples to retrieve.
- Returns:
List of example inputs and outputs.
- Return type:
List[Example]
- Raises:
IndexError – If example number is out of range.
- load() None
Load the saved object from the system
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ConfigDict = {'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'examples': FieldInfo(annotation=List[Dict[str, Any]], required=False, default_factory=list, description='List of example inputs and outputs.', repr=False), 'input_keys': FieldInfo(annotation=List[str], required=True, description='List of input keys.', repr=False), 'instructions': FieldInfo(annotation=str, required=True, description='The instructions for the prompt.', repr=False), 'name': FieldInfo(annotation=str, required=True, description='The name of the prompt.'), 'output_key': FieldInfo(annotation=str, required=True, description='Key for the output.', 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.
- save() None
Save the object locally
- to_string() str
Convert the prompt to a string representation.
- Returns:
String representation of the prompt.
- Return type:
str