server: support "reasoning_effort": "none" in OAI API#26045
Conversation
|
For what its worth, the UI has the concept of None/Low/Medium/High/Max, which is different reasoning budgets. maybe it makes sense to look there as well? |
|
the official doc also support and it should also be handled by response API: https://developers.openai.com/api/reference/resources/responses/methods/create#(resource)%20responses%20%3E%20(method)%20create%20%3E%20(params)%200.non_streaming%20%3E%20(param)%20reasoning%20%3E%20(schema)%20%2B%20(resource)%20%24shared%20%3E%20(model)%20reasoning%20%3E%20(schema)%20%3E%20(property)%20effort |
@MaxKruse From what I can tell this is handled client-side (maybe with
@ngxson I might be asking a dumb question here but isn't "max" just unlimited, which is already the default? In this PR all values except "none" are ignored, so the user could pass in "max" and it would have the expected result of the model just doing as much as it wants.
Good point, I will explore adding this too. |
|
|
||
| `chat_template_kwargs`: Allows sending additional parameters to the json templating system. For example: `{"enable_thinking": false}` | ||
|
|
||
| `reasoning_effort`: If set to `none`, reasoning will be disabled for this request. Other values (e.g., `low`, `high`) are not yet supported. |
There was a problem hiding this comment.
the current behavior seems like: anything other than none will be defaulted to max, probably better document this
the "not yet supported" is a bit ambiguous, it can be interpreted as "throwing an error"
There was a problem hiding this comment.
That makes sense, thanks. I just updated the documentation to hopefully avoid this interpretation.
|
It works with the responses API now too. I added an example of that. |
|
|
||
| // Parse also the OAI "reasoning_effort": "none" specific value | ||
| if (body.contains("reasoning_effort")) { | ||
| std::string reasoning_effort = body.at("reasoning_effort").get<std::string>(); |
There was a problem hiding this comment.
better to use json_value to make it similar to all other fields
Overview
The server already has a way to disable reasoning in the OpenAI-compatible chat completions API, via
chat_template_kwargs, but this is a bit annoying because it is non-canonical so it works for llama.cpp and not for other software, and vice versa. The OAI API already has a defined way to disable reasoning, via"reasoning_effort": "none".Of course,
reasoning_effortcan also do low/medium/etc. model-specific things, which free models generally do not support as far as I can tell, but it is relatively trivial to support the special case ofnoneat least. This will make it easier to support software that uses the OAI chat completions endpoint for super low-latency tasks without adding a special case for llama.cpp.Additional information
Example how to test:
Observe without
reasoning_effortor withreasoning_effortset to anything other than "none", it will reason for a while.Responses API example
It also works with the responses API now, which uses a nested
reasoning.effortvariable instead. For exampleRequirements