-
-
Notifications
You must be signed in to change notification settings - Fork 154
WIP - Support thinking mode for Anthropic models #170
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
base: main
Are you sure you want to change the base?
Conversation
@@ -39,36 +39,51 @@ def build_base_payload(chat_messages, temperature, model, stream) | |||
{ | |||
model: model, | |||
messages: chat_messages.map { |msg| format_message(msg) }, | |||
temperature: temperature, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO:
Hey @crmne, can you please let me know if this looks to be heading in a direction that you're happy with architecturally? Cheers! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @rhys117!
Thanks for tackling this feature!
Issue: Inconsistent Naming
We've got with_reasoning()
, reasoning_content
, default_reasoning_budget
, but Anthropic's API calls it "thinking" - and we're mixing both terms in capabilities. This breaks our clean API pattern.
Solution: Standardize on "thinking"
Let's match Anthropic's terminology throughout:
# Method
def with_thinking(budget: nil)
# budget parameter instead of separate config call
end
# Response
response.thinking # not reasoning_content
response.thinking? # boolean check
# Config
default_thinking_budget # not reasoning
# Error
UnsupportedThinkingError
Usage:
chat = RubyLLM.chat(model: 'claude-3-7-sonnet')
.with_thinking(budget: 2048)
.with_temperature(1.0)
response = chat.ask("Short story about a dog")
puts response.thinking
puts response.content
This keeps our API consistent and beautiful. Thoughts?
That all sounds good to me, I'll take a look at this again in the coming days |
Resolves #154
Description
Add thinking support for Anthropic models.
Implementation Details
models.json
Message
via.thinking_content
Testing
So far, this has been tested manually.
TODO:
acts_as
persistent models