mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 11:09:46 +08:00
Merge #2454 from Mahdi-Hasan
This commit is contained in:
@@ -656,17 +656,13 @@ class OpenAICompatProvider(LLMProvider):
|
||||
if item_index >= len(input_items):
|
||||
return None
|
||||
rejected_item = input_items[item_index]
|
||||
if (
|
||||
not isinstance(rejected_item, dict)
|
||||
or rejected_item.get("type") != "message"
|
||||
or "status" not in rejected_item
|
||||
):
|
||||
if not isinstance(rejected_item, dict) or "status" not in rejected_item:
|
||||
return None
|
||||
|
||||
sanitized_items: list[Any] = []
|
||||
has_status = False
|
||||
for item in input_items:
|
||||
if isinstance(item, dict) and item.get("type") == "message" and "status" in item:
|
||||
if isinstance(item, dict) and "status" in item:
|
||||
sanitized_items.append(
|
||||
{key: value for key, value in item.items() if key != "status"}
|
||||
)
|
||||
|
||||
@@ -93,6 +93,33 @@ async def test_a_rejected_status_is_stripped_and_the_call_retried_once() -> None
|
||||
assert all("status" in item for item in calls[0]["input"] if item["type"] == "message")
|
||||
|
||||
|
||||
async def test_a_rejected_status_on_a_replayed_function_call_is_stripped_too() -> None:
|
||||
provider = _provider()
|
||||
create, calls = _recorder(fail_on={1}, error=_RejectedParameter("input[1].status"))
|
||||
provider._client.responses.create = create
|
||||
body = {
|
||||
"model": "responses-only-model",
|
||||
"input": [
|
||||
{"role": "user", "content": [{"type": "input_text", "text": "hi"}]},
|
||||
{
|
||||
"type": "function_call",
|
||||
"call_id": "c1",
|
||||
"name": "read_material",
|
||||
"arguments": "{}",
|
||||
"status": "completed",
|
||||
},
|
||||
{"type": "function_call_output", "call_id": "c1", "output": "ok"},
|
||||
],
|
||||
}
|
||||
|
||||
assert await provider._create_responses_with_status_retry(body) == "ok"
|
||||
|
||||
assert len(calls) == 2
|
||||
assert all("status" not in item for item in calls[1]["input"])
|
||||
assert calls[1]["input"][1]["name"] == "read_material"
|
||||
assert body["input"][1]["status"] == "completed"
|
||||
|
||||
|
||||
async def test_the_model_is_remembered_so_the_next_turn_costs_one_call() -> None:
|
||||
provider = _provider()
|
||||
create, calls = _recorder(fail_on={1})
|
||||
|
||||
Reference in New Issue
Block a user