Thinking levels: Tab cycles off/low/medium/high, /effort
This commit is contained in:
1 parent
2f1ce2c072
commit
ab2af421a4
9 files changed
+180
-16
No files matched your search
@@ -12,8 +12,6 @@ pub struct Codex {
|
||||
auth: Auth,
|
||||
base_url: String,
|
||||
http: reqwest::Client,
|
||||
/// "none" | "minimal" | "low" | "medium" | "high"
|
||||
pub reasoning_effort: Option<String>,
|
||||
}
|
||||
|
||||
impl Codex {
|
||||
@@ -22,7 +20,6 @@ impl Codex {
|
||||
auth,
|
||||
base_url: "https://chatgpt.com/backend-api/codex".into(),
|
||||
http: reqwest::Client::new(),
|
||||
reasoning_effort: Some("medium".into()),
|
||||
}
|
||||
}
|
||||
pub fn login_default() -> Result<Self> {
|
||||
@@ -42,7 +39,7 @@ fn split_id(id: &str) -> (&str, Option<&str>) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn body(req: &Request, effort: Option<&str>) -> Value {
|
||||
pub fn body(req: &Request) -> Value {
|
||||
let mut input = vec![];
|
||||
for m in &req.messages {
|
||||
for b in &m.content {
|
||||
@@ -109,9 +106,12 @@ pub fn body(req: &Request, effort: Option<&str>) -> Value {
|
||||
"text": {"verbosity": "low"},
|
||||
"include": ["reasoning.encrypted_content"],
|
||||
});
|
||||
if let Some(e) = effort {
|
||||
b["reasoning"] = json!({"effort": e, "summary": "auto"});
|
||||
}
|
||||
// Off has no Codex equivalent (see Effort::levels); send the lowest level instead
|
||||
let e = match req.effort {
|
||||
crate::Effort::Off | crate::Effort::Low => "low",
|
||||
e => e.name(),
|
||||
};
|
||||
b["reasoning"] = json!({"effort": e, "summary": "auto"});
|
||||
b
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ impl Provider for Codex {
|
||||
.header("OpenAI-Beta", "responses=experimental")
|
||||
.header("accept", "text/event-stream")
|
||||
.header("user-agent", concat!("hx/", env!("CARGO_PKG_VERSION")))
|
||||
.json(&body(&req, self.reasoning_effort.as_deref()))
|
||||
.json(&body(&req))
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| Error::Http(e.to_string()))?;
|
||||
@@ -528,8 +528,9 @@ mod tests {
|
||||
input_schema: json!({"type":"object"}),
|
||||
}],
|
||||
max_tokens: 100,
|
||||
effort: crate::Effort::Low,
|
||||
};
|
||||
let b = body(&req, Some("low"));
|
||||
let b = body(&req);
|
||||
let inp = b["input"].as_array().unwrap();
|
||||
assert_eq!(inp[0]["content"][0]["type"], "input_text");
|
||||
assert_eq!(inp[1]["type"], "reasoning");
|
||||
|
||||
Reference in new issue
Block a user