Filter out reasoning items from previous turns (#5857)
Reduces request size and prevents 400 errors when switching between API orgs. Based on Responses API behavior described in https://cookbook.openai.com/examples/responses_api/reasoning_items#caching
This commit is contained in:
@@ -68,6 +68,14 @@ impl ResponsesRequest {
|
||||
.clone()
|
||||
}
|
||||
|
||||
pub fn inputs_of_type(&self, ty: &str) -> Vec<Value> {
|
||||
self.input()
|
||||
.iter()
|
||||
.filter(|item| item.get("type").and_then(Value::as_str) == Some(ty))
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn function_call_output(&self, call_id: &str) -> Value {
|
||||
self.call_output(call_id, "function_call_output")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user