loginowskid commited on
Commit
9e0af39
·
verified ·
1 Parent(s): f36b7a3

Sync from simready-oem-library-pm@02a6f31d

Browse files
Files changed (1) hide show
  1. tools/hf_space/agentic_issues.py +13 -2
tools/hf_space/agentic_issues.py CHANGED
@@ -29,16 +29,27 @@ MODEL = "claude-sonnet-4-6"
29
  MAX_TOKENS = 4096
30
 
31
 
 
 
 
 
 
 
 
 
 
 
32
  def _client():
33
  """Lazy import + construct so the module loads even when the
34
  anthropic SDK isn't installed (the caller probes this)."""
35
- if not os.environ.get("ANTHROPIC_API_KEY"):
 
36
  return None
37
  try:
38
  from anthropic import Anthropic
39
  except ImportError:
40
  return None
41
- return Anthropic()
42
 
43
 
44
  def is_available() -> bool:
 
29
  MAX_TOKENS = 4096
30
 
31
 
32
+ def _api_key() -> str | None:
33
+ """Token name varies by setup. ANTHROPIC_API_KEY is the SDK default;
34
+ on NVIDIA-internal Spaces (this one) the token is supplied as
35
+ NVIDIA_INFERENCE_TOKEN and the SDK is pointed at NVIDIA's Anthropic
36
+ proxy via ANTHROPIC_BASE_URL (Anthropic SDK reads BASE_URL natively,
37
+ no extra wiring needed here)."""
38
+ return (os.environ.get("ANTHROPIC_API_KEY")
39
+ or os.environ.get("NVIDIA_INFERENCE_TOKEN"))
40
+
41
+
42
  def _client():
43
  """Lazy import + construct so the module loads even when the
44
  anthropic SDK isn't installed (the caller probes this)."""
45
+ key = _api_key()
46
+ if not key:
47
  return None
48
  try:
49
  from anthropic import Anthropic
50
  except ImportError:
51
  return None
52
+ return Anthropic(api_key=key)
53
 
54
 
55
  def is_available() -> bool: