eleanor.llm.chain
Chain management module
This implements a configuration and global registry for LLM chains.
Attributes
Classes
Functions
build_prompt_from_template
build_prompt_from_template(
template: str,
llm_settings: LLMSettings,
mapper_to_str_kwargs: Dict[str, Any] | None = None,
output_parser: BaseOutputParser | None = None,
) -> Tuple[PromptTemplate, RunnableSerializable | None]
Builds a prompt template and a corresponding output parser based on the given template string and settings.
Parameters:
-
template
(str
) –The template string for the prompt.
-
llm_settings
(LLMSettings
) –The settings for the language model.
-
mapper_to_str_kwargs
(Dict[str, Any] | None
, default:None
) –Additional keyword arguments for the mapper’s
to_str
method. Defaults to None. -
output_parser
(BaseOutputParser | None
, default:None
) –The output parser to be used. Defaults to None.
Returns:
-
Tuple[PromptTemplate, RunnableSerializable | None]
–Tuple[PromptTemplate, RunnableSerializable]: A tuple containing the prompt template and the derived output parser.
register_chain
register_chain(
name: str,
chain_builder: ChainBuilder,
chain: RunnableSequence,
) -> None
Register a chain with the chain builder.
Parameters:
-
chain
(Any
) –Chain to register