mirror of
https://github.com/openai/codex.git
synced 2026-06-01 19:02:59 +00:00
Use TurnStatus in retry examples
This commit is contained in:
@@ -21,6 +21,7 @@ from openai_codex import (
|
|||||||
TextInput,
|
TextInput,
|
||||||
is_retryable_error,
|
is_retryable_error,
|
||||||
)
|
)
|
||||||
|
from openai_codex.types import TurnStatus
|
||||||
|
|
||||||
ResultT = TypeVar("ResultT")
|
ResultT = TypeVar("ResultT")
|
||||||
|
|
||||||
@@ -72,6 +73,10 @@ async def main() -> None:
|
|||||||
print(f"JSON-RPC error {exc.code}: {exc.message}")
|
print(f"JSON-RPC error {exc.code}: {exc.message}")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if result.status == TurnStatus.failed:
|
||||||
|
print("Turn failed:", result.error)
|
||||||
|
return
|
||||||
|
|
||||||
print("Text:", result.final_response)
|
print("Text:", result.final_response)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from openai_codex import (
|
|||||||
TextInput,
|
TextInput,
|
||||||
retry_on_overload,
|
retry_on_overload,
|
||||||
)
|
)
|
||||||
|
from openai_codex.types import TurnStatus
|
||||||
|
|
||||||
with Codex(config=runtime_config()) as codex:
|
with Codex(config=runtime_config()) as codex:
|
||||||
thread = codex.thread_start(model="gpt-5.4", config={"model_reasoning_effort": "high"})
|
thread = codex.thread_start(model="gpt-5.4", config={"model_reasoning_effort": "high"})
|
||||||
@@ -32,4 +33,7 @@ with Codex(config=runtime_config()) as codex:
|
|||||||
except JsonRpcError as exc:
|
except JsonRpcError as exc:
|
||||||
print(f"JSON-RPC error {exc.code}: {exc.message}")
|
print(f"JSON-RPC error {exc.code}: {exc.message}")
|
||||||
else:
|
else:
|
||||||
print("Text:", result.final_response)
|
if result.status == TurnStatus.failed:
|
||||||
|
print("Turn failed:", result.error)
|
||||||
|
else:
|
||||||
|
print("Text:", result.final_response)
|
||||||
|
|||||||
Reference in New Issue
Block a user