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

RestBaseClass. More...

#include <rest_base_class.hpp>

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

Public Member Functions

 RestBaseClass ()
 Constructor.
 
virtual ~RestBaseClass ()=default
 Destructor.
 
virtual void initialize_rest_base (rclcpp::Node::SharedPtr node, std::string plugin_name="RestBaseClass", std::string api_key_name="")
 Initialize the REST base class.
 
- Public Member Functions inherited from prompt::BaseClass
 BaseClass ()=default
 
virtual ~BaseClass ()=default
 
virtual void initialize (rclcpp::Node::SharedPtr node)=0
 Initialize the prompt pligin.
 
virtual prompt::EmbedResponse get_embeddings (prompt::EmbedRequest &req)
 get_embeddings sends a text to an embedding provider using REST
 
virtual prompt::TokenResponse get_tokens (prompt::TokenRequest &req)
 get_tokens sends a text to a token provider
 
virtual prompt::PromptResponse sendPrompt (prompt::PromptRequest &req)
 Send a prompt to the prompt plugin.
 
virtual prompt::PromptResponse sendConversation (prompt::PromptRequest &latest_request, std::vector< PromptDialogue > &conversation)
 Send a prompt to the prompt plugin.
 

Protected Member Functions

Poco::JSON::Object::Ptr process (Poco::JSON::Object &body_json, std::string &uri)
 Process the HTTP request and return the response as a JSON object.
 
virtual const Poco::JSON::Object handle_options (std::vector< prompt::PromptOption > &options)
 Process options from the prompt request.
 
- Protected Member Functions inherited from prompt::BaseClass
virtual void initialize_base (rclcpp::Node::SharedPtr node, std::string plugin_name="BaseClass")
 Initialize the prompt base class.
 

Static Protected Member Functions

static std::string extract_error_description (const std::string &response_body)
 

Protected Attributes

std::string method_
 
bool ssl_verify_
 
std::string auth_type_
 
std::string api_key_
 API key.
 
std::vector< prompt::PromptOptionrequired_options_
 Model options.
 
- Protected Attributes inherited from prompt::BaseClass
rclcpp::Node::SharedPtr node_
 Node shared pointer.
 
std::string plugin_name_
 Plugin name.
 

Detailed Description

RestBaseClass.

This class implements a base class for RESTful prompt plugins. It provides a common interface for sending prompts and receiving responses

Constructor & Destructor Documentation

◆ RestBaseClass()

prompt::RestBaseClass::RestBaseClass ( )
inline

Constructor.

Initializes the RestBaseClass with default values.

◆ ~RestBaseClass()

virtual prompt::RestBaseClass::~RestBaseClass ( )
virtualdefault

Destructor.

Cleans up resources used by the RestBaseClass.

Member Function Documentation

◆ extract_error_description()

static std::string prompt::RestBaseClass::extract_error_description ( const std::string &  response_body)
inlinestaticprotected

◆ handle_options()

virtual const Poco::JSON::Object prompt::RestBaseClass::handle_options ( std::vector< prompt::PromptOption > &  options)
inlineprotectedvirtual

Process options from the prompt request.

This method processes the options from the prompt request and returns a JSON object containing the options. It flattens the options into a JSON object, converting types based on the type hint provided in the option.

Parameters
promptThe prompt request containing options to be processed

◆ initialize_rest_base()

virtual void prompt::RestBaseClass::initialize_rest_base ( rclcpp::Node::SharedPtr  node,
std::string  plugin_name = "RestBaseClass",
std::string  api_key_name = "" 
)
inlinevirtual

Initialize the REST base class.

This method initializes the REST base class with parameters from the ROS parameter server.

Parameters
noderclcpp::Node::SharedPtr ROS node
plugin_namestd::string Name of the plugin, used for parameter names
api_key_namestd::string Name of the API key parameter, if different from the default
Exceptions
prompt::PromptExceptionif there is an error during initialization

◆ process()

Poco::JSON::Object::Ptr prompt::RestBaseClass::process ( Poco::JSON::Object &  body_json,
std::string &  uri 
)
inlineprotected

Process the HTTP request and return the response as a JSON object.

This method sends the HTTP request to the specified URI and returns the response as a Poco::JSON::Object::Ptr.

Parameters
body_jsonThe JSON object containing the request body.
uriThe URI to send the request to.
Returns
Poco::JSON::Object::Ptr The JSON object containing the response.
Exceptions
prompt::PromptExceptionif there is an error during the request.

Member Data Documentation

◆ api_key_

std::string prompt::RestBaseClass::api_key_
protected

API key.

◆ auth_type_

std::string prompt::RestBaseClass::auth_type_
protected

◆ method_

std::string prompt::RestBaseClass::method_
protected

◆ required_options_

std::vector<prompt::PromptOption> prompt::RestBaseClass::required_options_
protected

Model options.

This is the model options used by the prompt provider by default in case model options are not provided in the request

◆ ssl_verify_

bool prompt::RestBaseClass::ssl_verify_
protected

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