Skip to content

Commit

Permalink
if set to failed, do not set back to success (#7742)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 authored Feb 27, 2025
1 parent 2a26c37 commit e1e5bbd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion panel/chat/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def __exit__(self, exc_type, exc_value, tb):
self.status = "failed"
if self.context_exception == "raise":
return False
else:
elif self.status in ("pending", "running"):
self.status = "success"
return True # suppress exception if any

Expand Down
6 changes: 6 additions & 0 deletions panel/tests/chat/test_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ def test_repeated_error(self):
assert step.title == "Error: 'RuntimeError'", "Title should update to 'Error: 'RuntimeError'' on failure again"
assert step.objects[0].object == "Testing\nSecond Testing", "Error message should be streamed to the message pane"

def test_context_manually_set_failed(self):
step = ChatStep()
with step:
step.status = "failed"
assert step.status == "failed", "Status should be 'failed' after manually setting it to 'failed'"

def test_context_exception_ignore(self):
step = ChatStep(context_exception="ignore")
with step:
Expand Down

0 comments on commit e1e5bbd

Please sign in to comment.