Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/verify_test_fidelity.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"packages/chat/src/markdown.test.ts": "tests/test_markdown_faithful.py",
"packages/chat/src/streaming-markdown.test.ts": "tests/test_streaming_markdown.py",
"packages/chat/src/serialization.test.ts": "tests/test_serialization.py",
"packages/chat/src/ai.test.ts": "tests/test_ai.py",
"packages/chat/src/ai.test.ts": "tests/test_ai_messages.py",
"packages/chat/src/from-full-stream.test.ts": "tests/test_from_full_stream.py",
}

Expand Down
37 changes: 37 additions & 0 deletions src/chat_sdk/ai/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""AI SDK integration for the chat SDK.

Python port of the ``chat/ai`` subpath. Mirrors the upstream structure where
``ai.ts`` was split into ``ai/messages.ts`` (and, in later PRs, ``ai/tools.ts``)
to make room for tool factories.

Re-exports everything the former ``chat_sdk.ai`` module exposed so existing
imports such as ``from chat_sdk.ai import to_ai_messages`` keep working.
"""

from __future__ import annotations

from chat_sdk.ai.messages import (
TEXT_MIME_PREFIXES,
AiAssistantMessage,
AiFilePart,
AiImagePart,
AiMessage,
AiMessagePart,
AiTextPart,
AiUserMessage,
ToAiMessagesOptions,
to_ai_messages,
)
Comment on lines +13 to +24

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Re-export the existing MIME prefix constant

For consumers that imported the non-underscored TEXT_MIME_PREFIXES from the old chat_sdk.ai module (for example to inspect or reuse the text-file attachment policy), this package shim now raises ImportError because it only imports the message types and to_ai_messages. Since this refactor is intended to preserve the old chat_sdk.ai import surface, please re-export the constant from chat_sdk.ai.messages as well.

Useful? React with 👍 / 👎.


__all__ = [
"TEXT_MIME_PREFIXES",
"AiAssistantMessage",
"AiFilePart",
"AiImagePart",
"AiMessage",
"AiMessagePart",
"AiTextPart",
"AiUserMessage",
"ToAiMessagesOptions",
"to_ai_messages",
]
2 changes: 1 addition & 1 deletion src/chat_sdk/ai.py → src/chat_sdk/ai/messages.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Convert chat Messages to AI SDK format.

Python port of ai.ts.
Python port of ``ai/messages.ts``.
"""

from __future__ import annotations
Expand Down
File renamed without changes.
Loading