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.
- pycodex/__init__.py +4 -4
- pycodex/agent.py +28 -9
- pycodex/bootstrap.py +10 -12
- pycodex/cli.py +0 -14
- pycodex/context.py +43 -32
- pycodex/events.py +20 -11
- pycodex/model.py +16 -7
- pycodex/prompts/models.json +14 -0
- pycodex/protocol.py +18 -0
- pycodex/runtime.py +49 -54
- pycodex/tools/__init__.py +9 -10
- pycodex/tools/clock_tool.py +57 -7
- pycodex/tools/exec_runtime.py +29 -78
- pycodex/tools/exec_tool.py +2 -6
- pycodex/utils/compat.py +41 -0
- pycodex/utils/dotenv.py +0 -7
- pycodex/utils/event_helpers.py +5 -9
- pycodex/utils/history.py +79 -20
- pycodex/utils/session_persist.py +133 -36
- pycodex/utils/skill_catalog.py +18 -0
- python_codex-0.6.2.dist-info/METADATA +216 -0
- {python_codex-0.6.0.dist-info → python_codex-0.6.2.dist-info}/RECORD +33 -32
- responses_server/app.py +3 -1
- responses_server/config.py +6 -1
- responses_server/gemini_api.py +336 -0
- responses_server/messages_api.py +9 -1
- responses_server/request_translation.py +6 -0
- responses_server/stream_router.py +15 -0
- responses_server/tools/web_search.py +3 -0
- responses_server/transport.py +75 -19
- pycodex/tools/request_user_input_tool.py +0 -82
- python_codex-0.6.0.dist-info/METADATA +0 -352
- {python_codex-0.6.0.dist-info → python_codex-0.6.2.dist-info}/WHEEL +0 -0
- {python_codex-0.6.0.dist-info → python_codex-0.6.2.dist-info}/entry_points.txt +0 -0
- {python_codex-0.6.0.dist-info → python_codex-0.6.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -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=
|
|
1
|
+
pycodex/__init__.py,sha256=2rP9Qd5ClJlSI3bPNB0Jmn9lJUpeeo7gcbRPUvH81eI,2904
|
|
2
2
|
pycodex/__main__.py,sha256=MHKZ_ae3fSLGTLUUMOx15fWdeOnJSHhq-zslRP5F5Lc,79
|
|
3
|
-
pycodex/agent.py,sha256=
|
|
4
|
-
pycodex/bootstrap.py,sha256=
|
|
5
|
-
pycodex/cli.py,sha256=
|
|
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=
|
|
8
|
-
pycodex/events.py,sha256=
|
|
9
|
-
pycodex/model.py,sha256=
|
|
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=
|
|
12
|
-
pycodex/runtime.py,sha256=
|
|
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=
|
|
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=
|
|
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=
|
|
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=
|
|
39
|
-
pycodex/tools/exec_tool.py,sha256=
|
|
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=
|
|
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=
|
|
72
|
-
pycodex/utils/event_helpers.py,sha256=
|
|
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=
|
|
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=
|
|
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=
|
|
89
|
-
responses_server/config.py,sha256=
|
|
90
|
-
responses_server/
|
|
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=
|
|
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=
|
|
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=
|
|
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=
|
|
102
|
-
python_codex-0.6.
|
|
103
|
-
python_codex-0.6.
|
|
104
|
-
python_codex-0.6.
|
|
105
|
-
python_codex-0.6.
|
|
106
|
-
python_codex-0.6.
|
|
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
|
|
responses_server/config.py
CHANGED
|
@@ -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(
|