-
-
Notifications
You must be signed in to change notification settings - Fork 227
Introduce support of Responses API #290
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
Some model (incl. `o4-mini-deep-research`) aren't compatible with the chat/completion API. This PR introduces a new `Response` class, which - similarly to `Chat` (and inheriting from the same base `Conversation` class) - allows a user to target the `responses` endpoint.
@crmne let me know what you think about the approach, I think this is an important missing part of RubyLLM to actually support all models. If the approach does look good to you, I'll add more tests (incl. streaming ones) and documentation. |
@@ -8,162 +8,17 @@ module RubyLLM | |||
# chat = RubyLLM.chat | |||
# chat.ask "What's the best way to learn Ruby?" | |||
# chat.ask "Can you elaborate on that?" | |||
class Chat | |||
include Enumerable |
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.
I'm moving most of the Chat
implementation to a base class Conversation
so both Chat
and Conversation
inherit from the logic
@@ -68,7 +68,7 @@ | |||
instance_double(Message, | |||
content: '', | |||
tool_calls: { | |||
'tool_123' => instance_double(ToolCall, | |||
'tool_123' => instance_double(RubyLLM::ToolCall, | |||
id: 'tool_123', | |||
name: 'test_tool', | |||
arguments: { 'arg1' => 'value1' }) |
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.
I think those tests were wrongly relying on the Dummy app ToolCall
class VS the RubyLLM
one
@@ -143,6 +143,10 @@ | |||
end | |||
end | |||
|
|||
RESPONSE_MODELS = [ | |||
{ provider: :openai, model: 'o4-mini-deep-research', params: { tools: [{ type: 'web_search_preview' }] } } |
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.
the o4-mini-deep-research
requires 1 web_search_preview
tool.
I was working on this other night also. I think what I would prefer is if RubyLLM hid from me which endpoint was necessary for the given model and just handled this automatically. Not sure I love the library consumer having to figure out whether to call chat or response. Excited to see someone working on this! Definitely needed (see #213). |
Yes, I wasn't sure as the tools and some parameters are different.
Gosh, thanks for sharing; I couldn't find anything searching for |
Wondering if we can just switch to Responses for everything and keep the old code around for compatibility on other providers. |
What this does
Some models (incl.
o4-mini-deep-research
) aren't compatible with the chat/completion API. They will fail withThis PR introduces a new
Response
class, which - similarly toChat
(and inheriting from the same baseConversation
class) - allows a user to target theresponses
endpoint.Type of change
Scope check
Quality check
overcommit --install
and all hooks passmodels.json
,aliases.json
)API changes
Related issues
I was surprised nothing was there.