chatmux
Convert to and from common LLM chat schemas.
All implementations are built on pydantic base models to be network ready.
Installation
pip install chatmux
Usage
Fully OpenAI compatible pydantic models
from chatmux.openai import UserMessage, TextContentPart, ImageContentPart, ImageUrl
user_message = UserMessage(
role="user",
content=[
TextContentPart(type="text", text="Describe this image:"),
ImageContentPart(
type="image_url",
image_url=ImageUrl(url="https://example.com/image.jpg")
)
]
)
openai_messages = [user_message.model_dump(exclude_none=True)]
Conversion methods to and from other schemas
from chatmux.convert import oai_to_qwen
qwen_messages = oai_to_qwen(openai_messages)
print(qwen_messages)
Supported Conversions (as implemented in src/chatmux/convert.py
):
- OpenAI-like -> Unsloth: Converts messages (potentially from JSONL), handling image URLs/base64, embedding PIL Images. (
oai_to_unsloth
)
- OpenAI-like -> Qwen: Converts multimodal messages, keeping image URLs as strings but adjusting the content structure. (
oai_to_qwen
)
Contributing
Please open an issue before submitting a PR.
License
MIT