mirror of
https://github.com/openai/codex.git
synced 2026-05-24 04:54:52 +00:00
## TL;DR Add `thread.run(...)` / `async thread.run(...)` convenience methods to the Python SDK for the common case. - add `RunInput = Input | str` and `RunResult` with `final_response`, collected `items`, and optional `usage` - keep `thread.turn(...)` strict and lower-level for streaming, steering, interrupting, and raw generated `Turn` access - update Python SDK docs, quickstart examples, and tests for the sync and async convenience flows ## Validation - `python3 -m pytest sdk/python/tests/test_public_api_signatures.py sdk/python/tests/test_public_api_runtime_behavior.py` - `python3 -m pytest sdk/python/tests/test_real_app_server_integration.py -k 'thread_run_convenience or async_thread_run_convenience'` (skipped in this environment) --------- Co-authored-by: Codex <noreply@openai.com>
114 lines
2.3 KiB
Python
114 lines
2.3 KiB
Python
from .async_client import AsyncAppServerClient
|
|
from .client import AppServerClient, AppServerConfig
|
|
from .errors import (
|
|
AppServerError,
|
|
AppServerRpcError,
|
|
InternalRpcError,
|
|
InvalidParamsError,
|
|
InvalidRequestError,
|
|
JsonRpcError,
|
|
MethodNotFoundError,
|
|
ParseError,
|
|
RetryLimitExceededError,
|
|
ServerBusyError,
|
|
TransportClosedError,
|
|
is_retryable_error,
|
|
)
|
|
from .generated.v2_all import (
|
|
AskForApproval,
|
|
Personality,
|
|
PlanType,
|
|
ReasoningEffort,
|
|
ReasoningSummary,
|
|
SandboxMode,
|
|
SandboxPolicy,
|
|
ServiceTier,
|
|
ThreadItem,
|
|
ThreadForkParams,
|
|
ThreadListParams,
|
|
ThreadResumeParams,
|
|
ThreadSortKey,
|
|
ThreadSourceKind,
|
|
ThreadStartParams,
|
|
ThreadTokenUsageUpdatedNotification,
|
|
TurnCompletedNotification,
|
|
TurnStartParams,
|
|
TurnStatus,
|
|
TurnSteerParams,
|
|
)
|
|
from .models import InitializeResponse
|
|
from .api import (
|
|
AsyncCodex,
|
|
AsyncThread,
|
|
AsyncTurnHandle,
|
|
Codex,
|
|
ImageInput,
|
|
Input,
|
|
InputItem,
|
|
LocalImageInput,
|
|
MentionInput,
|
|
RunResult,
|
|
SkillInput,
|
|
TextInput,
|
|
Thread,
|
|
TurnHandle,
|
|
)
|
|
from .retry import retry_on_overload
|
|
|
|
__version__ = "0.2.0"
|
|
|
|
__all__ = [
|
|
"__version__",
|
|
"AppServerClient",
|
|
"AsyncAppServerClient",
|
|
"AppServerConfig",
|
|
"Codex",
|
|
"AsyncCodex",
|
|
"Thread",
|
|
"AsyncThread",
|
|
"TurnHandle",
|
|
"AsyncTurnHandle",
|
|
"InitializeResponse",
|
|
"RunResult",
|
|
"Input",
|
|
"InputItem",
|
|
"TextInput",
|
|
"ImageInput",
|
|
"LocalImageInput",
|
|
"SkillInput",
|
|
"MentionInput",
|
|
"ThreadItem",
|
|
"ThreadTokenUsageUpdatedNotification",
|
|
"TurnCompletedNotification",
|
|
"AskForApproval",
|
|
"Personality",
|
|
"PlanType",
|
|
"ReasoningEffort",
|
|
"ReasoningSummary",
|
|
"SandboxMode",
|
|
"SandboxPolicy",
|
|
"ServiceTier",
|
|
"ThreadStartParams",
|
|
"ThreadResumeParams",
|
|
"ThreadListParams",
|
|
"ThreadSortKey",
|
|
"ThreadSourceKind",
|
|
"ThreadForkParams",
|
|
"TurnStatus",
|
|
"TurnStartParams",
|
|
"TurnSteerParams",
|
|
"retry_on_overload",
|
|
"AppServerError",
|
|
"TransportClosedError",
|
|
"JsonRpcError",
|
|
"AppServerRpcError",
|
|
"ParseError",
|
|
"InvalidRequestError",
|
|
"MethodNotFoundError",
|
|
"InvalidParamsError",
|
|
"InternalRpcError",
|
|
"ServerBusyError",
|
|
"RetryLimitExceededError",
|
|
"is_retryable_error",
|
|
]
|