From 0cf556e410d402a6ccfa0ccaa6b30a8d2fb41a51 Mon Sep 17 00:00:00 2001 From: Zak Lee Date: Fri, 22 Nov 2024 11:02:14 -0800 Subject: [PATCH] Add stop/interrupt capability (#174) * add stop/interrupt capability * correctly update session_state.tools --- .../computer_use_demo/streamlit.py | 56 +++++++++++++++++-- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/computer-use-demo/computer_use_demo/streamlit.py b/computer-use-demo/computer_use_demo/streamlit.py index 45318ed9..6700a97c 100644 --- a/computer-use-demo/computer_use_demo/streamlit.py +++ b/computer-use-demo/computer_use_demo/streamlit.py @@ -7,6 +7,7 @@ import os import subprocess import traceback +from contextlib import contextmanager from datetime import datetime, timedelta from enum import StrEnum from functools import partial @@ -19,6 +20,7 @@ from anthropic.types.beta import ( BetaContentBlockParam, BetaTextBlockParam, + BetaToolResultBlockParam, ) from streamlit.delta_generator import DeltaGenerator @@ -33,10 +35,14 @@ API_KEY_FILE = CONFIG_DIR / "api_key" STREAMLIT_STYLE = """