feat: add OpenRouter reasoning mode support (v0.4.9)
Enables reasoning-capable models (Grok 4.1 Fast, DeepSeek-R1, etc.) via new admin settings: Enable Reasoning toggle and Reasoning Effort selector. Provider auto-injects reasoning params when enabled; callers can override per-call via options array. Response parser captures reasoning_tokens and reasoning_content for visibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -43,8 +43,10 @@ class PRAutoBlogger_OpenRouter_Response_Parser {
|
||||
* model: string,
|
||||
* prompt_tokens: int,
|
||||
* completion_tokens: int,
|
||||
* reasoning_tokens: int,
|
||||
* total_tokens: int,
|
||||
* finish_reason: string,
|
||||
* reasoning_content: string,
|
||||
* }
|
||||
*
|
||||
* @throws \RuntimeException If response structure is invalid.
|
||||
@@ -94,13 +96,18 @@ class PRAutoBlogger_OpenRouter_Response_Parser {
|
||||
|
||||
$usage = $data['usage'] ?? [];
|
||||
|
||||
// Reasoning content lives alongside 'content' in the message object.
|
||||
$reasoning_content = $data['choices'][0]['message']['reasoning'] ?? '';
|
||||
|
||||
return [
|
||||
'content' => (string) $content,
|
||||
'model' => $data['model'] ?? $model,
|
||||
'prompt_tokens' => (int) ( $usage['prompt_tokens'] ?? 0 ),
|
||||
'completion_tokens' => (int) ( $usage['completion_tokens'] ?? 0 ),
|
||||
'reasoning_tokens' => (int) ( $usage['reasoning_tokens'] ?? 0 ),
|
||||
'total_tokens' => (int) ( $usage['total_tokens'] ?? 0 ),
|
||||
'finish_reason' => $data['choices'][0]['finish_reason'] ?? 'unknown',
|
||||
'reasoning_content' => (string) $reasoning_content,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user