Skip to content

Commit

Permalink
Fix and test MemoryStep (#432)
Browse files Browse the repository at this point in the history
* Test MemoryStep
* Remove unused MemoryStep.raw attribute
  • Loading branch information
albertvillanova authored Jan 30, 2025
1 parent 42d9771 commit 181a500
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/smolagents/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ def dict(self):
}


@dataclass
class MemoryStep:
raw: Any # This is a placeholder for the raw data that the agent logs

def dict(self):
return asdict(self)

Expand Down
18 changes: 18 additions & 0 deletions tests/test_memory.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import pytest

from smolagents.memory import (
ActionStep,
AgentMemory,
ChatMessage,
MemoryStep,
Message,
MessageRole,
PlanningStep,
Expand All @@ -18,6 +21,21 @@ def test_initialization(self):
assert memory.steps == []


class TestMemoryStep:
def test_initialization(self):
step = MemoryStep()
assert isinstance(step, MemoryStep)

def test_dict(self):
step = MemoryStep()
assert step.dict() == {}

def test_to_messages(self):
step = MemoryStep()
with pytest.raises(NotImplementedError):
step.to_messages()


def test_action_step_to_messages():
action_step = ActionStep(
model_input_messages=[Message(role=MessageRole.USER, content="Hello")],
Expand Down

0 comments on commit 181a500

Please sign in to comment.