Skip to content

Commit

Permalink
bump retries; ssl min version
Browse files Browse the repository at this point in the history
  • Loading branch information
x5a committed Nov 14, 2024
1 parent eabba4b commit 3a841aa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion computer-use-demo/computer_use_demo/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
"""

import platform
import ssl
from collections.abc import Callable
from datetime import datetime
from enum import StrEnum
from typing import Any, cast

import certifi
import httpx
from anthropic import (
Anthropic,
Expand Down Expand Up @@ -103,7 +105,12 @@ async def sampling_loop(
betas = [COMPUTER_USE_BETA_FLAG]
image_truncation_threshold = 10
if provider == APIProvider.ANTHROPIC:
client = Anthropic(api_key=api_key)
# explicit SSL minimum version to avoid < TLSv1.2
ssl_context = ssl.create_default_context(cafile=certifi.where())
ssl_context.minimum_version = ssl.TLSVersion.TLSv1_2
http_client = httpx.Client(verify=ssl_context)

client = Anthropic(api_key=api_key, http_client=http_client, max_retries=5)
enable_prompt_caching = True
elif provider == APIProvider.VERTEX:
client = AnthropicVertex()
Expand Down

0 comments on commit 3a841aa

Please sign in to comment.