mirror of
https://github.com/openai/codex.git
synced 2026-05-23 12:34:25 +00:00
Use TurnStatus in retry examples
This commit is contained in:
@@ -21,6 +21,7 @@ from openai_codex import (
|
||||
TextInput,
|
||||
is_retryable_error,
|
||||
)
|
||||
from openai_codex.types import TurnStatus
|
||||
|
||||
ResultT = TypeVar("ResultT")
|
||||
|
||||
@@ -72,6 +73,10 @@ async def main() -> None:
|
||||
print(f"JSON-RPC error {exc.code}: {exc.message}")
|
||||
return
|
||||
|
||||
if result.status == TurnStatus.failed:
|
||||
print("Turn failed:", result.error)
|
||||
return
|
||||
|
||||
print("Text:", result.final_response)
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ from openai_codex import (
|
||||
TextInput,
|
||||
retry_on_overload,
|
||||
)
|
||||
from openai_codex.types import TurnStatus
|
||||
|
||||
with Codex(config=runtime_config()) as codex:
|
||||
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:
|
||||
print(f"JSON-RPC error {exc.code}: {exc.message}")
|
||||
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