Skip to content

Commit

Permalink
fix: include system prompt in text hmi
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejmajek committed Aug 21, 2024
1 parent 2bf5c99 commit 43981d0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/rai_hmi/rai_hmi/text_hmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
AIMessage,
BaseMessage,
HumanMessage,
SystemMessage,
ToolCall,
ToolMessage,
)
Expand Down Expand Up @@ -84,9 +85,9 @@ def initialize_agent(_node: BaseHMINode):
return agent


def initialize_session_memory():
def initialize_session_memory(system_prompt: str = ""):
if "memory" not in st.session_state:
st.session_state.memory = []
st.session_state.memory = [SystemMessage(content=system_prompt)]
if "tool_calls" not in st.session_state:
st.session_state.tool_calls = {}

Expand Down Expand Up @@ -134,6 +135,8 @@ def handle_history_message(message: BaseMessage):
base_64_image = artifact["images"][0]
image = decode_base64_into_image(base_64_image)
st.image(image)
elif isinstance(message, SystemMessage):
return # we do not handle system messages
else:
raise ValueError("Unknown message type")

Expand All @@ -142,7 +145,7 @@ def handle_history_message(message: BaseMessage):
with st.spinner("Initializing ROS 2 node..."):
node = initialize_ros_node(robot_description_package)
agent = initialize_agent(_node=node)
initialize_session_memory()
initialize_session_memory(system_prompt=node.system_prompt)

status = {
"robot_database": node.faiss_index is not None,
Expand Down

0 comments on commit 43981d0

Please sign in to comment.