Skip to content

Fix gpt-5-family labeling, refresh OpenAI model list, add Claude chat models - #155

Merged
enjalot merged 3 commits into
mainfrom
update-proprietary-models
Jul 11, 2026
Merged

Fix gpt-5-family labeling, refresh OpenAI model list, add Claude chat models#155
enjalot merged 3 commits into
mainfrom
update-proprietary-models

Conversation

@enjalot

@enjalot enjalot commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Why gpt-5-mini didn't work

OpenAIChatProvider.summarize() went through outlines' OpenAI wrapper, which always sends max_tokens — the gpt-5 family rejects that parameter (400: they only accept max_completion_tokens), so every gpt-5* model failed at label time. Reproduced live, then fixed by calling chat.completions.create directly with no token-cap or sampling params (the gpt-5 family also rejects non-default temperature). Two adjacent fixes: chat() previously called an unawaited AsyncOpenAI coroutine (it now uses a sync client), and tiktoken.encoding_for_model falls back to the gpt-4o encoding for model names newer than the installed tiktoken.

Registry refresh (verified against the live API)

  • Added: gpt-5.5, gpt-5.4, gpt-5.4-mini, gpt-5.4-nano
  • Dropped: legacy gpt-4 and gpt-4-turbo
  • All 13 OpenAI chat entries verified end-to-end with real summarize() calls — including the previously-broken gpt-5-mini
  • Embedding registry checked against the live models list: text-embedding-3-small/large are still current, no changes needed

New: Anthropic provider

AnthropicChatProvider (Messages API, lazy SDK import per repo convention) with registry entries for claude-haiku-4-5, claude-sonnet-5, and claude-opus-4-8. Note there is no "Haiku 5" — Haiku 4.5 is the newest Haiku tier. Details:

  • System messages are hoisted to the top-level system param; stop_reason: "refusal" returns an empty label with a warning instead of crashing
  • encoder = Nonelabel_clusters.py already handles this by skipping token-based sample truncation
  • If no ANTHROPIC_API_KEY is set in .env, the client falls back to the SDK's own credential resolution (env vars / ant auth login profile)
  • ANTHROPIC_API_KEY added to _SUPPORTED_API_KEYS, so it shows up in the Settings page automatically
  • anthropic added as a dependency (uv.lock re-locked with UV_EXTRA_INDEX_URL=https://pypi.nvidia.com uv lock --index-strategy unsafe-best-match, same as Support Model2Vec static embedding models via the existing HF path #153; diff adds only anthropic 0.116.0)

Test plan

  • tests/test_chat_providers.py: 12 new tests with fake clients — asserts the OpenAI provider sends no max_tokens/max_completion_tokens/temperature/top_p, registry resolution for all entries, Anthropic system-hoisting/refusal/encoder behavior
  • uv run pytest tests/ -q — 231 passed, 2 skipped
  • uv run ruff check latentscope/ — clean
  • Live verification: all 13 OpenAI registry models produced labels. Claude models are mock-tested only — no Anthropic key on this machine; needs one live run after adding ANTHROPIC_API_KEY in Settings.

🤖 Generated with Claude Code

The OpenAI chat provider routed summarize() through outlines, whose
OpenAI wrapper always sends max_tokens (and temperature) — the gpt-5
family rejects max_tokens (400: use max_completion_tokens), so
gpt-5-mini and friends failed at label time. summarize() now calls
chat.completions directly with no token-cap or sampling params, and
chat() uses a sync client (it previously called an unawaited
AsyncOpenAI coroutine). tiktoken falls back to the gpt-4o encoding for
model names it doesn't know.

Registry refresh: add gpt-5.5, gpt-5.4, gpt-5.4-mini, gpt-5.4-nano;
drop legacy gpt-4 and gpt-4-turbo. All 13 OpenAI entries verified live.

New AnthropicChatProvider (Messages API, lazy import, system-message
hoisting, refusal handling, SDK credential fallback when no
ANTHROPIC_API_KEY in .env) with claude-haiku-4-5, claude-sonnet-5, and
claude-opus-4-8 registry entries; ANTHROPIC_API_KEY joins the supported
keys so it appears in Settings.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 88b2f3cba2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +17 to +19
# no local tokenizer for Claude models; label_clusters handles
# encoder=None by skipping token-based sample truncation
self.encoder = None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve label token caps for Claude

When a user labels clusters with one of the new Anthropic models and the selected samples contain long text (or samples=0), the configured --max_tokens_per_sample and --max_tokens_total limits are silently ignored: label_clusters.py only truncates in the if enc is not None branch and otherwise sends the full selected rows. Setting self.encoder = None here therefore lets Claude requests exceed the intended token budget, which can produce context-window 400s or unexpectedly large requests instead of honoring the Setup/CLI limits.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 408278c — the provider now supplies the approximate gpt-4o tiktoken encoding (the same fallback the OpenAI provider uses for custom endpoints), so --max_tokens_per_sample/--max_tokens_total truncation applies to Claude requests too. Also live-verified all three Claude registry models end-to-end with the real key.

enjalot and others added 2 commits July 11, 2026 10:07
…155 review)

encoder=None silently disabled --max_tokens_per_sample /
--max_tokens_total truncation in label_clusters. Claude has no local
tokenizer, so reuse the gpt-4o tiktoken encoding as an approximation —
the same fallback the OpenAI provider uses for custom endpoints.
Verified all three Claude registry models live end-to-end.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Integrates #151's retry boundary with the outlines-free OpenAI chat
provider and the new Anthropic provider; re-locked uv.lock with both
the anthropic dep and model2vec[distill].

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@enjalot
enjalot merged commit 0c46baf into main Jul 11, 2026
5 checks passed
@enjalot
enjalot deleted the update-proprietary-models branch July 11, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant