Class LLMContext

Base Type

  • public std::enable_shared_from_this< LLMContext >

class LLMContext : public std::enable_shared_from_this<LLMContext>

Holds and manages information related to LLM tasks and input mappings required for LLMNode execution. Outputs of node executions are also saved here for use by nodes and task handlers in LLMEngine.

Public Functions

LLMContext()

Construct a new LLMContext object.

LLMContext(LLMTask task, std::shared_ptr<ControlMessage> message)

Construct a new LLMContext object.

Parameters
  • task – task for new context

  • message – control message for new context

LLMContext(std::shared_ptr<LLMContext> parent, std::string name, input_mappings_t inputs)

Construct a new LLMContext object.

Parameters
  • parent – parent context

  • name – new context name

  • inputs – input mappings for new context

~LLMContext()

Destroy the LLMContext object.

std::shared_ptr<LLMContext> parent() const

Get parent context.

Returns

std::shared_ptr<LLMContext>

const std::string &name() const

Get name of context.

Returns

const std::string&

const input_mappings_t &input_map() const

Get map of internal mappings for this context.

Returns

const input_mappings_t&

const LLMTask &task() const

Get task for this context.

Returns

const LLMTask&

std::shared_ptr<ControlMessage> &message() const

Get control message for this context.

Returns

std::shared_ptr<ControlMessage>&

nlohmann::json::const_reference all_outputs() const

Get all output mappings for this context.

Returns

nlohmann::json::const_reference

std::string full_name() const

Get full name of context containing parents up to root.

Returns

std::string

std::shared_ptr<LLMContext> push(std::string name, input_mappings_t inputs)

Create new context from this context using provided name and input mappings.

Parameters
  • name – name of new context

  • inputs – input mappings for new context

Returns

std::shared_ptr<LLMContext>

void pop()

Moves output map from this context to parent context. Outputs to move can be selected using set_output_names, otherwise all outputs are noved by default.

nlohmann::json::const_reference get_input() const

Get the input value from parent context corresponding to first internal input of this context.

Returns

nlohmann::json::const_reference

nlohmann::json::const_reference get_input(const std::string &node_name) const

Get the parent output value corresponding to given internal input name.

Parameters

node_name – internal input name

Returns

nlohmann::json::const_reference

nlohmann::json get_inputs() const

Get parent output values corresponding to all internal input names.

Returns

nlohmann::json

void set_output(nlohmann::json outputs)

Set output mappings for this context.

Parameters

outputs – output mappings

void set_output(const std::string &output_name, nlohmann::json output)

Set an output value for this context.

Parameters
  • output_name – output name

  • output – output value

void set_output_names(std::vector<std::string> output_names)

Set the output names to propagate from this context when using pop.

Parameters

output_names – output names to propagate

void outputs_complete()

nlohmann::json::const_reference view_outputs() const

Previous Class Listener
Next Class LLMEngine
© Copyright 2024, NVIDIA. Last updated on Apr 11, 2024.