Skip to content

Commit

Permalink
Limit images to 3 (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
zckly authored Nov 22, 2024
1 parent e3cdfa6 commit 6f85efe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions computer-use-demo/computer_use_demo/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async def sampling_loop(
while True:
enable_prompt_caching = False
betas = [COMPUTER_USE_BETA_FLAG]
image_truncation_threshold = 10
image_truncation_threshold = only_n_most_recent_images or 0
if provider == APIProvider.ANTHROPIC:
client = Anthropic(api_key=api_key, max_retries=4)
enable_prompt_caching = True
Expand All @@ -114,7 +114,8 @@ async def sampling_loop(
betas.append(PROMPT_CACHING_BETA_FLAG)
_inject_prompt_caching(messages)
# Is it ever worth it to bust the cache with prompt caching?
image_truncation_threshold = 50
if image_truncation_threshold:
image_truncation_threshold = 0
system["cache_control"] = {"type": "ephemeral"}

if only_n_most_recent_images:
Expand Down
2 changes: 1 addition & 1 deletion computer-use-demo/computer_use_demo/streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def setup_state():
if "tools" not in st.session_state:
st.session_state.tools = {}
if "only_n_most_recent_images" not in st.session_state:
st.session_state.only_n_most_recent_images = 10
st.session_state.only_n_most_recent_images = 3
if "custom_system_prompt" not in st.session_state:
st.session_state.custom_system_prompt = load_from_storage("system_prompt") or ""
if "hide_images" not in st.session_state:
Expand Down

0 comments on commit 6f85efe

Please sign in to comment.