diff --git a/superagi/helper/feed_parser.py b/superagi/helper/feed_parser.py index 170e65c53..c02040079 100644 --- a/superagi/helper/feed_parser.py +++ b/superagi/helper/feed_parser.py @@ -41,7 +41,8 @@ def parse_feed(feed): return {"role": "assistant", "feed": final_output, "updated_at": feed.updated_at, "time_difference": feed.time_difference} except Exception: - return feed + return {"role": "assistant", "feed": feed.feed, "updated_at": feed.updated_at, + "time_difference": feed.time_difference} if feed.role == "system": final_output = feed.feed diff --git a/tests/unit_tests/helper/test_feed_parser.py b/tests/unit_tests/helper/test_feed_parser.py index 0f321a054..2915949eb 100644 --- a/tests/unit_tests/helper/test_feed_parser.py +++ b/tests/unit_tests/helper/test_feed_parser.py @@ -1,22 +1,16 @@ import unittest from datetime import datetime - from superagi.helper.feed_parser import parse_feed from superagi.models.agent_execution_feed import AgentExecutionFeed - - class TestParseFeed(unittest.TestCase): - def test_parse_feed_system(self): current_time = datetime.now() + sample_feed = AgentExecutionFeed( + id=2, agent_execution_id=100, agent_id=200, role="user", + feed='System message', updated_at=current_time + ) - # Create a sample AgentExecutionFeed object with a system role - sample_feed = AgentExecutionFeed(id=2, agent_execution_id=100, agent_id=200, role="assistant", - feed='System message', - updated_at=current_time) - - # Call the parse_feed function with the sample_feed object result = parse_feed(sample_feed) - - # In this test case, we only ensure that the parse_feed function doesn't modify the given feed - self.assertEqual(result, sample_feed, "Incorrect output from parse_feed function for system role") + + self.assertEqual(result['feed'], sample_feed.feed, "Incorrect output from parse_feed function for system role") + self.assertEqual(result['role'], sample_feed.role, "Incorrect output from parse_feed function for system role") \ No newline at end of file