Add thinking to Requesty provider (#4041)

This commit is contained in:
Daniel Trugman 2025-05-27 16:16:25 +01:00 committed by GitHub
parent 9d4b4ebff0
commit 4ea75629e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
"roo-cline": patch
---
Add thinking controls for Requesty

View file

@ -19,12 +19,17 @@ export async function getRequestyModels(apiKey?: string): Promise<Record<string,
const rawModels = response.data.data
for (const rawModel of rawModels) {
const reasoningBudget = rawModel.supports_reasoning && rawModel.id.includes("claude")
const reasoningEffort = rawModel.supports_reasoning && rawModel.id.includes("openai")
const modelInfo: ModelInfo = {
maxTokens: rawModel.max_output_tokens,
contextWindow: rawModel.context_window,
supportsPromptCache: rawModel.supports_caching,
supportsImages: rawModel.supports_vision,
supportsComputerUse: rawModel.supports_computer_use,
supportsReasoningBudget: reasoningBudget,
supportsReasoningEffort: reasoningEffort,
inputPrice: parseApiPrice(rawModel.input_price),
outputPrice: parseApiPrice(rawModel.output_price),
description: rawModel.description,

View file

@ -31,6 +31,10 @@ type RequestyChatCompletionParams = OpenAI.Chat.ChatCompletionCreateParams & {
mode?: string
}
}
thinking?: {
type: string
budget_tokens?: number
}
}
export class RequestyHandler extends BaseProvider implements SingleCompletionHandler {
@ -94,10 +98,25 @@ export class RequestyHandler extends BaseProvider implements SingleCompletionHan
]
let maxTokens = undefined
if (this.options.includeMaxTokens) {
if (this.options.modelMaxTokens) {
maxTokens = this.options.modelMaxTokens
} else if (this.options.includeMaxTokens) {
maxTokens = model.info.maxTokens
}
let reasoningEffort = undefined
if (this.options.reasoningEffort) {
reasoningEffort = this.options.reasoningEffort
}
let thinking = undefined
if (this.options.modelMaxThinkingTokens) {
thinking = {
type: "enabled",
budget_tokens: this.options.modelMaxThinkingTokens,
}
}
const temperature = this.options.modelTemperature
const completionParams: RequestyChatCompletionParams = {
@ -107,6 +126,8 @@ export class RequestyHandler extends BaseProvider implements SingleCompletionHan
temperature: temperature,
stream: true,
stream_options: { include_usage: true },
reasoning_effort: reasoningEffort,
thinking: thinking,
requesty: {
trace_id: metadata?.taskId,
extra: {