Skip to content

Commit

Permalink
Update the msg pkg name to ai_prompt_msgs (#8)
Browse files Browse the repository at this point in the history
* Update the msg pkg name to `ai_prompt_msgs`

* Alphabetize
  • Loading branch information
AndyZe committed Jul 16, 2024
1 parent 6e338c6 commit 8c3a3b3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

set(THIS_PACKAGE_INCLUDE_DEPENDS ament_index_cpp cv_bridge openai_msgs rclcpp sensor_msgs)
set(THIS_PACKAGE_INCLUDE_DEPENDS ai_prompt_msgs ament_index_cpp cv_bridge rclcpp sensor_msgs)

find_package(ament_cmake REQUIRED)
find_package(CURL REQUIRED)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ Here's a quick example:

Send it a prompt. Here's an example that returns a bool from a yes/no question. Note that the `image` field of the service request may be left empty...

`ros2 service call /openai_server openai_msgs/srv/StringImagePrompt prompt:\ "Are you a pirate? Please respond with a one-word answer, yes or no"`
`ros2 service call /openai_server ai_prompt_msgs/srv/StringImagePrompt prompt:\ "Are you a pirate? Please respond with a one-word answer, yes or no"`

Here's an example that returns a full string...

`ros2 service call /openai_server openai_msgs/srv/StringImagePrompt prompt:\ "Are you a pirate?"`
`ros2 service call /openai_server ai_prompt_msgs/srv/StringImagePrompt prompt:\ "Are you a pirate?"`

Here's an example client which sends an image of a wooden table and prompts whether it is indeed a wooden table:

Expand Down
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<buildtool_depend>ament_cmake</buildtool_depend>

<depend>ament_index_cpp</depend>
<depend>ai_prompt_msgs</depend>
<depend>cv_bridge</depend>
<depend>openai_msgs</depend>
<depend>rclcpp</depend>
<depend>sensor_msgs</depend>

Expand Down
8 changes: 4 additions & 4 deletions src/example_client.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "openai_msgs/srv/string_image_prompt.hpp"
#include "ai_prompt_msgs/srv/string_image_prompt.hpp"
#include "rclcpp/rclcpp.hpp"

#include <ament_index_cpp/get_package_share_directory.hpp>
Expand All @@ -15,10 +15,10 @@ int main(int argc, char** argv)
rclcpp::init(argc, argv);

std::shared_ptr<rclcpp::Node> node = rclcpp::Node::make_shared("open_ai_client");
rclcpp::Client<openai_msgs::srv::StringImagePrompt>::SharedPtr client =
node->create_client<openai_msgs::srv::StringImagePrompt>("openai_server");
rclcpp::Client<ai_prompt_msgs::srv::StringImagePrompt>::SharedPtr client =
node->create_client<ai_prompt_msgs::srv::StringImagePrompt>("openai_server");

auto request = std::make_shared<openai_msgs::srv::StringImagePrompt::Request>();
auto request = std::make_shared<ai_prompt_msgs::srv::StringImagePrompt::Request>();
request->prompt = "Is this a wooden table? Please respond in one word, yes or no.";

// Add an image of a wooden table to the OpenAI request
Expand Down
10 changes: 5 additions & 5 deletions src/openai_server.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "robosoft_openai/convert_image_to_base_64.hpp"

#include "openai_msgs/srv/string_image_prompt.hpp"
#include "ai_prompt_msgs/srv/string_image_prompt.hpp"
#include "rclcpp/rclcpp.hpp"
#include "sensor_msgs/msg/image.hpp"

Expand All @@ -17,7 +17,7 @@ class OpenAIServer : public rclcpp::Node
public:
OpenAIServer() : Node("service_client")
{
prompt_srv_ = create_service<openai_msgs::srv::StringImagePrompt>(
prompt_srv_ = create_service<ai_prompt_msgs::srv::StringImagePrompt>(
"openai_server", std::bind(&OpenAIServer::promptCallback, this, std::placeholders::_1, std::placeholders::_2));

curl_ = curl_easy_init();
Expand Down Expand Up @@ -144,8 +144,8 @@ class OpenAIServer : public rclcpp::Node
* @param request service request
* @param response bool response, parsed from OpenAI's string response
*/
void promptCallback(const std::shared_ptr<openai_msgs::srv::StringImagePrompt::Request> request,
std::shared_ptr<openai_msgs::srv::StringImagePrompt::Response> response)
void promptCallback(const std::shared_ptr<ai_prompt_msgs::srv::StringImagePrompt::Request> request,
std::shared_ptr<ai_prompt_msgs::srv::StringImagePrompt::Response> response)
{
RCLCPP_INFO_STREAM(this->get_logger(), "Incoming StringImagePrompt request: " << request->prompt);
std::string string_response;
Expand All @@ -160,7 +160,7 @@ class OpenAIServer : public rclcpp::Node
response->string_response = std::move(string_response);
}

rclcpp::Service<openai_msgs::srv::StringImagePrompt>::SharedPtr prompt_srv_;
rclcpp::Service<ai_prompt_msgs::srv::StringImagePrompt>::SharedPtr prompt_srv_;

std::string openai_key_string_;
CURL* curl_;
Expand Down
4 changes: 2 additions & 2 deletions upstream.repos
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
repositories:
openai_msgs:
ai_prompt_msgs:
type: git
url: https://github.com/robosoft-ai/openai_msgs.git
url: https://github.com/robosoft-ai/ai_prompt_msgs.git
version: main

0 comments on commit 8c3a3b3

Please sign in to comment.