Skip to main content

RAI Whoami

RAI Whoami

Overview

RAI Whoami is a Python package designed to extract and synthesize robot embodiment information from a structured directory of documentation, images, and URDFs.
It generates a comprehensive system prompt (embodiment info) for robots controlled by LLMs, enabling advanced reasoning guided by the robot's embodiment setup.


How It Works

Given a directory containing robot documentation (documents, images, URDFs), RAI Whoami processes these resources to produce a structured representation of the robot, including:

  • Rules: Extracted operational or safety rules.
  • Behaviors: Descriptions of robot behaviors.
  • Capabilities: Functional and physical capabilities.
  • Images: Visual representations.
  • Vector Database: Embeddings of the robot's documentation. (optional)

This embodiment info is then used to create a system prompt for LLM-based agents, enabling them to reason about and interact with the robot effectively.

Directory Structure

Initialize the documentation directory:

initialize-docs documentation_dir

Populate your robot documentation directory:

documentation_dir/
├── images/          # png, jpg, jpeg files
├── documentation/   # pdf, docx, doc, md files
├── urdf/            # urdf files

Building the Embodiment Info

To generate the system prompt from your documentation directory:

build-whoami documentation_dir [--output_dir output_dir] [--build-vector-db]

Generated files will be saved in the output_dir / generated directory or documentation_dir / generated if not specified.


Using with ROS2 and ReActAgent

Integrate the generated embodiment info into your LLM-powered robot agent:

from rai_whoami import EmbodimentInfo
from rai.agents import ReActAgent, wait_for_shutdown
from rai.communication.ros2 import ROS2HRIConnector

info = EmbodimentInfo.from_directory("output_dir/")
system_prompt = info.to_langchain()  # Convert EmbodimentInfo to a system prompt

# example usage with langchain runnable
from rai.agents.langchain import create_react_runnable

react_agent = create_react_runnable(
    tools=[],
    system_prompt=system_prompt
)

# example usage with RAI Agent
connector = ROS2HRIConnector()
agent = ReActAgent(
    target_connectors={"/to_human": connector},
    system_prompt=system_prompt,
)
agent.subscribe_source("/from_human", connector)

agent.run()
wait_for_shutdown([agent])

Using generated Vector Database

rai whoami provides a langchain tool to query the generated vector database. There are a couple of ways to use it:

  1. Through a langchain runnable
from langchain_core.messages import HumanMessage
from rai_whoami.tools import QueryDatabaseTool
from rai.agents.langchain import create_react_runnable

query_tool = QueryDatabaseTool(root_dir="output_dir")

react_agent = create_react_runnable(tools=[query_tool])
print(
    react_agent.invoke(
        {"messages": [HumanMessage(content="Check the db for Robot's name")]}
    )
)
  1. Through a RAI Agent
from rai.agents import ReActAgent, wait_for_shutdown
from rai.communication.ros2 import ROS2HRIConnector

from rai_whoami.tools import QueryDatabaseTool

query_tool = QueryDatabaseTool(root_dir="output_dir")

connector = ROS2HRIConnector()
agent = ReActAgent(
    target_connectors={"/to_human": connector}, system_prompt="", tools=[query_tool]
)
agent.subscribe_source("/from_human", connector)

agent.run()
wait_for_shutdown([agent])

Using ROS2 Vector Store Retrieval Agent

The ROS2VectorStoreRetrievalAgent is a ROS2 agent that can be used to retrieve information from the vector database through a ROS 2 service.

from rai_whoami.agents.ros2 import ROS2VectorStoreRetrievalAgent
from rai.agents import wait_for_shutdown

agent = ROS2VectorStoreRetrievalAgent(
    service_name="rai_whoami_documentation_service",
    root_dir="output_dir",
    k=4,
)
agent.run()
wait_for_shutdown([agent])

With the agent running, you can query the vector database through a ROS 2 service:

ros2 service call /rai_whoami_documentation_service rai_interfaces/srv/VectorStoreRetrieval "query:  'maximum load'"

Using ROS2 Embodiment Info Agent

The ROS2EmbodimentInfoAgent is a ROS2 agent that can be used to retrieve information from the embodiment info through a ROS 2 service.

from rai_whoami.agents.ros2 import ROS2EmbodimentInfoAgent
from rai.agents import wait_for_shutdown

agent = ROS2EmbodimentInfoAgent(
    service_name="rai_whoami_embodiment_info_service",
    root_dir="output_dir",
)
agent.run()
wait_for_shutdown([agent])

With the agent running, you can query the embodiment info through a ROS 2 service:

ros2 service call /rai_whoami_embodiment_info_service rai_interfaces/srv/EmbodimentInfo

Metadata

Release files for rai_whoami 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rai_whoami 0.0.5
File Size Uploaded
rai_whoami-0.0.5.tar.gz 12.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rai_whoami 0.0.5
File Interpreter ABI Platform
rai_whoami-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 42.7 kB

Release files / rai_whoami-0.0.5.tar.gz

Download URL rai_whoami-0.0.5.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5ebcdaedbe3034892cf57fc77acce67e9dc8cb9a4c2a01b99e1578d8c4870770
BLAKE2b-256 checksum
How to use checksums
3155d4c35c31e318bb69cf81f82e0eddad1710c6e67206a5e37ef5198625d35f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-26-generic

Release files / rai_whoami-0.0.5-py3-none-any.whl

Download URL rai_whoami-0.0.5-py3-none-any.whl
Size 30.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3e1bc580855ed855e81c88d2c854fe6f79332941da1574c5728ef7425d85a4e2
BLAKE2b-256 checksum
How to use checksums
68b68bc3f7078c23a93c6c74562cfc0607fdaf0a0c4661b1d602986c71909a07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.3 Linux/6.11.0-26-generic

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page