Skip to content

fix(examples): unbreak claude-query under anthropic 1.x - #1948

Open
shcheklein wants to merge 1 commit into
mainfrom
fix/anthropic-1x-example
Open

fix(examples): unbreak claude-query under anthropic 1.x#1948
shcheklein wants to merge 1 commit into
mainfrom
fix/anthropic-1x-example

Conversation

@shcheklein

Copy link
Copy Markdown
Contributor

Problem

The examples (ubuntu-latest, 3.14, llm_and_nlp) job has failed on every branch since 2026-08-21. Last green run: 32408870541 (08-20).

datachain.lib.udf.UdfRunError: TypeError: Messages.parse() got an unexpected keyword argument 'temperature'
FAILED tests/examples/test_examples.py::test_llm_and_nlp_examples[examples/llm_and_nlp/claude-query.py]

anthropic is unpinned in the examples extra, and anthropic 1.0.0 shipped on 2026-08-20 (previous release 0.125.0, 08-19). The 1.x major removes the sampling parameters temperature / top_p / top_k from messages.create() / .stream() / .parse() and their beta.messages counterparts — passing one is now a TypeError. Current models don't use them and the SDK offers no escape hatch.

This never blocked a merge because examples is in the check gate's allowed-failures, so it has just been quietly red.

Fix

  • Drop temperature=TEMPERATURE (and the now-unused constant) from the messages.parse call.
  • Move client.beta.messages.parse(...)client.messages.parse(...). Structured outputs is GA, so the beta path was churn risk for no benefit. output_format=Rating is the helper argument and is unchanged in 1.x.

Verification

Checked against a real anthropic==1.0.0 install: the exact kwarg set the example now passes binds cleanly to messages.parse. messages.parse also exists on 0.125.0, so the example still runs for anyone on a recent 0.x. File compiles and passes ruff.

Nothing else in the repo touches the SDK — tests/func/test_optional.py only mimics anthropic.types shapes without importing it, and the setup() docstring in datachain.py passes no sampling params.

Not done here

Left anthropic unbounded in the examples extra. Since the check gate already tolerates examples failures, letting upstream breakage surface looks deliberate. If you'd rather be warned by dependabot than by red CI, an anthropic<2 bound in the litellm style is a one-liner — happy to add it.

🤖 Generated with Claude Code

anthropic 1.0.0 (released 2026-08-20) removes temperature/top_p/top_k from
messages.create/.stream/.parse and their beta counterparts, so the unpinned
examples extra started resolving an SDK that rejects the call:

  TypeError: Messages.parse() got an unexpected keyword argument 'temperature'

The llm_and_nlp examples job has failed on every branch since; it is in the
check gate's allowed-failures, so it never blocked a merge.

Also move off client.beta.messages.parse -- structured outputs is GA, and
messages.parse exists on recent 0.x too, so the example works on both.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying datachain with  Cloudflare Pages  Cloudflare Pages

Latest commit: e3a1d82
Status: ✅  Deploy successful!
Preview URL: https://bf9fea80.datachain-2g6.pages.dev
Branch Preview URL: https://fix-anthropic-1x-example.datachain-2g6.pages.dev

View logs

@shcheklein
shcheklein requested a review from a team August 22, 2026 17:53
@codecov

codecov Bot commented Aug 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Restores the Claude query example’s compatibility with Anthropic SDK 1.x.

Changes:

  • Uses the GA client.messages.parse() API.
  • Removes unsupported sampling configuration.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants