Skip to content

Commit 7478c55

Browse files
Update default models and improve provider configs
Updated default model names for several providers in annotate.py to reflect latest versions. Added constants for fallback provider/model in consensus.py and refactored their usage. Enhanced model alias mapping in anthropic.py with new Claude 4.5 variants. Simplified DeepSeek retry logic by removing session-based retries and handling all errors in a single block. Streamlined OpenRouter model format check for clarity.
1 parent 900e2c1 commit 7478c55

5 files changed

Lines changed: 26 additions & 78 deletions

File tree

python/mllmcelltype/annotate.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,16 @@ def get_default_model(provider: str) -> str:
147147
148148
"""
149149
default_models = {
150-
"openai": "gpt-5",
151-
"anthropic": "claude-sonnet-4-20250514",
150+
"openai": "gpt-5.2",
151+
"anthropic": "claude-sonnet-4-5-20250929",
152152
"deepseek": "deepseek-chat",
153-
"gemini": "gemini-2.5-pro-preview-03-25",
154-
"qwen": "qwen-max-2025-01-25",
155-
"stepfun": "step-2-16k",
156-
"zhipu": "glm-4",
153+
"gemini": "gemini-2.5-pro",
154+
"qwen": "qwen3-max",
155+
"stepfun": "step-3",
156+
"zhipu": "glm-4-plus",
157157
"minimax": "MiniMax-Text-01",
158-
"grok": "grok-3-beta",
159-
"openrouter": "openai/gpt-5",
158+
"grok": "grok-3",
159+
"openrouter": "openai/gpt-5.2",
160160
}
161161

162162
return default_models.get(provider.lower(), "unknown")

python/mllmcelltype/consensus.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,19 @@
2929
# High entropy indicates high uncertainty
3030
DEFAULT_FALLBACK_ENTROPY = 2.0
3131

32+
# Default fallback LLM for consensus checking
33+
DEFAULT_FALLBACK_PROVIDER = "anthropic"
34+
DEFAULT_FALLBACK_MODEL = "claude-sonnet-4-5-20250929"
35+
3236

3337
def _call_llm_with_retry(
3438
prompt: str,
3539
provider: str,
3640
model: str,
3741
api_key: Optional[str],
3842
max_retries: int = 3,
39-
fallback_provider: str = "anthropic",
40-
fallback_model: str = "claude-sonnet-4-5-20250929",
43+
fallback_provider: str = DEFAULT_FALLBACK_PROVIDER,
44+
fallback_model: str = DEFAULT_FALLBACK_MODEL,
4145
api_keys: Optional[dict[str, str]] = None,
4246
base_urls: Optional[Union[str, dict[str, str]]] = None,
4347
) -> Optional[str]:
@@ -383,8 +387,8 @@ def check_consensus(
383387
model=primary_model,
384388
api_key=primary_api_key,
385389
max_retries=3,
386-
fallback_provider="anthropic",
387-
fallback_model="claude-sonnet-4-5-20250929",
390+
fallback_provider=DEFAULT_FALLBACK_PROVIDER,
391+
fallback_model=DEFAULT_FALLBACK_MODEL,
388392
api_keys=api_keys,
389393
)
390394

python/mllmcelltype/providers/anthropic.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212

1313
# Model alias mapping: user-friendly names -> official API model IDs
1414
MODEL_ALIASES = {
15-
# Claude 4.5 series (latest - Sep 2025)
15+
# Claude 4.5 series (latest - Nov 2025)
16+
"claude-opus-4.5": "claude-opus-4-5-20251101",
17+
"claude-opus-latest": "claude-opus-4-5-20251101",
1618
"claude-sonnet-4.5": "claude-sonnet-4-5-20250929",
1719
"claude-sonnet-latest": "claude-sonnet-4-5-20250929",
20+
"claude-haiku-4.5": "claude-haiku-4-5-20251001",
21+
"claude-haiku-latest": "claude-haiku-4-5-20251001",
1822
# Claude 4.1 series (Aug 2025)
1923
"claude-opus-4.1": "claude-opus-4-1-20250805",
20-
"claude-opus-latest": "claude-opus-4-1-20250805",
2124
# Claude 4 series (May 2025)
2225
"claude-opus-4": "claude-opus-4-20250514",
2326
"claude-sonnet-4": "claude-sonnet-4-20250514",

python/mllmcelltype/providers/deepseek.py

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
from typing import Optional
55

66
import requests
7-
from requests.adapters import HTTPAdapter
8-
from urllib3.util.retry import Retry
97

108
from ..logger import write_log
119
from ..url_utils import get_default_api_url, validate_base_url
@@ -60,35 +58,14 @@ def process_deepseek(
6058
"Authorization": f"Bearer {api_key}",
6159
}
6260

63-
# Increase retry parameters for DeepSeek
61+
# DeepSeek-specific config: longer timeout and more retries for stability
6462
max_retries = 5
6563
retry_delay = 3
6664
timeout = 90
6765

68-
# Create a session with retry strategy
69-
session = requests.Session()
70-
71-
# Configure retry strategy for the session
72-
retry_strategy = Retry(
73-
total=max_retries,
74-
backoff_factor=retry_delay,
75-
status_forcelist=[429, 500, 502, 503, 504],
76-
allowed_methods=["POST"],
77-
)
78-
79-
# Mount the adapter to the session
80-
adapter = HTTPAdapter(max_retries=retry_strategy)
81-
session.mount("https://", adapter)
82-
session.mount("http://", adapter)
83-
84-
write_log(
85-
f"Configured session with {max_retries} retries, {retry_delay}s backoff factor, and {timeout}s timeout"
86-
)
87-
8866
for attempt in range(max_retries):
8967
try:
90-
write_log(f"Sending request (attempt {attempt + 1}/{max_retries})...")
91-
response = session.post(url=url, headers=headers, json=body, timeout=timeout)
68+
response = requests.post(url=url, headers=headers, json=body, timeout=timeout)
9269

9370
# Check for errors
9471
if response.status_code != 200:
@@ -116,42 +93,11 @@ def process_deepseek(
11693
# Clean up results (remove commas at the end of lines)
11794
return [line.rstrip(",") for line in res]
11895

119-
except requests.exceptions.Timeout as e:
120-
write_log(
121-
f"Timeout during API call (attempt {attempt + 1}/{max_retries}): {str(e)}"
122-
)
123-
if attempt < max_retries - 1:
124-
wait_time = retry_delay * (2**attempt)
125-
write_log(f"Waiting {wait_time} seconds before retrying...")
126-
time.sleep(wait_time)
127-
else:
128-
write_log(
129-
f"All retry attempts failed with timeout. Last error: {str(e)}",
130-
level="error",
131-
)
132-
raise
133-
134-
except requests.exceptions.ConnectionError as e:
135-
write_log(
136-
f"Connection error during API call (attempt {attempt + 1}/{max_retries}): {str(e)}"
137-
)
138-
if attempt < max_retries - 1:
139-
wait_time = retry_delay * (2**attempt)
140-
write_log(f"Waiting {wait_time} seconds before retrying...")
141-
time.sleep(wait_time)
142-
else:
143-
write_log(
144-
f"All retry attempts failed with connection error. Last error: {str(e)}",
145-
level="error",
146-
)
147-
raise
148-
14996
except Exception as e:
15097
write_log(f"Error during API call (attempt {attempt + 1}/{max_retries}): {str(e)}")
15198
if attempt < max_retries - 1:
15299
wait_time = retry_delay * (2**attempt)
153100
write_log(f"Waiting {wait_time} seconds before retrying...")
154101
time.sleep(wait_time)
155102
else:
156-
write_log(f"All retry attempts failed. Last error: {str(e)}", level="error")
157103
raise

python/mllmcelltype/providers/openrouter.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,10 @@ def process_openrouter(
4646
write_log(f"Using model: {model}")
4747

4848
# Ensure model ID is in the correct format for OpenRouter (provider/model)
49-
if (
50-
"/" not in model
51-
and not model.startswith("anthropic/")
52-
and not model.startswith("openai/")
53-
and not model.startswith("meta-llama/")
54-
and not model.startswith("mistralai/")
55-
):
49+
if "/" not in model:
5650
write_log(
57-
f"Model ID '{model}' may not be in the correct format for OpenRouter. Expected format: 'provider/model'",
51+
f"Model ID '{model}' may not be in the correct format for OpenRouter. "
52+
"Expected format: 'provider/model'",
5853
level="warning",
5954
)
6055

0 commit comments

Comments
 (0)