Commit 1320300
refactor(ai): convert chat_sdk.ai module to package for chat/ai subpath (#116)
* refactor(ai): convert chat_sdk.ai module to package for chat/ai subpath (vercel/chat#492)
Mirror upstream PR vercel/chat#492 which split ai.ts into ai/messages.ts to
make room for ai/tools.ts. Convert the chat_sdk.ai module into a package:
- src/chat_sdk/ai/messages.py: to_ai_messages + supporting types, moved
verbatim from the former ai.py (docstring path updated only).
- src/chat_sdk/ai/__init__.py: re-export shim exposing every symbol the old
module exported, so from chat_sdk.ai import to_ai_messages keeps working.
- tests/test_ai.py renamed to tests/test_ai_messages.py (logic unchanged).
No public import path changed. PR 1 of 3 (module move only); the tool
factory (create_chat_tools) lands in PR 2.
Design issue #109, tracking #98.
https://claude.ai/code/session_01FyMxQn2BEAzmwKS1GZczKj
* fix(scripts): update AI test-fidelity mapping after module move (review)
* fix(ai): unbreak strict fidelity check + re-export TEXT_MIME_PREFIXES
Two CI / review follow-ups on PR #116:
1. Fidelity-mapping fix went too far in the previous commit. The script's
parity pin is `chat@4.26.0` (see `lint.yml:63`), where the upstream
AI test file is still the flat `packages/chat/src/ai.test.ts` — the
move to `ai/messages.test.ts` happened in 4.29.0. Pointing the mapping
at the 4.29-era path made `verify_test_fidelity.py --strict` fail with
"upstream checkout missing — mapped TS file not found". Revert just
the TS half of the mapping to `ai.test.ts`; keep the Python half at
`tests/test_ai_messages.py` (the file this PR actually renamed). When
the parity pin moves to 4.29.0 the TS path can advance too.
Locally verified against a fresh `chat@4.26.0` clone:
TOTAL: 564/564 matched (100%), 0 missing
All TS tests have Python equivalents.
2. The package shim was missing `TEXT_MIME_PREFIXES` (flagged by Codex
P2). The PR description promises to "re-export everything the former
`chat_sdk.ai` module exposed" — add the constant to both the import
block and `__all__` so the contract holds.
https://claude.ai/code/session_01FyMxQn2BEAzmwKS1GZczKj
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 6995da6 commit 1320300
4 files changed
Lines changed: 39 additions & 2 deletions
File tree
- scripts
- src/chat_sdk/ai
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
File renamed without changes.
0 commit comments