Skip to content
New issue

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

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

Already on GitHub? # to your account

Limit images to 3 #176

Merged
merged 1 commit into from
Nov 22, 2024
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
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
Loading