Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If ChatStep set to failed, do not set to success on exiting context #7742

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading