Skip to content

Commit 900e2c1

Browse files
Remove unused _get_api_key function
Deleted the redundant _get_api_key function and replaced its usage with direct dictionary access or fallback to load_api_key. This simplifies API key retrieval logic and reduces indirection.
1 parent ed2df01 commit 900e2c1

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

python/mllmcelltype/consensus.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,6 @@
3030
DEFAULT_FALLBACK_ENTROPY = 2.0
3131

3232

33-
def _get_api_key(provider: str, api_keys: Optional[dict[str, str]] = None) -> Optional[str]:
34-
"""Get API key for a specific provider.
35-
36-
Args:
37-
provider: Provider name (e.g., 'qwen', 'anthropic')
38-
api_keys: Optional dictionary of API keys
39-
40-
Returns:
41-
Optional[str]: API key if found, None otherwise
42-
"""
43-
# Try to get from provided api_keys first
44-
if api_keys and provider in api_keys:
45-
return api_keys[provider]
46-
47-
# Fallback to loading from environment/config
48-
return load_api_key(provider)
49-
50-
5133
def _call_llm_with_retry(
5234
prompt: str,
5335
provider: str,
@@ -108,7 +90,7 @@ def _call_llm_with_retry(
10890

10991
# Try fallback provider
11092
if api_keys:
111-
fallback_api_key = _get_api_key(fallback_provider, api_keys)
93+
fallback_api_key = api_keys.get(fallback_provider) or load_api_key(fallback_provider)
11294
if fallback_api_key:
11395
# Resolve base URL for fallback provider
11496
fallback_base_url = resolve_provider_base_url(fallback_provider, base_urls)
@@ -363,7 +345,7 @@ def check_consensus(
363345
primary_model = "qwen-max-2025-01-25"
364346

365347
# Get API key for primary provider
366-
primary_api_key = _get_api_key(primary_provider, api_keys)
348+
primary_api_key = (api_keys.get(primary_provider) if api_keys else None) or load_api_key(primary_provider)
367349

368350
# If primary model is not available and we have available_models, try to use one of them
369351
if not primary_api_key and available_models and not consensus_model:

0 commit comments

Comments
 (0)