Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anthropic[patch]: support claude 3.7 sonnet #29971

Merged
merged 5 commits into from
Feb 24, 2025
Merged

anthropic[patch]: support claude 3.7 sonnet #29971

merged 5 commits into from
Feb 24, 2025

Conversation

ccurme
Copy link
Collaborator

@ccurme ccurme commented Feb 24, 2025

No description provided.

@ccurme ccurme requested a review from baskaryan February 24, 2025 18:51
Copy link

vercel bot commented Feb 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Feb 24, 2025 7:26pm

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Feb 24, 2025
Copy link
Collaborator

@baskaryan baskaryan left a comment

Choose a reason for hiding this comment

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

tangential but ooc what happens if you send thinking block without the signature?

if (
isinstance(block, dict)
and block.get("type") == "thinking"
and "text" in block
Copy link
Collaborator

Choose a reason for hiding this comment

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

isn't "thinking" the key in a type: thinking block?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

model_dumping the content generates a key {"text": None}, so I remove it here.

@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Feb 24, 2025
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Feb 24, 2025
@ccurme
Copy link
Collaborator Author

ccurme commented Feb 24, 2025

tangential but ooc what happens if you send thinking block without the signature?

BadRequestError: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages.1.content.0.thinking.signature: Field required'}}

@baskaryan
Copy link
Collaborator

we should follow up with reasoning token counts if their api exposes those (guessing it does)

@ccurme ccurme merged commit ded886f into master Feb 24, 2025
29 checks passed
@ccurme ccurme deleted the cc/anthropic branch February 24, 2025 20:17
@ccurme
Copy link
Collaborator Author

ccurme commented Feb 24, 2025

we should follow up with reasoning token counts if their api exposes those (guessing it does)

I'm not seeing these carved out in the response:

import anthropic 
 
client = anthropic.Anthropic()
response = client.messages.create(
    model="claude-3-7-sonnet-latest",
    max_tokens=5000,
    thinking={
        "type": "enabled",
        "budget_tokens": 2000,
    },
    messages=[{
        "role": "user",
        "content": "Hello",
    }]
)

response.usage
Usage(cache_creation_input_tokens=0, cache_read_input_tokens=0, input_tokens=36, output_tokens=128)

@baskaryan
Copy link
Collaborator

we should follow up with reasoning token counts if their api exposes those (guessing it does)

I'm not seeing these carved out in the response:

import anthropic 
 
client = anthropic.Anthropic()
response = client.messages.create(
    model="claude-3-7-sonnet-latest",
    max_tokens=5000,
    thinking={
        "type": "enabled",
        "budget_tokens": 2000,
    },
    messages=[{
        "role": "user",
        "content": "Hello",
    }]
)

response.usage
Usage(cache_creation_input_tokens=0, cache_read_input_tokens=0, input_tokens=36, output_tokens=128)

yea doesn't seem updated yet https://github.com/anthropics/anthropic-sdk-python/blob/main/src/anthropic/types/usage.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm PR looks good. Use to confirm that a PR is ready for merging. size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants