Map Thinking Budget to Reasoning Effort for OpenAI Models

未关闭
#177 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
65/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript

调研方向

Start by locating the OpenAI adapter and the sibling issue's isReasoning branch, then read how it builds bodyPayload and accesses the model sampling profile. Add the specified thinkingBudget mapping and cover numeric thresholds, string values, absent budgets, and standard models in tests. Done when those tests and the listed typecheck, test, and lint commands pass.

由索引模型根据 Issue 内容生成。

描述

bug good first issue

Goal

Add reasoning_effort parameter support to the OpenAI adapter for reasoning models that accept it (o3, o3-mini, o4-mini, gpt-6).

Background

OpenAI's reasoning models accept a reasoning_effort parameter with values "low", "medium", or "high" that controls how many internal thinking tokens the model uses. Currently Codra sends no such parameter and cannot tune the cost/quality tradeoff for reasoning model calls.

This sub-issue is part of the parent issue: OpenAI adapter incompatible with reasoning models.

What to Build

After the isReasoning branch is in place (see sibling sub-issue), read the thinkingBudget from the model's sampling profile and map it to reasoning_effort:

if (isReasoning && sampling?.thinkingBudget) {
  let effort: "low" | "medium" | "high" | undefined;

  if (typeof sampling.thinkingBudget === "number") {
    effort =
      sampling.thinkingBudget > 10000 ? "high"
      : sampling.thinkingBudget > 3000 ? "medium"
      : "low";
  } else if (
    sampling.thinkingBudget === "low" ||
    sampling.thinkingBudget === "medium" ||
    sampling.thinkingBudget === "high"
  ) {
    effort = sampling.thinkingBudget;
  }

  if (effort) {
    bodyPayload.reasoning_effort = effort;
  }
}

Done When

  • reasoning_effort is included in requests to supported reasoning models when a thinking budget is configured
  • Numeric budgets are mapped to low/medium/high correctly
  • String values low/medium/high are passed through directly
  • The parameter is omitted when no thinking budget is configured
  • Standard (non-reasoning) models are not affected
  • Tests cover all mapping cases and the absent-budget case
  • npm run typecheck, npm test, and npm run lint all pass
主要语言
TypeScript
星标
125
派生
23
平均合并
2 天 13 小时
30 天内合并 PR
12

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

devarshishimpi/codra 的其他 Issue

查看 devarshishimpi/codra 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。