Skip to content

Commit

Permalink
error_handling fix (#1247)
Browse files Browse the repository at this point in the history
Error handling fix.
  • Loading branch information
rounak610 authored Sep 17, 2023
1 parent 3b5a868 commit eaf44a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
3 changes: 2 additions & 1 deletion superagi/helper/feed_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 7 additions & 13 deletions tests/unit_tests/helper/test_feed_parser.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit eaf44a8

Please sign in to comment.