Skip to content

Commit

Permalink
fix(text_hmi): uids are strings (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
boczekbartek authored Sep 26, 2024
1 parent 4cc7e7b commit 18af536
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/rai_hmi/rai_hmi/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ def get_mission_memory(uid: str) -> List[MissionMessage]:
def add_task_to_queue(task: TaskInput):
"""Use this tool to add a task to the queue. The task will be handled by the executor part of your system."""

uid = uuid.uuid1()
uid = uuid.uuid4()
hmi_node.add_task_to_queue(
Task(
name=task.name,
description=task.description,
priority=task.priority,
uid=uid,
uid=str(uid),
)
)
return f"UID={uid} | Task added to the queue: {task.json()}"
return f"UID={uid} | Task added to the queue: {task.model_dump_json()}"

node_tools = tools = [
Ros2GetRobotInterfaces(node=rai_node),
Expand Down
4 changes: 2 additions & 2 deletions src/rai_hmi/rai_hmi/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from enum import Enum

from pydantic import UUID4, BaseModel
from pydantic import BaseModel


class Priority(str, Enum):
Expand All @@ -33,4 +33,4 @@ class TaskInput(BaseModel):


class Task(TaskInput):
uid: UUID4
uid: str
8 changes: 3 additions & 5 deletions src/rai_hmi/rai_hmi/text_hmi_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
#

import uuid
from pprint import pformat
from typing import List, Optional, Set, cast

Expand Down Expand Up @@ -45,12 +44,11 @@ def get_mission_memory(self, uid: Optional[str] = None) -> List[MissionMessage]:
if not uid:
return self.mission_memory

_uid = uuid.UUID(uid)
print(f"{self.missions_uids=}")
if _uid not in self.missions_uids:
raise AssertionError(f"Mission with {_uid=} not found")
if uid not in self.missions_uids:
raise AssertionError(f"Mission with {uid=} not found")

return [m for m in self.mission_memory if m.uid == _uid]
return [m for m in self.mission_memory if m.uid == uid]

def __repr__(self) -> str:
return f"===> Chat <===\n{pformat(self.chat_memory)}\n\n===> Mission <===\n{pformat(self.mission_memory)}\n\n===> Tool calls <===\n{pformat(self.tool_calls)}"

0 comments on commit 18af536

Please sign in to comment.