dspy-codex-auth 0.2.0__tar.gz → 0.3.0__tar.gz
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.
- {dspy_codex_auth-0.2.0 → dspy_codex_auth-0.3.0}/PKG-INFO +128 -30
- {dspy_codex_auth-0.2.0 → dspy_codex_auth-0.3.0}/README.md +126 -27
- {dspy_codex_auth-0.2.0 → dspy_codex_auth-0.3.0}/pyproject.toml +3 -3
- dspy_codex_auth-0.3.0/src/dspy_codex_auth/connection.py +169 -0
- dspy_codex_auth-0.3.0/src/dspy_codex_auth/engines.py +237 -0
- dspy_codex_auth-0.3.0/src/dspy_codex_auth/lm.py +386 -0
- dspy_codex_auth-0.2.0/src/dspy_codex_auth/lm.py +0 -822
- {dspy_codex_auth-0.2.0 → dspy_codex_auth-0.3.0}/src/dspy_codex_auth/LICENSE +0 -0
- {dspy_codex_auth-0.2.0 → dspy_codex_auth-0.3.0}/src/dspy_codex_auth/THIRD_PARTY_NOTICES.md +0 -0
- {dspy_codex_auth-0.2.0 → dspy_codex_auth-0.3.0}/src/dspy_codex_auth/__init__.py +5 -5
- {dspy_codex_auth-0.2.0 → dspy_codex_auth-0.3.0}/src/dspy_codex_auth/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dspy-codex-auth
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: DSPy integration for ChatGPT Codex subscription-backed language models
|
|
5
5
|
Keywords: codex,dspy,language-models,openai
|
|
6
6
|
Author: hrbatra
|
|
@@ -13,8 +13,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
14
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
15
15
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
-
Requires-Dist: dspy>=3.
|
|
17
|
-
Requires-Dist: litellm>=1.82.6
|
|
16
|
+
Requires-Dist: dspy[litellm]>=3.5.0
|
|
18
17
|
Requires-Dist: openai-codex-auth>=0.2.0
|
|
19
18
|
Requires-Python: >=3.12
|
|
20
19
|
Project-URL: Homepage, https://github.com/hrbatra/dspy-codex-auth
|
|
@@ -30,8 +29,9 @@ language model.
|
|
|
30
29
|
- It uses [`openai-codex-auth`](https://github.com/hrbatra/openai-codex-auth)
|
|
31
30
|
for authentication, HTTP/WebSocket requests, and streamed-response handling.
|
|
32
31
|
- It installs a DSPy `LM` wrapper for `codex/...` model strings.
|
|
33
|
-
-
|
|
34
|
-
|
|
32
|
+
- Its sync and async engines convert DSPy's typed requests into native Codex
|
|
33
|
+
requests and return `dspy.lm15.Response` objects. DSPy owns caching, retries,
|
|
34
|
+
history, callbacks, and usage accounting.
|
|
35
35
|
|
|
36
36
|
## Install
|
|
37
37
|
|
|
@@ -39,6 +39,15 @@ language model.
|
|
|
39
39
|
uv add dspy-codex-auth
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
+
Version 0.3 requires Python 3.12+ and DSPy 3.5+. To upgrade an existing project:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
uv add --upgrade dspy-codex-auth
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Restart the notebook kernel or Python process after upgrading so it loads the
|
|
49
|
+
new adapter and DSPy classes.
|
|
50
|
+
|
|
42
51
|
The two packages have separate roles: `openai-codex-auth` provides the reusable
|
|
43
52
|
Codex client; `dspy-codex-auth` provides its DSPy adapter. Installing the adapter
|
|
44
53
|
brings in both packages. For ordinary Python without DSPy, install
|
|
@@ -77,12 +86,54 @@ lm = dspy.LM("codex/gpt-5.6-luna", cache=False)
|
|
|
77
86
|
dspy.configure(lm=lm, adapter=dspy.JSONAdapter())
|
|
78
87
|
```
|
|
79
88
|
|
|
80
|
-
Use
|
|
89
|
+
Use a model available to your ChatGPT account with `codex/<model>` for the
|
|
90
|
+
Codex subscription route. The examples use `gpt-5.6-sol`; older model IDs may
|
|
91
|
+
be rejected by the backend. This is not the
|
|
81
92
|
OpenAI API key route and does not require `OPENAI_API_KEY`.
|
|
82
93
|
|
|
83
94
|
`cache=False` is recommended for Codex while iterating because stale DSPy cache
|
|
84
95
|
entries can preserve old empty-output responses across package upgrades.
|
|
85
96
|
|
|
97
|
+
## Migrating to 0.3
|
|
98
|
+
|
|
99
|
+
Ordinary `lm("hello")`, `await lm.acall("hello")`, and DSPy modules such as
|
|
100
|
+
`dspy.Predict` keep their usual interface. String calls return DSPy's list of
|
|
101
|
+
outputs. The old `lm(messages=[...])`, `lm.forward(...)`, and
|
|
102
|
+
`lm.aforward(...)` interfaces are removed.
|
|
103
|
+
|
|
104
|
+
For a conversation or direct structured call, use types from **`dspy.lm15`**:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from dspy.lm15 import Config, Message, Reasoning, Request, Response
|
|
108
|
+
|
|
109
|
+
request = Request(
|
|
110
|
+
model=lm.model,
|
|
111
|
+
system="Be concise.",
|
|
112
|
+
messages=(Message.user("What is DSPy?"),),
|
|
113
|
+
config=Config(reasoning=Reasoning(effort="low", summary="detailed")),
|
|
114
|
+
)
|
|
115
|
+
response: Response = lm(request)
|
|
116
|
+
print(response.text)
|
|
117
|
+
|
|
118
|
+
# In a notebook or async function:
|
|
119
|
+
response = await lm.acall(request)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`Request.model` must equal `lm.model`. Put generation settings in
|
|
123
|
+
`Request.config`: a typed request does **not** inherit the LM's generation
|
|
124
|
+
defaults or accept generation keyword arguments alongside it. String calls
|
|
125
|
+
continue to use constructor defaults and per-call generation overrides.
|
|
126
|
+
Connection and transport overrides, such as `timeout` and `codex_transport`,
|
|
127
|
+
can still be passed alongside either call form.
|
|
128
|
+
|
|
129
|
+
This adapter collects the complete provider response before returning it. It
|
|
130
|
+
does not expose token streaming through DSPy's streaming engine interface.
|
|
131
|
+
Stop sequences are unsupported: `stop=` on a string call or `Config.stop` on
|
|
132
|
+
a typed request raises `dspy.LMUnsupportedFeatureError` before provider I/O.
|
|
133
|
+
The completion-only engine cannot stop generation at a matching sequence.
|
|
134
|
+
See DSPy's [LM migration guide](https://dspy.ai/community/normalized-lm-api-migration/)
|
|
135
|
+
for the underlying API changes.
|
|
136
|
+
|
|
86
137
|
## Codex Transport Selection
|
|
87
138
|
|
|
88
139
|
Codex LMs accept `codex_transport` at construction time. Its accepted values
|
|
@@ -122,11 +173,20 @@ timeout defaults to 300 seconds. Custom `api_base` values must use HTTP or
|
|
|
122
173
|
HTTPS; the WebSocket transport converts them to WS or WSS and appends the
|
|
123
174
|
`/responses` path. TLS uses Requests' CA bundle.
|
|
124
175
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
176
|
+
DSPy owns the single retry loop. `num_retries=k` permits at most `k + 1` engine
|
|
177
|
+
attempts; retry delays are 1, 2, 4, ... seconds, capped at 60 seconds unless a
|
|
178
|
+
provider retry hint applies. The shared client receives `max_retries=0`.
|
|
179
|
+
Auto selection may additionally make an HTTP routing probe within an attempt.
|
|
180
|
+
HTTP supports phase-specific `httpx.Timeout` values. For WebSocket idle time,
|
|
181
|
+
the precedence is:
|
|
182
|
+
|
|
183
|
+
1. A numeric per-call `timeout`.
|
|
184
|
+
2. A per-call `codex_websocket_idle_timeout`.
|
|
185
|
+
3. A numeric constructor `timeout`.
|
|
186
|
+
4. The constructor `codex_websocket_idle_timeout` (300 seconds by default).
|
|
187
|
+
|
|
188
|
+
Passing `timeout=None` on a call clears the constructor timeout for that call.
|
|
189
|
+
Per-call overrides do not change subsequent calls' defaults.
|
|
130
190
|
|
|
131
191
|
Authentication remains in the WebSocket handshake: the bearer credential is
|
|
132
192
|
never placed in the `response.create` data frame. HTTP requests use originator
|
|
@@ -152,7 +212,7 @@ def configure_model(model: str, **kwargs):
|
|
|
152
212
|
return lm
|
|
153
213
|
|
|
154
214
|
|
|
155
|
-
codex_lm = configure_model("codex/gpt-5.
|
|
215
|
+
codex_lm = configure_model("codex/gpt-5.6-sol", cache=False)
|
|
156
216
|
api_lm = configure_model("openai/gpt-5.5", api_key="...", cache=False)
|
|
157
217
|
```
|
|
158
218
|
|
|
@@ -163,20 +223,52 @@ Pass `reasoning_effort` as usual. This package also supports
|
|
|
163
223
|
|
|
164
224
|
```python
|
|
165
225
|
lm = dspy.LM(
|
|
166
|
-
"codex/gpt-5.
|
|
226
|
+
"codex/gpt-5.6-sol",
|
|
167
227
|
cache=False,
|
|
168
228
|
reasoning_effort="medium",
|
|
169
229
|
reasoning_summary="detailed",
|
|
170
230
|
)
|
|
171
231
|
```
|
|
172
232
|
|
|
173
|
-
DSPy predictions expose declared output fields.
|
|
174
|
-
|
|
233
|
+
DSPy predictions expose declared output fields. A single-response history entry
|
|
234
|
+
contains the canonical response, including returned reasoning parts:
|
|
235
|
+
|
|
236
|
+
```python
|
|
237
|
+
from dspy.lm15 import ThinkingPart
|
|
238
|
+
|
|
239
|
+
response = lm.history[-1]["response"]
|
|
240
|
+
summaries = [part.text for part in response.message.parts_of(ThinkingPart)]
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Read `response.usage.input_tokens`, `response.usage.output_tokens`, and
|
|
244
|
+
`response.usage.total_tokens` for canonical usage; an unreported counter is
|
|
245
|
+
`None`, not zero. DSPy's history `usage` field uses its own prompt/completion
|
|
246
|
+
accounting format. Cache hits do not add billed usage.
|
|
247
|
+
|
|
248
|
+
Provider-specific details are available without inspecting private objects:
|
|
175
249
|
|
|
176
250
|
```python
|
|
177
|
-
|
|
251
|
+
raw_response = response.provider_data["codex_response"]
|
|
252
|
+
selected_transport = response.provider_data["codex_transport"]
|
|
178
253
|
```
|
|
179
254
|
|
|
255
|
+
The Responses codec reports dropped or clamped settings in
|
|
256
|
+
`response.adaptations`. Removed Codex output-token caps are recorded there too,
|
|
257
|
+
so callers can inspect which requested settings were changed.
|
|
258
|
+
|
|
259
|
+
## Copying and Saving
|
|
260
|
+
|
|
261
|
+
`lm.copy(...)`, `copy.deepcopy(lm)`, and DSPy's full-program save/load preserve
|
|
262
|
+
the Codex integration. Copies and saved LM state retain the resolved Codex
|
|
263
|
+
model and route, so changing a custom alias registration later does not
|
|
264
|
+
silently redirect them.
|
|
265
|
+
|
|
266
|
+
`lm.dump_state()` produces reconstructible JSON state with the auth-file path
|
|
267
|
+
and transport settings, omitting credentials and custom headers. Reapply any
|
|
268
|
+
explicit key or custom headers after loading that state. This omission applies
|
|
269
|
+
to the JSON state format; DSPy's full-program pickle includes runtime objects
|
|
270
|
+
and is not the sanitized JSON form.
|
|
271
|
+
|
|
180
272
|
## Fast Mode / Service Tier
|
|
181
273
|
|
|
182
274
|
Codex CLI config uses `service_tier = "fast"` for Fast mode. Internally, the
|
|
@@ -186,7 +278,7 @@ spelling directly:
|
|
|
186
278
|
|
|
187
279
|
```python
|
|
188
280
|
lm = dspy.LM(
|
|
189
|
-
"codex/gpt-5.
|
|
281
|
+
"codex/gpt-5.6-sol",
|
|
190
282
|
cache=False,
|
|
191
283
|
service_tier="fast",
|
|
192
284
|
reasoning_effort="low",
|
|
@@ -200,7 +292,7 @@ For raw Codex CLI calls, use `-c` config overrides:
|
|
|
200
292
|
|
|
201
293
|
```bash
|
|
202
294
|
codex exec \
|
|
203
|
-
-m gpt-5.
|
|
295
|
+
-m gpt-5.6-sol \
|
|
204
296
|
-c 'service_tier="fast"' \
|
|
205
297
|
-c 'model_reasoning_effort="low"' \
|
|
206
298
|
--json \
|
|
@@ -223,7 +315,7 @@ explicitly:
|
|
|
223
315
|
|
|
224
316
|
```python
|
|
225
317
|
lm = dspy_codex_auth.LM(
|
|
226
|
-
"openai/gpt-5.
|
|
318
|
+
"openai/gpt-5.6-sol",
|
|
227
319
|
auth_provider="codex",
|
|
228
320
|
cache=False,
|
|
229
321
|
reasoning_effort="medium",
|
|
@@ -241,9 +333,9 @@ preserving provider metadata, message text, function calls, and reasoning
|
|
|
241
333
|
summaries. This adapter converts that response into the objects DSPy expects.
|
|
242
334
|
Codex requests no longer pass through LiteLLM's Responses transport.
|
|
243
335
|
|
|
244
|
-
|
|
245
|
-
cannot become an empty
|
|
246
|
-
the native refusal item in `CodexResponse.output`.
|
|
336
|
+
Provider failures and refusals surface through DSPy's public `LMError` family.
|
|
337
|
+
A refusal cannot become an empty successful prediction. Direct `CodexClient`
|
|
338
|
+
callers still receive the native refusal item in `CodexResponse.output`.
|
|
247
339
|
|
|
248
340
|
The adapter and shared core together handle:
|
|
249
341
|
|
|
@@ -275,7 +367,7 @@ import dspy_codex_auth
|
|
|
275
367
|
|
|
276
368
|
dspy_codex_auth.install()
|
|
277
369
|
|
|
278
|
-
lm = dspy.LM("codex/gpt-5.
|
|
370
|
+
lm = dspy.LM("codex/gpt-5.6-sol", cache=False)
|
|
279
371
|
dspy.configure(lm=lm, adapter=dspy.JSONAdapter())
|
|
280
372
|
|
|
281
373
|
|
|
@@ -299,7 +391,7 @@ import dspy_codex_auth
|
|
|
299
391
|
dspy_codex_auth.install()
|
|
300
392
|
|
|
301
393
|
lm = dspy.LM(
|
|
302
|
-
"codex/gpt-5.
|
|
394
|
+
"codex/gpt-5.6-sol",
|
|
303
395
|
cache=False,
|
|
304
396
|
reasoning_effort="medium",
|
|
305
397
|
reasoning_summary="detailed",
|
|
@@ -325,7 +417,8 @@ pred = solver(
|
|
|
325
417
|
|
|
326
418
|
print(pred.answer)
|
|
327
419
|
print(pred.explanation)
|
|
328
|
-
|
|
420
|
+
response = lm.history[-1]["response"]
|
|
421
|
+
print(response.provider_data["codex_response"])
|
|
329
422
|
```
|
|
330
423
|
|
|
331
424
|
## Attribution
|
|
@@ -347,11 +440,13 @@ https://github.com/MaximeRivest/dspy-lm-auth/pull/2
|
|
|
347
440
|
|
|
348
441
|
```bash
|
|
349
442
|
uv sync --dev
|
|
350
|
-
|
|
351
|
-
uv run ruff check .
|
|
352
|
-
uv build --no-sources
|
|
443
|
+
scripts/check
|
|
353
444
|
```
|
|
354
445
|
|
|
446
|
+
`scripts/check` runs lint, offline tests, a distribution build, and sync/async
|
|
447
|
+
smoke tests against an isolated installation of the built wheel. Build and
|
|
448
|
+
cache artifacts for this check use a temporary directory.
|
|
449
|
+
|
|
355
450
|
The default test command skips the real-network live transport test. Run it
|
|
356
451
|
explicitly only with valid Codex subscription credentials:
|
|
357
452
|
|
|
@@ -368,9 +463,12 @@ Short local release flow:
|
|
|
368
463
|
|
|
369
464
|
```bash
|
|
370
465
|
uv version --bump patch
|
|
371
|
-
|
|
466
|
+
scripts/check
|
|
372
467
|
uv build --no-sources
|
|
373
468
|
uv run --with twine python -m twine upload dist/*
|
|
374
469
|
```
|
|
375
470
|
|
|
376
|
-
|
|
471
|
+
Use a minor bump for compatibility changes such as 0.3. PyPI releases are
|
|
472
|
+
immutable, so every update needs a new version number. Build release artifacts
|
|
473
|
+
in a clean `dist/` directory; see the full release instructions for GitHub,
|
|
474
|
+
tagging, and fresh-install verification.
|
|
@@ -6,8 +6,9 @@ language model.
|
|
|
6
6
|
- It uses [`openai-codex-auth`](https://github.com/hrbatra/openai-codex-auth)
|
|
7
7
|
for authentication, HTTP/WebSocket requests, and streamed-response handling.
|
|
8
8
|
- It installs a DSPy `LM` wrapper for `codex/...` model strings.
|
|
9
|
-
-
|
|
10
|
-
|
|
9
|
+
- Its sync and async engines convert DSPy's typed requests into native Codex
|
|
10
|
+
requests and return `dspy.lm15.Response` objects. DSPy owns caching, retries,
|
|
11
|
+
history, callbacks, and usage accounting.
|
|
11
12
|
|
|
12
13
|
## Install
|
|
13
14
|
|
|
@@ -15,6 +16,15 @@ language model.
|
|
|
15
16
|
uv add dspy-codex-auth
|
|
16
17
|
```
|
|
17
18
|
|
|
19
|
+
Version 0.3 requires Python 3.12+ and DSPy 3.5+. To upgrade an existing project:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
uv add --upgrade dspy-codex-auth
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Restart the notebook kernel or Python process after upgrading so it loads the
|
|
26
|
+
new adapter and DSPy classes.
|
|
27
|
+
|
|
18
28
|
The two packages have separate roles: `openai-codex-auth` provides the reusable
|
|
19
29
|
Codex client; `dspy-codex-auth` provides its DSPy adapter. Installing the adapter
|
|
20
30
|
brings in both packages. For ordinary Python without DSPy, install
|
|
@@ -53,12 +63,54 @@ lm = dspy.LM("codex/gpt-5.6-luna", cache=False)
|
|
|
53
63
|
dspy.configure(lm=lm, adapter=dspy.JSONAdapter())
|
|
54
64
|
```
|
|
55
65
|
|
|
56
|
-
Use
|
|
66
|
+
Use a model available to your ChatGPT account with `codex/<model>` for the
|
|
67
|
+
Codex subscription route. The examples use `gpt-5.6-sol`; older model IDs may
|
|
68
|
+
be rejected by the backend. This is not the
|
|
57
69
|
OpenAI API key route and does not require `OPENAI_API_KEY`.
|
|
58
70
|
|
|
59
71
|
`cache=False` is recommended for Codex while iterating because stale DSPy cache
|
|
60
72
|
entries can preserve old empty-output responses across package upgrades.
|
|
61
73
|
|
|
74
|
+
## Migrating to 0.3
|
|
75
|
+
|
|
76
|
+
Ordinary `lm("hello")`, `await lm.acall("hello")`, and DSPy modules such as
|
|
77
|
+
`dspy.Predict` keep their usual interface. String calls return DSPy's list of
|
|
78
|
+
outputs. The old `lm(messages=[...])`, `lm.forward(...)`, and
|
|
79
|
+
`lm.aforward(...)` interfaces are removed.
|
|
80
|
+
|
|
81
|
+
For a conversation or direct structured call, use types from **`dspy.lm15`**:
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from dspy.lm15 import Config, Message, Reasoning, Request, Response
|
|
85
|
+
|
|
86
|
+
request = Request(
|
|
87
|
+
model=lm.model,
|
|
88
|
+
system="Be concise.",
|
|
89
|
+
messages=(Message.user("What is DSPy?"),),
|
|
90
|
+
config=Config(reasoning=Reasoning(effort="low", summary="detailed")),
|
|
91
|
+
)
|
|
92
|
+
response: Response = lm(request)
|
|
93
|
+
print(response.text)
|
|
94
|
+
|
|
95
|
+
# In a notebook or async function:
|
|
96
|
+
response = await lm.acall(request)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`Request.model` must equal `lm.model`. Put generation settings in
|
|
100
|
+
`Request.config`: a typed request does **not** inherit the LM's generation
|
|
101
|
+
defaults or accept generation keyword arguments alongside it. String calls
|
|
102
|
+
continue to use constructor defaults and per-call generation overrides.
|
|
103
|
+
Connection and transport overrides, such as `timeout` and `codex_transport`,
|
|
104
|
+
can still be passed alongside either call form.
|
|
105
|
+
|
|
106
|
+
This adapter collects the complete provider response before returning it. It
|
|
107
|
+
does not expose token streaming through DSPy's streaming engine interface.
|
|
108
|
+
Stop sequences are unsupported: `stop=` on a string call or `Config.stop` on
|
|
109
|
+
a typed request raises `dspy.LMUnsupportedFeatureError` before provider I/O.
|
|
110
|
+
The completion-only engine cannot stop generation at a matching sequence.
|
|
111
|
+
See DSPy's [LM migration guide](https://dspy.ai/community/normalized-lm-api-migration/)
|
|
112
|
+
for the underlying API changes.
|
|
113
|
+
|
|
62
114
|
## Codex Transport Selection
|
|
63
115
|
|
|
64
116
|
Codex LMs accept `codex_transport` at construction time. Its accepted values
|
|
@@ -98,11 +150,20 @@ timeout defaults to 300 seconds. Custom `api_base` values must use HTTP or
|
|
|
98
150
|
HTTPS; the WebSocket transport converts them to WS or WSS and appends the
|
|
99
151
|
`/responses` path. TLS uses Requests' CA bundle.
|
|
100
152
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
153
|
+
DSPy owns the single retry loop. `num_retries=k` permits at most `k + 1` engine
|
|
154
|
+
attempts; retry delays are 1, 2, 4, ... seconds, capped at 60 seconds unless a
|
|
155
|
+
provider retry hint applies. The shared client receives `max_retries=0`.
|
|
156
|
+
Auto selection may additionally make an HTTP routing probe within an attempt.
|
|
157
|
+
HTTP supports phase-specific `httpx.Timeout` values. For WebSocket idle time,
|
|
158
|
+
the precedence is:
|
|
159
|
+
|
|
160
|
+
1. A numeric per-call `timeout`.
|
|
161
|
+
2. A per-call `codex_websocket_idle_timeout`.
|
|
162
|
+
3. A numeric constructor `timeout`.
|
|
163
|
+
4. The constructor `codex_websocket_idle_timeout` (300 seconds by default).
|
|
164
|
+
|
|
165
|
+
Passing `timeout=None` on a call clears the constructor timeout for that call.
|
|
166
|
+
Per-call overrides do not change subsequent calls' defaults.
|
|
106
167
|
|
|
107
168
|
Authentication remains in the WebSocket handshake: the bearer credential is
|
|
108
169
|
never placed in the `response.create` data frame. HTTP requests use originator
|
|
@@ -128,7 +189,7 @@ def configure_model(model: str, **kwargs):
|
|
|
128
189
|
return lm
|
|
129
190
|
|
|
130
191
|
|
|
131
|
-
codex_lm = configure_model("codex/gpt-5.
|
|
192
|
+
codex_lm = configure_model("codex/gpt-5.6-sol", cache=False)
|
|
132
193
|
api_lm = configure_model("openai/gpt-5.5", api_key="...", cache=False)
|
|
133
194
|
```
|
|
134
195
|
|
|
@@ -139,20 +200,52 @@ Pass `reasoning_effort` as usual. This package also supports
|
|
|
139
200
|
|
|
140
201
|
```python
|
|
141
202
|
lm = dspy.LM(
|
|
142
|
-
"codex/gpt-5.
|
|
203
|
+
"codex/gpt-5.6-sol",
|
|
143
204
|
cache=False,
|
|
144
205
|
reasoning_effort="medium",
|
|
145
206
|
reasoning_summary="detailed",
|
|
146
207
|
)
|
|
147
208
|
```
|
|
148
209
|
|
|
149
|
-
DSPy predictions expose declared output fields.
|
|
150
|
-
|
|
210
|
+
DSPy predictions expose declared output fields. A single-response history entry
|
|
211
|
+
contains the canonical response, including returned reasoning parts:
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
from dspy.lm15 import ThinkingPart
|
|
215
|
+
|
|
216
|
+
response = lm.history[-1]["response"]
|
|
217
|
+
summaries = [part.text for part in response.message.parts_of(ThinkingPart)]
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Read `response.usage.input_tokens`, `response.usage.output_tokens`, and
|
|
221
|
+
`response.usage.total_tokens` for canonical usage; an unreported counter is
|
|
222
|
+
`None`, not zero. DSPy's history `usage` field uses its own prompt/completion
|
|
223
|
+
accounting format. Cache hits do not add billed usage.
|
|
224
|
+
|
|
225
|
+
Provider-specific details are available without inspecting private objects:
|
|
151
226
|
|
|
152
227
|
```python
|
|
153
|
-
|
|
228
|
+
raw_response = response.provider_data["codex_response"]
|
|
229
|
+
selected_transport = response.provider_data["codex_transport"]
|
|
154
230
|
```
|
|
155
231
|
|
|
232
|
+
The Responses codec reports dropped or clamped settings in
|
|
233
|
+
`response.adaptations`. Removed Codex output-token caps are recorded there too,
|
|
234
|
+
so callers can inspect which requested settings were changed.
|
|
235
|
+
|
|
236
|
+
## Copying and Saving
|
|
237
|
+
|
|
238
|
+
`lm.copy(...)`, `copy.deepcopy(lm)`, and DSPy's full-program save/load preserve
|
|
239
|
+
the Codex integration. Copies and saved LM state retain the resolved Codex
|
|
240
|
+
model and route, so changing a custom alias registration later does not
|
|
241
|
+
silently redirect them.
|
|
242
|
+
|
|
243
|
+
`lm.dump_state()` produces reconstructible JSON state with the auth-file path
|
|
244
|
+
and transport settings, omitting credentials and custom headers. Reapply any
|
|
245
|
+
explicit key or custom headers after loading that state. This omission applies
|
|
246
|
+
to the JSON state format; DSPy's full-program pickle includes runtime objects
|
|
247
|
+
and is not the sanitized JSON form.
|
|
248
|
+
|
|
156
249
|
## Fast Mode / Service Tier
|
|
157
250
|
|
|
158
251
|
Codex CLI config uses `service_tier = "fast"` for Fast mode. Internally, the
|
|
@@ -162,7 +255,7 @@ spelling directly:
|
|
|
162
255
|
|
|
163
256
|
```python
|
|
164
257
|
lm = dspy.LM(
|
|
165
|
-
"codex/gpt-5.
|
|
258
|
+
"codex/gpt-5.6-sol",
|
|
166
259
|
cache=False,
|
|
167
260
|
service_tier="fast",
|
|
168
261
|
reasoning_effort="low",
|
|
@@ -176,7 +269,7 @@ For raw Codex CLI calls, use `-c` config overrides:
|
|
|
176
269
|
|
|
177
270
|
```bash
|
|
178
271
|
codex exec \
|
|
179
|
-
-m gpt-5.
|
|
272
|
+
-m gpt-5.6-sol \
|
|
180
273
|
-c 'service_tier="fast"' \
|
|
181
274
|
-c 'model_reasoning_effort="low"' \
|
|
182
275
|
--json \
|
|
@@ -199,7 +292,7 @@ explicitly:
|
|
|
199
292
|
|
|
200
293
|
```python
|
|
201
294
|
lm = dspy_codex_auth.LM(
|
|
202
|
-
"openai/gpt-5.
|
|
295
|
+
"openai/gpt-5.6-sol",
|
|
203
296
|
auth_provider="codex",
|
|
204
297
|
cache=False,
|
|
205
298
|
reasoning_effort="medium",
|
|
@@ -217,9 +310,9 @@ preserving provider metadata, message text, function calls, and reasoning
|
|
|
217
310
|
summaries. This adapter converts that response into the objects DSPy expects.
|
|
218
311
|
Codex requests no longer pass through LiteLLM's Responses transport.
|
|
219
312
|
|
|
220
|
-
|
|
221
|
-
cannot become an empty
|
|
222
|
-
the native refusal item in `CodexResponse.output`.
|
|
313
|
+
Provider failures and refusals surface through DSPy's public `LMError` family.
|
|
314
|
+
A refusal cannot become an empty successful prediction. Direct `CodexClient`
|
|
315
|
+
callers still receive the native refusal item in `CodexResponse.output`.
|
|
223
316
|
|
|
224
317
|
The adapter and shared core together handle:
|
|
225
318
|
|
|
@@ -251,7 +344,7 @@ import dspy_codex_auth
|
|
|
251
344
|
|
|
252
345
|
dspy_codex_auth.install()
|
|
253
346
|
|
|
254
|
-
lm = dspy.LM("codex/gpt-5.
|
|
347
|
+
lm = dspy.LM("codex/gpt-5.6-sol", cache=False)
|
|
255
348
|
dspy.configure(lm=lm, adapter=dspy.JSONAdapter())
|
|
256
349
|
|
|
257
350
|
|
|
@@ -275,7 +368,7 @@ import dspy_codex_auth
|
|
|
275
368
|
dspy_codex_auth.install()
|
|
276
369
|
|
|
277
370
|
lm = dspy.LM(
|
|
278
|
-
"codex/gpt-5.
|
|
371
|
+
"codex/gpt-5.6-sol",
|
|
279
372
|
cache=False,
|
|
280
373
|
reasoning_effort="medium",
|
|
281
374
|
reasoning_summary="detailed",
|
|
@@ -301,7 +394,8 @@ pred = solver(
|
|
|
301
394
|
|
|
302
395
|
print(pred.answer)
|
|
303
396
|
print(pred.explanation)
|
|
304
|
-
|
|
397
|
+
response = lm.history[-1]["response"]
|
|
398
|
+
print(response.provider_data["codex_response"])
|
|
305
399
|
```
|
|
306
400
|
|
|
307
401
|
## Attribution
|
|
@@ -323,11 +417,13 @@ https://github.com/MaximeRivest/dspy-lm-auth/pull/2
|
|
|
323
417
|
|
|
324
418
|
```bash
|
|
325
419
|
uv sync --dev
|
|
326
|
-
|
|
327
|
-
uv run ruff check .
|
|
328
|
-
uv build --no-sources
|
|
420
|
+
scripts/check
|
|
329
421
|
```
|
|
330
422
|
|
|
423
|
+
`scripts/check` runs lint, offline tests, a distribution build, and sync/async
|
|
424
|
+
smoke tests against an isolated installation of the built wheel. Build and
|
|
425
|
+
cache artifacts for this check use a temporary directory.
|
|
426
|
+
|
|
331
427
|
The default test command skips the real-network live transport test. Run it
|
|
332
428
|
explicitly only with valid Codex subscription credentials:
|
|
333
429
|
|
|
@@ -344,9 +440,12 @@ Short local release flow:
|
|
|
344
440
|
|
|
345
441
|
```bash
|
|
346
442
|
uv version --bump patch
|
|
347
|
-
|
|
443
|
+
scripts/check
|
|
348
444
|
uv build --no-sources
|
|
349
445
|
uv run --with twine python -m twine upload dist/*
|
|
350
446
|
```
|
|
351
447
|
|
|
352
|
-
|
|
448
|
+
Use a minor bump for compatibility changes such as 0.3. PyPI releases are
|
|
449
|
+
immutable, so every update needs a new version number. Build release artifacts
|
|
450
|
+
in a clean `dist/` directory; see the full release instructions for GitHub,
|
|
451
|
+
tagging, and fresh-install verification.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "dspy-codex-auth"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.3.0"
|
|
4
4
|
description = "DSPy integration for ChatGPT Codex subscription-backed language models"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -19,8 +19,7 @@ classifiers = [
|
|
|
19
19
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
20
20
|
]
|
|
21
21
|
dependencies = [
|
|
22
|
-
"dspy>=3.
|
|
23
|
-
"litellm>=1.82.6",
|
|
22
|
+
"dspy[litellm]>=3.5.0",
|
|
24
23
|
"openai-codex-auth>=0.2.0",
|
|
25
24
|
]
|
|
26
25
|
|
|
@@ -35,6 +34,7 @@ build-backend = "uv_build"
|
|
|
35
34
|
|
|
36
35
|
[dependency-groups]
|
|
37
36
|
dev = [
|
|
37
|
+
"coverage>=7.17.3",
|
|
38
38
|
"pytest>=9.0.3",
|
|
39
39
|
"ruff>=0.15.12",
|
|
40
40
|
]
|