mirror of
https://github.com/openai/codex.git
synced 2026-09-13 11:47:17 +00:00
Add Python SDK goal turns
This commit is contained in:
28
sdk/python/examples/16_goal_turns/async.py
Normal file
28
sdk/python/examples/16_goal_turns/async.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
_EXAMPLES_ROOT = Path(__file__).resolve().parents[1]
|
||||
if str(_EXAMPLES_ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(_EXAMPLES_ROOT))
|
||||
|
||||
from _bootstrap import ensure_local_sdk_src, runtime_config
|
||||
|
||||
ensure_local_sdk_src()
|
||||
|
||||
import asyncio
|
||||
|
||||
from openai_codex import AsyncCodex
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
async with AsyncCodex(config=runtime_config()) as codex:
|
||||
thread = await codex.thread_start()
|
||||
result = await thread.run(
|
||||
"Improve the benchmark coverage in this repository.",
|
||||
goal=True,
|
||||
)
|
||||
print(result.final_response)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
17
sdk/python/examples/16_goal_turns/sync.py
Normal file
17
sdk/python/examples/16_goal_turns/sync.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
_EXAMPLES_ROOT = Path(__file__).resolve().parents[1]
|
||||
if str(_EXAMPLES_ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(_EXAMPLES_ROOT))
|
||||
|
||||
from _bootstrap import ensure_local_sdk_src, runtime_config
|
||||
|
||||
ensure_local_sdk_src()
|
||||
|
||||
from openai_codex import Codex
|
||||
|
||||
with Codex(config=runtime_config()) as codex:
|
||||
thread = codex.thread_start()
|
||||
result = thread.run("Improve the benchmark coverage in this repository.", goal=True)
|
||||
print(result.final_response)
|
||||
@@ -89,3 +89,5 @@ python examples/01_quickstart_constructor/async.py
|
||||
- separate `steer()` and `interrupt()` demos with concise summaries
|
||||
- `15_login_and_account/`
|
||||
- browser-login handle lifecycle, cancellation, and account inspection
|
||||
- `16_goal_turns/`
|
||||
- run a longer autonomous objective as one logical turn
|
||||
|
||||
Reference in New Issue
Block a user