|
Prompt Tools 0.3.2
|
ROS 2 meta-package with tools for working with prompted systems such as large language models and their responses in distributed robotic applications. It provides generic ROS message types for prompt, embedding, and tokenization workflows together with a flexible plugin-based bridge. The current providers are:
| Provider | Package |
|---|---|
| OpenAI | prompt_openai |
| Ollama | prompt_ollama |
prompt_bridge is designed to provide a generic, extensible interface for integrating prompted systems (e.g., LLMs) into ROS 2 robotic applications. It follows ROS best practices by using a plugin architecture, allowing different LLM providers to be loaded at runtime. This enables rapid experimentation and integration of new models and providers without changing core code.
The main node that connects ROS 2 applications to prompt providers. It loads providers through pluginlib and exposes prompt, embedding, and tokenization services concurrently.
prompt/prompt (prompt_msgs/srv/Prompt)prompt/embedding (prompt_msgs/srv/Embedding)prompt/tokenizer (prompt_msgs/srv/Tokenize)prompt/history (prompt_msgs/msg/PromptHistory)Following is the current system Architecture
Clone the prompt tools package
Move to workspace root and run the following command to install dependencies
If not connecting to a Online API, a local LLM running on docker can be used. Separately clone a repository such as CollaborativeRoboticsLab/ollama-docker for this purpose and start it.
Run the following command with the actual OPENAI_API_KEY in place of <open-ai-api-key> if using prompt-openai plugins
Then build the workspace and launch prompt_bridge with the packaged YAML configuration. The default OpenAI configuration uses the Responses API for prompts and the Embeddings API for embeddings.
Rename the .devcontainer/devcontainer-empty.env as .devcontainer/devcontainer.env and update it with your API Keys. Then rebuild the container
To build and run the C++ test node that exercises the current prompt, chat, cache, and embedding flows:
This will run the test node and print results for stateless prompting, chat mode, cached prompting, and embedding requests.
Two lightweight Python examples are available under prompt_bridge/test/:
call_srvs.py sends a single request to prompt/prompt.call_services.py exercises prompt/prompt, prompt/embedding, and prompt/tokenizer.Run them from a sourced workspace after prompt_bridge is already running:
prompt/promptprompt/embeddingprompt/tokenizerprompt/historyprompt_bridge/config/prompt_bridge.yamlOpenAI prompt requests are sent to https://api.openai.com/v1/responses, OpenAI embedding requests are sent to https://api.openai.com/v1/embeddings, and OpenAI tokenization is handled locally through cpp-tiktoken.
If you use this work in an academic context, please cite the following publication(s):