From 69542142d4ac2dee67e84e34398499331af4187a Mon Sep 17 00:00:00 2001 From: AndyZe Date: Thu, 11 Jul 2024 18:51:49 -0500 Subject: [PATCH] Message renaming (#6) --- CMakeLists.txt | 3 +-- README.md | 4 ++-- package.xml | 2 +- src/example_client.cpp | 8 ++++---- src/openai_server.cpp | 10 +++++----- upstream.repos | 4 ++-- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52dcaa9..7e00ac2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +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 rclcpp robosoft_ai_msgs - sensor_msgs) +set(THIS_PACKAGE_INCLUDE_DEPENDS ament_index_cpp cv_bridge openai_msgs rclcpp sensor_msgs) find_package(ament_cmake REQUIRED) find_package(CURL REQUIRED) diff --git a/README.md b/README.md index 7061f20..63741ae 100644 --- a/README.md +++ b/README.md @@ -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 robosoft_ai_msgs/srv/StringImagePrompt prompt:\ "Are you a pirate? Please respond with a one-word answer, yes or no"` +`ros2 service call /openai_server openai_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 robosoft_ai_msgs/srv/StringImagePrompt prompt:\ "Are you a pirate?"` +`ros2 service call /openai_server openai_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: diff --git a/package.xml b/package.xml index cbbd856..55794fb 100644 --- a/package.xml +++ b/package.xml @@ -11,8 +11,8 @@ ament_index_cpp cv_bridge + openai_msgs rclcpp - robosoft_ai_msgs sensor_msgs ament_lint_auto diff --git a/src/example_client.cpp b/src/example_client.cpp index 36b3237..dbd6fb3 100644 --- a/src/example_client.cpp +++ b/src/example_client.cpp @@ -1,4 +1,4 @@ -#include "robosoft_ai_msgs/srv/string_image_prompt.hpp" +#include "openai_msgs/srv/string_image_prompt.hpp" #include "rclcpp/rclcpp.hpp" #include @@ -15,10 +15,10 @@ int main(int argc, char** argv) rclcpp::init(argc, argv); std::shared_ptr node = rclcpp::Node::make_shared("open_ai_client"); - rclcpp::Client::SharedPtr client = - node->create_client("openai_server"); + rclcpp::Client::SharedPtr client = + node->create_client("openai_server"); - auto request = std::make_shared(); + auto request = std::make_shared(); 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 diff --git a/src/openai_server.cpp b/src/openai_server.cpp index fab5bc0..fa693d5 100644 --- a/src/openai_server.cpp +++ b/src/openai_server.cpp @@ -1,6 +1,6 @@ #include "robosoft_openai/convert_image_to_base_64.hpp" -#include "robosoft_ai_msgs/srv/string_image_prompt.hpp" +#include "openai_msgs/srv/string_image_prompt.hpp" #include "rclcpp/rclcpp.hpp" #include "sensor_msgs/msg/image.hpp" @@ -17,7 +17,7 @@ class OpenAIServer : public rclcpp::Node public: OpenAIServer() : Node("service_client") { - prompt_srv_ = create_service( + prompt_srv_ = create_service( "openai_server", std::bind(&OpenAIServer::promptCallback, this, std::placeholders::_1, std::placeholders::_2)); curl_ = curl_easy_init(); @@ -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 request, - std::shared_ptr response) + void promptCallback(const std::shared_ptr request, + std::shared_ptr response) { RCLCPP_INFO_STREAM(this->get_logger(), "Incoming StringImagePrompt request: " << request->prompt); std::string string_response; @@ -160,7 +160,7 @@ class OpenAIServer : public rclcpp::Node response->string_response = std::move(string_response); } - rclcpp::Service::SharedPtr prompt_srv_; + rclcpp::Service::SharedPtr prompt_srv_; std::string openai_key_string_; CURL* curl_; diff --git a/upstream.repos b/upstream.repos index 047dada..812ea15 100644 --- a/upstream.repos +++ b/upstream.repos @@ -1,5 +1,5 @@ repositories: - robosoft_ai_msgs: + openai_msgs: type: git - url: https://github.com/robosoft-ai/robosoft_ai_msgs.git + url: https://github.com/robosoft-ai/openai_msgs.git version: main