python-codex 0.6.0__py3-none-any.whl → 0.6.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,216 @@
1
+ Metadata-Version: 2.1
2
+ Name: python-codex
3
+ Version: 0.6.2
4
+ Summary: A minimal Python extraction of Codex's main agent loop
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.6.2
7
+ Requires-Dist: dataclasses>=0.8; python_version < '3.7'
8
+ Requires-Dist: importlib-metadata>=4.8.3; python_version < '3.8'
9
+ Requires-Dist: loguru>=0.7.3
10
+ Requires-Dist: prompt-toolkit>=3.0.36
11
+ Requires-Dist: pyyaml>=6.0
12
+ Requires-Dist: requests>=2.27.1
13
+ Requires-Dist: starlette<0.20,>=0.19.1; python_version < '3.7'
14
+ Requires-Dist: starlette>=0.19.1; python_version >= '3.7'
15
+ Requires-Dist: tomli<2,>=1.2.3; python_version < '3.11'
16
+ Requires-Dist: typing-extensions>=4.1.1; python_version < '3.8'
17
+ Requires-Dist: uvicorn<0.17,>=0.16.0; python_version < '3.7'
18
+ Requires-Dist: uvicorn>=0.16.0; python_version >= '3.7'
19
+ Description-Content-Type: text/markdown
20
+
21
+ # pycodex
22
+
23
+ [中文](README_ZH.md)
24
+
25
+ pycodex is a Python implementation of the [Codex](https://github.com/openai/codex)
26
+ coding agent. Use it in a terminal, in a browser, or from your own Python code.
27
+ It supports file editing, command execution, multiple agents and saved sessions.
28
+ See [upstream alignment](docs/ALIGNMENT.md) for the supported scope and differences.
29
+
30
+ ## Install
31
+
32
+ | Package | Includes | Python |
33
+ | --- | --- | --- |
34
+ | `python-codex` | CLI and Python API | 3.6.2+ |
35
+ | `pycodex-ws` | Core plus browser workspace and optional Feishu integration | 3.7+ |
36
+
37
+ For the CLI and Python API:
38
+
39
+ ```bash
40
+ python3 -m pip install --upgrade python-codex
41
+ ```
42
+
43
+ For the browser workspace, install `pycodex-ws`; it includes the matching core version:
44
+
45
+ ```bash
46
+ python3 -m pip install --upgrade pycodex-ws
47
+ ```
48
+
49
+ ## Configure a model
50
+
51
+ Start with [config_examples/](config_examples/README.md) for Responses, StepFun,
52
+ Chat Completions, Claude Messages or Gemini. Give an agent your endpoint and key
53
+ (StepFun Coding Plan includes its endpoint) and ask it to follow that guide to
54
+ install and verify a config or profile.
55
+
56
+ Create `~/.codex/config.toml`. For example, with OpenAI:
57
+
58
+ ```toml
59
+ model = "gpt-5.4"
60
+ model_provider = "openai"
61
+ ```
62
+
63
+ Supply the API key through the environment or `~/.codex/.env`:
64
+
65
+ ```bash
66
+ export OPENAI_API_KEY="your-api-key"
67
+ ```
68
+
69
+ For another provider, configure its `base_url` and `env_key`. Select the API with
70
+ `compat_api` in the profile or provider table:
71
+
72
+ | `compat_api` | API |
73
+ | --- | --- |
74
+ | `"none"` (default) | Responses |
75
+ | `"chat_completions"` | Chat Completions, including Step |
76
+ | `"messages"` | Claude Messages |
77
+ | `"gemini"` | Gemini API |
78
+
79
+ Legacy `use_chat_completion = true/false` remains supported as `chat_completions/none`.
80
+
81
+ Use `--profile NAME` to select `NAME.config.toml` beside the base config or an
82
+ embedded `[profiles.NAME]` table. Use `--config PATH` for a different config file,
83
+ and `pycodex doctor` to check configuration and connectivity.
84
+ The browser workspace picks up profile changes for new sessions without a restart.
85
+
86
+ See [configuration](docs/CONTEXT.md#配置读取与-profile) and the
87
+ [Gemini setup example](docs/responses_server/README.md#gemini-api).
88
+ Gemini 4 Argon includes a prompt adapted from Antigravity.
89
+ Gemini tool arguments stream as they are generated; tools run after the complete call is received.
90
+ Gemini continuation omits unsigned empty text parts while preserving thought signatures,
91
+ including when resuming recorded sessions.
92
+
93
+ ## Use the CLI
94
+
95
+ Run these commands from your project directory:
96
+
97
+ ```bash
98
+ pycodex
99
+ pycodex "Summarize this repository."
100
+ pycodex --profile my_profile "Review the latest changes."
101
+ pycodex --json "Summarize this repository."
102
+ ```
103
+
104
+ The first command starts an interactive session; the others run a single task.
105
+ Web skill completion is an [optional frontend feature](packages/pycodex-ws/workspace_server/optional_features/skill-completion/README.md).
106
+ Apply `skill-completion` through Customize to enable @/$ prefix suggestions.
107
+ The agent can edit files and run commands with your user account's permissions.
108
+
109
+ | Command | Purpose |
110
+ | --- | --- |
111
+ | `/model`, `/effort` | View or change the model and reasoning effort |
112
+ | `/cd <directory>` | Change directory while idle |
113
+ | `/title`, `/history` | Manage the title and inspect conversation history |
114
+ | `/resume` | List or resume saved sessions |
115
+ | `/compact` | Summarize history to free context |
116
+ | `/queue <message>` | Submit a task after the current one finishes |
117
+
118
+ Send a message while the agent is working to redirect it, or use `/queue` to
119
+ wait. Sessions are saved under `~/.codex/sessions` by default.
120
+ Ctrl+C or Ctrl+D closes the session after issued operations finish.
121
+ Run `pycodex --help` for all options.
122
+
123
+ For a local vLLM server:
124
+
125
+ ```bash
126
+ pycodex --vllm-endpoint http://127.0.0.1:18000
127
+ ```
128
+
129
+ ## Use the browser workspace
130
+
131
+ After installing `pycodex-ws`, create `workspaces.json`:
132
+
133
+ ```json
134
+ {
135
+ "workspaces": [
136
+ {"id": "demo", "work_dir": ".", "state_path": "demo", "enable_board": true}
137
+ ]
138
+ }
139
+ ```
140
+
141
+ Start the server and keep the terminal open:
142
+
143
+ ```bash
144
+ pycodex-ws --listen 127.0.0.1:6007 --workspace-config workspaces.json
145
+ ```
146
+
147
+ Open `http://127.0.0.1:6007`. The workspace uses the same model configuration as
148
+ the CLI and provides conversations, a live HTML Canvas, and file/diff viewers.
149
+ Click file links to inspect code, then select text and use **Insert into chat**
150
+ to include it in your next message.
151
+ Each input displays its author and creation time, including separate messages
152
+ in a steer batch. Recorded messages keep that metadata when the session resumes.
153
+ Restoring a tab reads the rollout tail needed for its latest 80 display rows;
154
+ Agent resume still restores the complete active context after the last checkpoint.
155
+
156
+ The settings menu provides interface customization, password-protected
157
+ workspace sharing, and [One-line Agent](packages/pycodex-ws/README.md#one-line-agent):
158
+ an Agent that runs directly in most shells without installation, for bootstrapping
159
+ an Agent environment or simple debugging. See the [workspace guide](packages/pycodex-ws/README.md) for
160
+ session controls, storage and Feishu setup. A separate
161
+ [VS Code extension](packages/pycodex-ws/extensions/vscode/README.md) connects to
162
+ the same backend, including over Remote SSH.
163
+
164
+ ## Use the Python API
165
+
166
+ Save this as `example.py` and run `python3 example.py`. It uses the model
167
+ configuration above and the standard tools:
168
+
169
+ ```python
170
+ from contextlib import closing
171
+
172
+ from pycodex import AgentsManager, CodexConfig
173
+ from pycodex.bootstrap import build_model
174
+ from pycodex.utils.async_bridge import run_async
175
+
176
+
177
+ async def main():
178
+ config = CodexConfig.from_env()
179
+ with closing(build_model(config.provider)) as model:
180
+ runtime = AgentsManager(
181
+ model.client, config.context,
182
+ ).create_root_runtime()
183
+ try:
184
+ await runtime.start()
185
+ receipt = await runtime.submit_input("Summarize this repository.")
186
+ print((await receipt.future).output_text)
187
+ finally:
188
+ await runtime.close()
189
+
190
+
191
+ run_async(main())
192
+ ```
193
+
194
+ `AgentsManager` creates the runtime; `submit_input` submits work.
195
+ Await `receipt.future` for the result. The example closes the runtime and any
196
+ local compatibility server when finished. See [runtime contracts](docs/RUNTIME.md#ownership) for
197
+ custom models, tools and integrations.
198
+
199
+ ## More features
200
+
201
+ - [Portable configuration](docs/PORTABLE.md): transfer encrypted configuration, instructions and skills to another machine.
202
+ - [Frontend customization](packages/pycodex-ws/README.md#customize-the-interface): change the workspace through an Agent conversation or your own CSS/JavaScript.
203
+ - [Responses compatibility server](docs/responses_server/README.md): expose a supported backend through the Responses API.
204
+ - [Retries and fallback models](docs/RUNTIME.md#responses-reliability): configure recovery from model failures.
205
+
206
+ ## Development
207
+
208
+ From the repository root:
209
+
210
+ ```bash
211
+ env -u VIRTUAL_ENV uv sync --dev
212
+ env -u VIRTUAL_ENV uv run --dev pytest
213
+ ```
214
+
215
+ See the [development guide](AGENTS.md), [test guide](tests/TESTS.md),
216
+ [runtime architecture](docs/RUNTIME.md) and [workspace API](docs/WORKSPACE_API.md).
@@ -1,22 +1,22 @@
1
- pycodex/__init__.py,sha256=2DyU0vUq3EAS1Pya-farjLv4Z86k8JxVJqRnkeSXNQM,2918
1
+ pycodex/__init__.py,sha256=2rP9Qd5ClJlSI3bPNB0Jmn9lJUpeeo7gcbRPUvH81eI,2904
2
2
  pycodex/__main__.py,sha256=MHKZ_ae3fSLGTLUUMOx15fWdeOnJSHhq-zslRP5F5Lc,79
3
- pycodex/agent.py,sha256=yZ75cpCBM2acDBayKo9ekqHZRvODXsKtJFjyhm78v9M,22704
4
- pycodex/bootstrap.py,sha256=OhSzxwyi54bXwuO2tM9Q0AJGem46nQ24l08XEpH77V4,5070
5
- pycodex/cli.py,sha256=yEwPZLehVrWd-vs-cWyb_8PCqt9INb5O08YlILYn5pQ,13077
3
+ pycodex/agent.py,sha256=DfT4zYsCWiTsfQaBdVvFi5KQ5ke2nJ7DXdUUW4B8YFo,23514
4
+ pycodex/bootstrap.py,sha256=MR0msG5SEAAbdT8i_wCn1ueLdNx9sETsqIVWQPhPxus,4990
5
+ pycodex/cli.py,sha256=HkX_fFNUyPnNo25FeSa9ZMaQG79rqk3b0oV4ZH0h68c,12576
6
6
  pycodex/config.py,sha256=mGM7oLaciBwGXHMQjKVifWFTd7gZTfzqlQeJSFzcQic,1218
7
- pycodex/context.py,sha256=K8Q-PRNj9GQ79KdQXb_U1YhmgvnDEqsGhZ12_kbISX8,41076
8
- pycodex/events.py,sha256=qJnQItZOq4xs9JAbaEzDng1WdiqlH7i3D9fSIy36mHg,22749
9
- pycodex/model.py,sha256=13EP4v2Hlry5_cQ8hxYDj2fgSLpPWBxiA5yt1UB_WoI,58201
7
+ pycodex/context.py,sha256=i2Gpm2rXqd0PMZHYzZYefwdSPOP0eA62fxS3WeJNFw0,41483
8
+ pycodex/events.py,sha256=8gPVe_wb5r5s2hVQhywFMnz1YVvBmDLhyq43e9Y71wk,23090
9
+ pycodex/model.py,sha256=omwYru3BZ2ejZTCvUTFsIltjtH1LQWG3zWrzZ3hyNhI,58672
10
10
  pycodex/multi_agents.py,sha256=3KN_Ai3UremtsQppvxd0pE7pFam_v0zBastCNi-NNx8,16150
11
- pycodex/protocol.py,sha256=Jl0-Zah0mzb04HlBF3SLk5XwtALec7M9IPn_0BZnTNQ,14568
12
- pycodex/runtime.py,sha256=Szeufq_cAPSw_r7HCmpin1nm_Ugsj3FCcn-pgCCkrrI,37525
11
+ pycodex/protocol.py,sha256=qYUS9371F-DadlsYgctCpQbm3JCqyfpcWcxkANRAZWQ,15586
12
+ pycodex/runtime.py,sha256=92hVNdBzugUYQb01-bbkAOYpNpjIB1IWVEU6_U6SERA,37120
13
13
  pycodex/portable/__init__.py,sha256=NgACNTFK5hbRK6fqbL89qjPuh44N950pr4eoDWLfKD4,1110
14
14
  pycodex/portable/client.py,sha256=ZvXjKCB557ZZ-ELmec9DIxymWbG8QBZsaU6e0axu0T0,15508
15
15
  pycodex/portable/protocol.py,sha256=jtyPHI3aVY4UldlSIzeZRQX3MCFzPYfG-0iDC6JSWYo,931
16
16
  pycodex/portable/server.py,sha256=UCQAqcO0OTNkEv4MQgR-fIt1y5bzdqMndFJtMm16Lqk,7503
17
17
  pycodex/prompts/default_base_instructions.md,sha256=D65mcj6bo4CDvVom-D9cbJRJVNquo0NghKt164_fRsg,20923
18
18
  pycodex/prompts/developer_messages.json,sha256=E-CAWMOL2KoImJ1U_1aA-OYbuVtJF0-GtZkn983B-TI,4007
19
- pycodex/prompts/models.json,sha256=fq_8UCJ8EJ_0ajUWrnYwwU4I1a9d9UWjJbdLdGaynGk,611262
19
+ pycodex/prompts/models.json,sha256=cMpnFFT56zmndGnESKSIVzUyKZOCuxjVFAouZiDx_Qk,619361
20
20
  pycodex/prompts/goals/budget_limit.md,sha256=RbvI03fMD3tTy-ytnzylqAsIr9b2O_Cb81CQejR1J-k,775
21
21
  pycodex/prompts/goals/continuation.md,sha256=K7OtQKQNoCKcgne-e-SQBGJjEpnCVcVCtML7T-82bWI,6153
22
22
  pycodex/prompts/permissions/approval_policy/never.md,sha256=QceTG6wjkaJARjYr0HYV1aPnPcpGcrkRUW-smWRr6MQ,120
@@ -27,16 +27,16 @@ pycodex/prompts/permissions/approval_policy/unless_trusted.md,sha256=XHpi1Lfx1iI
27
27
  pycodex/prompts/permissions/sandbox_mode/danger_full_access.md,sha256=nZ7YHacBd3cAHKRZc9XClOOOnXJPXPh0WFBueh5C2D0,197
28
28
  pycodex/prompts/permissions/sandbox_mode/read_only.md,sha256=2rAPEXsBYCcuttI5j3euS-3uv_v97catIsnhxlSQSIM,173
29
29
  pycodex/prompts/permissions/sandbox_mode/workspace_write.md,sha256=lVN-LwrBbHqlv5yVjcd_mU8tzZW8jfKpTatJKIZu9HI,277
30
- pycodex/tools/__init__.py,sha256=fMNf_nlYvgCuP0EkkYPb0Jh82GLkuKFqVYnpumDtbvs,5231
30
+ pycodex/tools/__init__.py,sha256=yE_9gmbNrbUKXMfZO79Y8chfHMmOe9NBozy4i0vn0bY,5175
31
31
  pycodex/tools/agent_tool_schemas.py,sha256=juw4b2pp2tDhDPVTVY4rytm8IyVr2h686Qfk_5e9S0E,780
32
32
  pycodex/tools/apply_patch_tool.py,sha256=LcyJuGtndmLLbFL1sIUQ2Y6KLCef95KBfi0adGA1bN8,13183
33
33
  pycodex/tools/base_tool.py,sha256=dD_makVyjbnJN_cAhRAj_sJJHYh8VUDoXFiRoWDh6Ko,8644
34
34
  pycodex/tools/clock_manager.py,sha256=Xn1i4aasN_ZZdL9WsA_cS-RAVLV-SQXmOecMc1nGCa4,5884
35
- pycodex/tools/clock_tool.py,sha256=G4SSchZq8qAz-Rjc2qAbN2bFTIkD7pUsNRFL4K3fvj8,2100
35
+ pycodex/tools/clock_tool.py,sha256=14Y1uLagSuEO8eaACQcQQbPZP1R6cSAYaReZIyZen4c,3790
36
36
  pycodex/tools/code_mode_manager.py,sha256=_bZ7RlKzAEqb2m6PBfR7Or1GJYajeuSz1xCmuJcGsV8,15975
37
37
  pycodex/tools/exec_command_tool.py,sha256=Mf2FRsx6o5pWq68PCXNCSOce4wzwqyX6VrXNOvym_So,4076
38
- pycodex/tools/exec_runtime.py,sha256=AEmZw0eH4omw2ssOJXGcHR4YpVAmOyeHlU60p73cDao,14227
39
- pycodex/tools/exec_tool.py,sha256=0X3obuj6XPa0qamQK_WAmwhALZmd8zbFVjCBLGfKbYs,5477
38
+ pycodex/tools/exec_runtime.py,sha256=vR4HfTxknxbKDhO7QFlBDgltKegFy5KJE1eAODWVYqY,12061
39
+ pycodex/tools/exec_tool.py,sha256=7HQ8sazJBr4WQklJsCJS30kfVaQOsg5gBgIutC6QyRY,5209
40
40
  pycodex/tools/followup_task_tool.py,sha256=D3nRu6csiriwe1WVig_HNLRzJQfDNMmk2R75vMfSI4Y,1609
41
41
  pycodex/tools/goal_manager.py,sha256=8zicCSjqJgYyONL6EaOIyaGjTA6EBECi1NYQgEwLFms,8480
42
42
  pycodex/tools/goal_tool.py,sha256=TShHf6dh6YCdMPoc6zuIgj0W2D_O95ewmh6OZKFXAX0,5225
@@ -47,7 +47,6 @@ pycodex/tools/list_dir_tool.py,sha256=_U6ouRcVbGHT5mChVyUsiMgDGrFK7EFMFaspPLAHtH
47
47
  pycodex/tools/python_tool_schema.py,sha256=yoJHP7GJGSu6oyT_0nxbGJWy_TaTobFwDoFQMl65464,5781
48
48
  pycodex/tools/read_file_tool.py,sha256=YK__uhIVldBjAQega5S_ZuZU5jgP_kLOwr-YhjAmRo4,9735
49
49
  pycodex/tools/request_permissions_tool.py,sha256=t-Y-iEhvUyE9IJAeiwnzfUdbQ73Gw7uxFcWLwS0no4o,4000
50
- pycodex/tools/request_user_input_tool.py,sha256=rVjJPVzrkBPmAQkfPWiCvAuIAp0Lt8WwuVgfbNbbeHY,2893
51
50
  pycodex/tools/runtime_services.py,sha256=oEqUyR7-oHQdTsEWXoiP7VKP_JDiG5dc8AjlSGQFjYI,7542
52
51
  pycodex/tools/send_message_tool.py,sha256=mH51ufxTCcsHuLFI1tDKyX14AHPMij2cMJLJdlFFjZQ,1414
53
52
  pycodex/tools/shell_command_tool.py,sha256=bJKlTdIs2i28vH5f4GZfpunezr6JNicRzsL_6Vc3HvU,3675
@@ -64,18 +63,19 @@ pycodex/utils/__init__.py,sha256=ih_KyZ2_bajR5YlZ1QMTWOHnuEBda-S3gQ7PwnBtLZQ,453
64
63
  pycodex/utils/async_bridge.py,sha256=BXsKTUTUvUtPJnItQlulFRdV7opdKKDlsKLdtVTYshs,1732
65
64
  pycodex/utils/codex_config.py,sha256=oCisEGUJcJxcZL1wIqXkon1xTShymOlz96E3VgDVTlY,3748
66
65
  pycodex/utils/compactor.py,sha256=IzRC6bY1ab6WP33jRMFMbmlJ3TMJcoTgDFFG-Y4C86E,6299
67
- pycodex/utils/compat.py,sha256=OaUWtldoMYYuRgVCbrsuN2J3jsVUa_Xt8Wg3mjHcG2o,3572
66
+ pycodex/utils/compat.py,sha256=16FyHHlDES57mOHCasN4FWveEkGYd2aZex9-Eojlkg8,5277
68
67
  pycodex/utils/crypto.py,sha256=HRCXF26Ft3S8CG2X0YpZwa8GMU9YJ0Loo8Q9PMPMcNw,1249
69
68
  pycodex/utils/debug.py,sha256=5XMpWpwFSm6woyx6RGXvN2qL0afRtTQbwlOAv-LotTw,913
70
69
  pycodex/utils/doctor.py,sha256=xhPflFEYFfmtQ4-LjnIyz-cNts0GjNtAK0inVTYfKiI,10764
71
- pycodex/utils/dotenv.py,sha256=h7ZgvqpEswetqjhtwfiaHyokAHwNKPakizTAHPHz5Ds,1865
72
- pycodex/utils/event_helpers.py,sha256=VH8MMmpAO98EFb-PeEKjqAw8LCiGGaWegENP9Jnc6kA,12021
70
+ pycodex/utils/dotenv.py,sha256=rLHBfz5zPZMbrJqyRyYPy3j4oiDwuzfrH4mDH3XRrow,1647
71
+ pycodex/utils/event_helpers.py,sha256=ULvTSktxMd--VEL2UJA6CbuWHLsrctAcAuEk91wGLL8,12021
73
72
  pycodex/utils/get_env.py,sha256=L4S8h84tkgxZKvrxY7ezTgePbXepG-yIigUTKeY6uuE,6094
74
- pycodex/utils/history.py,sha256=wCyf2Jf4flqzSEIKmebbdkwclfEMzl0Af7VZOgrpu24,1338
73
+ pycodex/utils/history.py,sha256=qgt5IxxkfCYjjpr08VJFhasICSSlqxQM7d-DjRJVjHA,3845
75
74
  pycodex/utils/image_utils.py,sha256=OUzUs0Cow4L8Z2np0EBeEUotAqqsCmRmhrV8AxZUXRw,2460
76
75
  pycodex/utils/model_metadata.py,sha256=uK3iI4yC7Ge7yN4I1_gQYalQ4MYKddz2qMwsmQb-P80,1337
77
76
  pycodex/utils/random_ids.py,sha256=jLTxZZ0MBbRdQOFDFWGVRjWzIo6FKSQ5ADXbQSLPp1s,379
78
- pycodex/utils/session_persist.py,sha256=mtYUZGkF0ag49aEmIPidwls-2zNafVf5SWMtGsa3DmU,27024
77
+ pycodex/utils/session_persist.py,sha256=7JXXInvKaeO-9zz-n4LrnqrNn4BvFPEoVgZ88c9yZrM,31333
78
+ pycodex/utils/skill_catalog.py,sha256=3W-r6pn_fzEGyd89aKD2shGNhrUK2hLgrlwOlqYOpgU,618
79
79
  pycodex/utils/truncation.py,sha256=5D6vAorT8EgXgjd7ASwtraAyIZdlCR-w5jKZqJxDzho,5446
80
80
  pycodex/utils/_aes_gcm/LICENSE,sha256=KvdHagY3sYIK34GldJaRi34sNnGwMVJIIoDhbC9MRu8,2805
81
81
  pycodex/utils/_aes_gcm/README.md,sha256=D9XGeewCgU2PVqJCO6WusUs0Mw2FbMnABCqaVktqCnE,3045
@@ -85,22 +85,23 @@ pycodex/utils/_aes_gcm/gcm.py,sha256=Z8fYHpnLpqJyTPmjDOZtryqe0xmT_93vscNuJe5ZY-w
85
85
  pycodex/utils/_aes_gcm/source-sha256.json,sha256=g9uPWXuA0D9Wq9EGnduyiVanTgi8QWRFW-9T69FG-fc,215
86
86
  responses_server/__init__.py,sha256=SOMO5Q-Z0dpaRih8yWuKUTclPl28tpy_XIPTOO_BPq0,447
87
87
  responses_server/__main__.py,sha256=876xZTqhPeDBD2GKKr8pKX33Af8PhFTosAI8bYQsFgQ,61
88
- responses_server/app.py,sha256=SvH8xL3OlWXqC_yW04bMvlRvU9v6PjmI2nf70qF7ZiQ,8413
89
- responses_server/config.py,sha256=ktUQlDT33vzfCuPvaMPNa7JRArEL5B-Yi1ngJPzR91Q,2374
90
- responses_server/messages_api.py,sha256=ialAYTMmN0y-uxQB3Y51ukq-kvkSVO84WVLXaqLsKw0,18775
88
+ responses_server/app.py,sha256=658hV1uR51RZzTe8B5xPvaasWZdjJo5rxg2GJFnxOLk,8495
89
+ responses_server/config.py,sha256=HxoZYNkpDwZgbIxgVgoR_8BYTRV8V2e1dCddUTo1FyQ,2663
90
+ responses_server/gemini_api.py,sha256=dnKKzB7A60QDDHU-uDYShCyNo02Hsv-HJwZnW4t7UJ4,15798
91
+ responses_server/messages_api.py,sha256=3Mr0v0ieN18PpEgmR48DnP6PrCDk980cAckZG-2HKrM,19274
91
92
  responses_server/payload_processors.py,sha256=jIiGCHGFootnkwPpZiM1-Zv1WKziHlklSWGo050hBgU,3567
92
- responses_server/request_translation.py,sha256=0i8rserasFDcBbvrOL0zJd8A-9ULjFl7-LC40U8v8Oc,18479
93
+ responses_server/request_translation.py,sha256=9TYgGv4GV2M7m6TGXV-pqIpIFTn8v_ZBKULUq3nvaB8,18754
93
94
  responses_server/server.py,sha256=hFSRU3GjYa9cI1YSDxKvg2gLjp3OJ_Mh_JFyau3yzl4,2535
94
95
  responses_server/session_store.py,sha256=nwGxQL6nUVKnDVeDHz8IzqNQ7dWk8Ybf0URekOHdxTo,1133
95
96
  responses_server/stream_events.py,sha256=nWi5VcssytFD3SDHW5hQik5LR-US-Clk-5EEWAi3t-k,4984
96
- responses_server/stream_router.py,sha256=jFm_YFb0f0FwYude42Hsm1juSF29n_vy1M7oUZ7tyR8,14216
97
+ responses_server/stream_router.py,sha256=iDcgNUtcd1inotuWMLfaK7gZfEyCnc403_SKvrcpxaw,15037
97
98
  responses_server/trajectory_dump.py,sha256=5_Wy6tslszrqx3j1JeP_boyTbzIicKy8No84PzMnmHk,5111
98
- responses_server/transport.py,sha256=u-RiWvJeLMpifveQuODx7fcbjWKqlgRjXjq6GP6ly2Y,13557
99
+ responses_server/transport.py,sha256=363GeSws0VS-yL7pPjtMvjEp7rZ60FdMJ5oD0vPPIWU,16519
99
100
  responses_server/tools/__init__.py,sha256=ivsBSEy0SBUhY-Uea5v1XMLXShkwHdCVl0id-1FwdZg,150
100
101
  responses_server/tools/custom_adapter.py,sha256=leYNJKp4Ute0JWNfGpe-ntSyFqRgYCdWF4dMYQFINlk,8615
101
- responses_server/tools/web_search.py,sha256=pnKH9JyTScRehWpZS3HpXRvjWsQvC0QZqxjEOCT4ndg,8936
102
- python_codex-0.6.0.dist-info/METADATA,sha256=tZYTIoKC6b9lSS0z2EGgozUUAVv-xOTHiX78PZKrrP4,16661
103
- python_codex-0.6.0.dist-info/WHEEL,sha256=KGYbc1zXlYddvwxnNty23BeaKzh7YuoSIvIMO4jEhvw,87
104
- python_codex-0.6.0.dist-info/entry_points.txt,sha256=sNUVakoVuTrzJH505ZgRTQxmtRRPUHV_EH0i6EbYTyM,45
105
- python_codex-0.6.0.dist-info/licenses/LICENSE,sha256=0X8ifk312hYAORM4hlzg8wVSEXYKNmiPgWlB1YIy2Nw,10926
106
- python_codex-0.6.0.dist-info/RECORD,,
102
+ responses_server/tools/web_search.py,sha256=JyF6NHCS0SqoBrO18jX8cgBsiV4OYQBPz0Ky4u3juSQ,9059
103
+ python_codex-0.6.2.dist-info/METADATA,sha256=D6WM3UCjYbbicU8pXwNrZaMZH-Z1ZrHPXYbqlF7-hvk,7995
104
+ python_codex-0.6.2.dist-info/WHEEL,sha256=KGYbc1zXlYddvwxnNty23BeaKzh7YuoSIvIMO4jEhvw,87
105
+ python_codex-0.6.2.dist-info/entry_points.txt,sha256=sNUVakoVuTrzJH505ZgRTQxmtRRPUHV_EH0i6EbYTyM,45
106
+ python_codex-0.6.2.dist-info/licenses/LICENSE,sha256=0X8ifk312hYAORM4hlzg8wVSEXYKNmiPgWlB1YIy2Nw,10926
107
+ python_codex-0.6.2.dist-info/RECORD,,
responses_server/app.py CHANGED
@@ -33,8 +33,10 @@ async def _http_exception_response(request: "Request", exc: "HTTPException"):
33
33
 
34
34
 
35
35
  def _format_sse_event(
36
- event_name: "str", payload: "typing.Dict[str, object]"
36
+ event_name: "typing.Union[str, None]", payload: "typing.Dict[str, object]"
37
37
  ) -> "bytes":
38
+ if event_name is None:
39
+ return b": keep-alive\n\n"
38
40
  data = json.dumps(payload, ensure_ascii=False)
39
41
  return f"event: {event_name}\ndata: {data}\n\n".encode("utf-8")
40
42
 
@@ -32,6 +32,11 @@ class CompatServerConfig:
32
32
  base = self.outcomming_base_url.rstrip("/")
33
33
  return f"{base}/messages"
34
34
 
35
+ def outcomming_gemini_url(self, model: "str") -> "str":
36
+ base = self.outcomming_base_url.rstrip("/")
37
+ model_path = urllib.parse.quote(model, safe="")
38
+ return f"{base}/models/{model_path}:streamGenerateContent?alt=sse"
39
+
35
40
  def outcomming_models_url(self) -> "str":
36
41
  base = self.outcomming_base_url.rstrip("/")
37
42
  return f"{base}/models"
@@ -53,7 +58,7 @@ class CompatServerConfig:
53
58
  raise ValueError(f"invalid outcomming base url: {outcomming_base_url}")
54
59
  normalized_path = parsed.path.rstrip("/")
55
60
  if normalized_path in {"", "/"}:
56
- parsed = parsed._replace(path="/v1")
61
+ parsed = parsed._replace(path="/v1beta" if outcomming_api == "gemini" else "/v1")
57
62
  outcomming_base_url = urllib.parse.urlunparse(parsed)
58
63
  else:
59
64
  outcomming_base_url = urllib.parse.urlunparse(