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

EmbedBaseClass. More...

#include <embed_base_class.hpp>

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

Public Member Functions

 EmbedBaseClass ()
 Constructor.
 
virtual ~EmbedBaseClass ()=default
 Destructor.
 
virtual void initialize_embed_base (rclcpp::Node::SharedPtr node, std::string plugin_name="EmbedBaseClass", std::string api_key_name="")
 Initialize the REST base class.
 
virtual prompt::EmbedResponse get_embeddings (prompt::EmbedRequest &req) override
 get_embeddings sends a text to an embedding provider using REST
 
- Public Member Functions inherited from prompt::RestBaseClass
 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::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

virtual Poco::JSON::Object toJson (prompt::EmbedRequest &input)=0
 Convert a embed request to a JSON object.
 
virtual prompt::EmbedResponse fromJson (const Poco::JSON::Object::Ptr object)=0
 Convert a JSON object to a embed response.
 
- Protected Member Functions inherited from prompt::RestBaseClass
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.
 

Protected Attributes

std::string embed_uri_
 URI for embedding requests.
 
- Protected Attributes inherited from prompt::RestBaseClass
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.
 

Additional Inherited Members

- Static Protected Member Functions inherited from prompt::RestBaseClass
static std::string extract_error_description (const std::string &response_body)
 

Detailed Description

EmbedBaseClass.

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

Constructor & Destructor Documentation

◆ EmbedBaseClass()

prompt::EmbedBaseClass::EmbedBaseClass ( )
inline

Constructor.

Initializes the EmbedBaseClass with default values.

◆ ~EmbedBaseClass()

virtual prompt::EmbedBaseClass::~EmbedBaseClass ( )
virtualdefault

Destructor.

Cleans up resources used by the EmbedBaseClass.

Member Function Documentation

◆ fromJson()

virtual prompt::EmbedResponse prompt::EmbedBaseClass::fromJson ( const Poco::JSON::Object::Ptr  object)
protectedpure virtual

Convert a JSON object to a embed response.

This method converts a JSON object received from the embed plugin into a embed response. It extracts the relevant fields from the JSON object and returns a EmbedResponse object.

Parameters
objectThe JSON object to convert
Returns
A EmbedResponse object containing the response data

Implemented in prompt::OpenAIEmbedding.

◆ get_embeddings()

virtual prompt::EmbedResponse prompt::EmbedBaseClass::get_embeddings ( prompt::EmbedRequest req)
inlineoverridevirtual

get_embeddings sends a text to an embedding provider using REST

Parameters
reqThe embed request containing the text and options.
Returns
const EmbedResponse

Reimplemented from prompt::BaseClass.

◆ initialize_embed_base()

virtual void prompt::EmbedBaseClass::initialize_embed_base ( rclcpp::Node::SharedPtr  node,
std::string  plugin_name = "EmbedBaseClass",
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::EmbedExceptionif there is an error during initialization

◆ toJson()

virtual Poco::JSON::Object prompt::EmbedBaseClass::toJson ( prompt::EmbedRequest input)
protectedpure virtual

Convert a embed request to a JSON object.

This method converts the embed request to a JSON object that can be sent to the embed plugin. It includes the embed text and options in the JSON object.

Parameters
inputThe embed request to convert
Returns
A JSON object representing the embed request

Implemented in prompt::OpenAIEmbedding.

Member Data Documentation

◆ embed_uri_

std::string prompt::EmbedBaseClass::embed_uri_
protected

URI for embedding requests.


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