Skip to content

Commit

Permalink
add traceback; fix hide css
Browse files Browse the repository at this point in the history
  • Loading branch information
x5a committed Oct 23, 2024
1 parent c1eb423 commit 26a16f7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions computer-use-demo/computer_use_demo/streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import base64
import os
import subprocess
import traceback
from datetime import datetime, timedelta
from enum import StrEnum
from functools import partial
Expand Down Expand Up @@ -39,7 +40,7 @@
display: none;
}
/* Hide the streamlit deploy button */
.stDeployButton {
.stAppDeployButton {
visibility: hidden;
}
</style>
Expand Down Expand Up @@ -331,10 +332,14 @@ def _render_error(error: Exception):
if isinstance(error, RateLimitError):
body = "You have been rate limited."
if retry_after := error.response.headers.get("retry-after"):
body += f" **Retry after {str(timedelta(seconds=int(retry_after)))} (HH:MM:SS).**"
body += f" **Retry after {str(timedelta(seconds=int(retry_after)))} (HH:MM:SS).** See our API [documentation](https://docs.anthropic.com/en/api/rate-limits) for more details."
body += f"\n\n{error.message}"
else:
body = str(error)
body += "\n\n**Traceback:**"
lines = "\n".join(traceback.format_exception(error))
body += f"\n\n```{lines}```"
save_to_storage(f"error_{datetime.now().timestamp()}.md", body)
st.error(f"**{error.__class__.__name__}**\n\n{body}", icon=":material/error:")


Expand Down

0 comments on commit 26a16f7

Please sign in to comment.