morpheus.llm.nodes.rag_node.RAGNode
- class RAGNode(*, prompt, template_format='jinja', vdb_service, embedding=None, llm_client)[source]
Bases:
morpheus._lib.llm.LLMNode
Performs Retrieval Augmented Generation (RAG).
- Parameters
- prompt
- template_format
- vdb_service
- embedding
- llm_client
The prompt template string to populate with input values.
The format of the template string. Must be one of: f-string, jinja.
The VectorDB service to use for retrieval.
An asynchronous function to use to determine the embeddings to search the
vdb_service
for. IfNone
, upstream nodes must provide the embeddings.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 context
instance.get_input_names
(self)Get the input names for the node. - add_node(self: morpheus._lib.llm.LLMNode, name: str, *, inputs: object = None, node: morpheus._lib.llm.LLMNodeBase, is_output: bool = False) → morpheus._lib.llm.LLMNodeRunner
Add an LLMNode to the current node.
- Parameters
- name
- inputs
- node
- is_output
The name of the node to add
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.The node to add
Indicates if the node is an output node, by default False
- execute(self: morpheus._lib.llm.LLMNodeBase, context: morpheus._lib.llm.LLMContext) → Awaitable[morpheus._lib.llm.LLMContext]
Execute the current node with the given
context
instance.All inputs for the given node should be fetched from the context, typically by calling either
context.get_inputs
to fetch all inputs as adict
, orcontext.get_input
to 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 :
- get_input_names(self: morpheus._lib.llm.LLMNodeBase) → List[str]
Get the input names for the node.
- Returns
- list[str]
The input names for the node