Prompt Tools 0.3.2
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
prompt::PromptBridge Class Reference

PromptBridge. More...

#include <prompt_bridge.hpp>

Inheritance diagram for prompt::PromptBridge:
Inheritance graph
[legend]
Collaboration diagram for prompt::PromptBridge:
Collaboration graph
[legend]

Public Member Functions

 PromptBridge (const rclcpp::NodeOptions &options=rclcpp::NodeOptions())
 Construct a new Prompt Bridge object.
 
void initialize ()
 Initialize the PromptBridge node.
 
 ~PromptBridge ()=default
 
std::shared_ptr< prompt::BaseClassload_prompt_model (std::string family)
 Load a prompt model plugin based on the prompt family.
 
std::shared_ptr< prompt::BaseClassload_embedding_model (std::string family)
 Load an embedding model plugin based on the embedding family.
 
std::shared_ptr< prompt::BaseClassload_tokenizer_model (std::string family)
 Load a tokenizer model plugin based on the tokenizer family.
 
void prompt_service_cb (const std::shared_ptr< PromptSrv::Request > req, std::shared_ptr< PromptSrv::Response > res)
 prompt service callback for instance prompts
 
void embedding_service_cb (const std::shared_ptr< EmbeddingSrv::Request > req, std::shared_ptr< EmbeddingSrv::Response > res)
 embedding service callback for embedding requests
 
void tokenize_service_cb (const std::shared_ptr< TokenizeSrv::Request > req, std::shared_ptr< TokenizeSrv::Response > res)
 tokenizer service callback for tokenization requests
 

Static Public Member Functions

static std::string generate_uuid ()
 Generate a UUID string for prompt tracking.
 

Private Types

using PromptSrv = prompt_msgs::srv::Prompt
 
using EmbeddingSrv = prompt_msgs::srv::Embedding
 
using TokenizeSrv = prompt_msgs::srv::Tokenize
 

Private Member Functions

void history_timer ()
 Timer callback to publish prompt history at regular intervals.
 
void update_prompt_history (prompt_msgs::msg::Prompt prompt, prompt_msgs::msg::PromptResponse response, rclcpp::Time prompt_time, rclcpp::Time response_time)
 Update the prompt history with a new prompt transaction.
 

Private Attributes

std::string frame_id_
 
unsigned int transaction_limit_
 
std::string provider_name_
 
prompt_msgs::msg::PromptHistory prompt_history_
 
pluginlib::ClassLoader< prompt::BaseClassprompt_loader
 
pluginlib::ClassLoader< prompt::BaseClassembedding_loader
 
pluginlib::ClassLoader< prompt::BaseClasstokenizer_loader
 
rclcpp::Publisher< prompt_msgs::msg::PromptHistory >::SharedPtr prompt_history_pub_
 
rclcpp::Service< PromptSrv >::SharedPtr prompt_service_
 
rclcpp::Service< EmbeddingSrv >::SharedPtr embedding_service_
 
rclcpp::Service< TokenizeSrv >::SharedPtr tokenizer_service_
 
rclcpp::TimerBase::SharedPtr history_pub_timer_
 
std::vector< std::string > prompt_families_keys_
 
std::map< std::string, std::string > prompt_families_names_
 
std::vector< std::string > embedding_families_keys_
 
std::map< std::string, std::string > embedding_families_names_
 
std::vector< std::string > tokenizer_families_keys_
 
std::map< std::string, std::string > tokenizer_families_names_
 
std::map< std::string, std::vector< prompt::PromptDialogue > > prompt_conversations_
 

Detailed Description

PromptBridge.

This class provides a bridge between ROS resources and the prompt provider and scheme It also provides a ROS action and service servers that can be used to send and receive prompts

Member Typedef Documentation

◆ EmbeddingSrv

using prompt::PromptBridge::EmbeddingSrv = prompt_msgs::srv::Embedding
private

◆ PromptSrv

using prompt::PromptBridge::PromptSrv = prompt_msgs::srv::Prompt
private

◆ TokenizeSrv

using prompt::PromptBridge::TokenizeSrv = prompt_msgs::srv::Tokenize
private

Constructor & Destructor Documentation

◆ PromptBridge()

prompt::PromptBridge::PromptBridge ( const rclcpp::NodeOptions &  options = rclcpp::NodeOptions())
inline

Construct a new Prompt Bridge object.

Parameters
optionsNode options for the PromptBridge node

◆ ~PromptBridge()

prompt::PromptBridge::~PromptBridge ( )
default

Member Function Documentation

◆ embedding_service_cb()

void prompt::PromptBridge::embedding_service_cb ( const std::shared_ptr< EmbeddingSrv::Request >  req,
std::shared_ptr< EmbeddingSrv::Response >  res 
)
inline

embedding service callback for embedding requests

This function is called when an embedding service request is received. It processes the embedding request using the embedding provider, and sends the response back to the client.

Parameters
reqthe embedding service request. contains an embedding request message, which is processed by the embedding provider
resthe embedding service response. contains the processed embedding response.
Exceptions
prompt::PromptExceptionif the embedding provider fails to process the embedding request

◆ generate_uuid()

static std::string prompt::PromptBridge::generate_uuid ( )
inlinestatic

Generate a UUID string for prompt tracking.

◆ history_timer()

void prompt::PromptBridge::history_timer ( )
inlineprivate

Timer callback to publish prompt history at regular intervals.

◆ initialize()

void prompt::PromptBridge::initialize ( )
inline

Initialize the PromptBridge node.

