morpheus_llm.llm.nodes.rag_node.RAGNode#
- class RAGNode(
- *,
- prompt,
- template_format='jinja',
- vdb_service,
- embedding=None,
- llm_client,
Bases:
LLMNodePerforms Retrieval Augmented Generation (RAG).
- Parameters:
- promptstr
The prompt template string to populate with input values.
- template_formatstr, optional default=”jinja”
The format of the template string. Must be one of: f-string, jinja.
- vdb_serviceVectorDBResourceService
The VectorDB service to use for retrieval.
- embeddingCallable[[list[str]], Coroutine[Any, Any, list[list[float]]]], optional
An asynchronous function to use to determine the embeddings to search the
vdb_servicefor. IfNone, upstream nodes must provide the embeddings.- llm_clientLLMClient
The LLM client to use for generation.
Methods
add_node(self, name, *[, inputs, is_output])Add an LLMNode to the current node.
execute(self, context)Execute the current node with the given
contextinstance.get_input_names(self)Get the input names for the node.
- add_node(
- self: morpheus_llm._lib.llm.LLMNode,
- name: str,
- *,
- inputs: object = None,
- node: morpheus_llm._lib.llm.LLMNodeBase,
- is_output: bool = False,
Add an LLMNode to the current node.
- Parameters:
- namestr
The name of the node to add
- inputslist[tuple[str, str]], optional
List of input mappings to use for the node, in the form of
[(external_name, internal_name), ...]If unspecified the node’s input_names will be used.- nodeLLMNodeBase
The node to add
- is_outputbool, optional
Indicates if the node is an output node, by default False
- execute(
- self: morpheus_llm._lib.llm.LLMNodeBase,
- context: morpheus_llm._lib.llm.LLMContext,
Execute the current node with the given
contextinstance.All inputs for the given node should be fetched from the context, typically by calling either
context.get_inputsto fetch all inputs as adict, orcontext.get_inputto fetch a specific input.Similarly the output of the node is written to the context using
context.set_output.- Parameters:
- context
morpheus._lib.llm.LLMContext Context instance to use for the execution
- context