This method initializes the PromptBridge node by declaring parameters and loading plugins.

◆ load_embedding_model()

std::shared_ptr< prompt::BaseClass > prompt::PromptBridge::load_embedding_model ( std::string  family)
inline

Load an embedding model plugin based on the embedding family.

Parameters
familyThe embedding family name
Returns
std::shared_ptr<prompt::BaseClass> The loaded embedding provider instance
Exceptions
prompt::PromptExceptionif the embedding family is not found

◆ load_prompt_model()

std::shared_ptr< prompt::BaseClass > prompt::PromptBridge::load_prompt_model ( std::string  family)
inline

Load a prompt model plugin based on the prompt family.

Parameters
familyThe prompt family name
Returns
std::shared_ptr<prompt::BaseClass> The loaded prompt provider instance
Exceptions
prompt::PromptExceptionif the prompt family is not found

◆ load_tokenizer_model()

std::shared_ptr< prompt::BaseClass > prompt::PromptBridge::load_tokenizer_model ( std::string  family)
inline

Load a tokenizer model plugin based on the tokenizer family.

Parameters
familyThe tokenizer family name
Returns
std::shared_ptr<prompt::BaseClass> The loaded tokenizer provider instance
Exceptions
prompt::PromptExceptionif the tokenizer family is not found

◆ prompt_service_cb()

void prompt::PromptBridge::prompt_service_cb ( const std::shared_ptr< PromptSrv::Request >  req,
std::shared_ptr< PromptSrv::Response >  res 
)
inline

prompt service callback for instance prompts

This function is called when a prompt service request is received. It processes the prompt request with a new instance of the prompt provider and allows for concurrent prompt handling. It processes the prompt request using the prompt provider, and sends the response back to the client.

Parameters
reqthe prompt service request. contains a prompt message, which is processed by the prompt provider
resthe prompt service response. contains the processed prompt response.
Exceptions
prompt::PromptExceptionif the prompt provider fails to process the prompt

◆ tokenize_service_cb()

void prompt::PromptBridge::tokenize_service_cb ( const std::shared_ptr< TokenizeSrv::Request >  req,
std::shared_ptr< TokenizeSrv::Response >  res 
)
inline

tokenizer service callback for tokenization requests

This function is called when a tokenizer service request is received. It processes the tokenization request using the tokenizer provider, and sends the response back to the client.

Parameters
reqthe tokenizer service request. contains a tokenization request message, which is processed by the tokenizer provider
resthe tokenizer service response. contains the processed tokenization response.
Exceptions
prompt::PromptExceptionif the tokenizer provider fails to process the tokenization request

◆ update_prompt_history()

void prompt::PromptBridge::update_prompt_history ( prompt_msgs::msg::Prompt  prompt,
prompt_msgs::msg::PromptResponse  response,
rclcpp::Time  prompt_time,
rclcpp::Time  response_time 
)
inlineprivate

Update the prompt history with a new prompt transaction.

Parameters
promptThe prompt message
responseThe prompt response message
prompt_timeThe time the prompt was sent
response_timeThe time the response was received

Member Data Documentation

◆ embedding_families_keys_

std::vector<std::string> prompt::PromptBridge::embedding_families_keys_
private

◆ embedding_families_names_

std::map<std::string, std::string> prompt::PromptBridge::embedding_families_names_
private

◆ embedding_loader

pluginlib::ClassLoader<prompt::BaseClass> prompt::PromptBridge::embedding_loader
private

◆ embedding_service_

rclcpp::Service<EmbeddingSrv>::SharedPtr prompt::PromptBridge::embedding_service_
private

◆ frame_id_

std::string prompt::PromptBridge::frame_id_
private

◆ history_pub_timer_

rclcpp::TimerBase::SharedPtr prompt::PromptBridge::history_pub_timer_
private

◆ prompt_conversations_

std::map<std::string, std::vector<prompt::PromptDialogue> > prompt::PromptBridge::prompt_conversations_
private

◆ prompt_families_keys_

std::vector<std::string> prompt::PromptBridge::prompt_families_keys_
private

◆ prompt_families_names_

std::map<std::string, std::string> prompt::PromptBridge::prompt_families_names_
private

◆ prompt_history_

prompt_msgs::msg::PromptHistory prompt::PromptBridge::prompt_history_
private

◆ prompt_history_pub_

rclcpp::Publisher<prompt_msgs::msg::PromptHistory>::SharedPtr prompt::PromptBridge::prompt_history_pub_
private

◆ prompt_loader

pluginlib::ClassLoader<prompt::BaseClass> prompt::PromptBridge::prompt_loader
private

◆ prompt_service_

rclcpp::Service<PromptSrv>::SharedPtr prompt::PromptBridge::prompt_service_
private

◆ provider_name_

std::string prompt::PromptBridge::provider_name_
private

◆ tokenizer_families_keys_

std::vector<std::string> prompt::PromptBridge::tokenizer_families_keys_
private

◆ tokenizer_families_names_

std::map<std::string, std::string> prompt::PromptBridge::tokenizer_families_names_
private

◆ tokenizer_loader

pluginlib::ClassLoader<prompt::BaseClass> prompt::PromptBridge::tokenizer_loader
private

◆ tokenizer_service_

rclcpp::Service<TokenizeSrv>::SharedPtr prompt::PromptBridge::tokenizer_service_
private

◆ transaction_limit_

unsigned int prompt::PromptBridge::transaction_limit_
private

The documentation for this class was generated from the following file: