Socket
Book a DemoInstallSign in
Socket

chatmux

Package Overview
Maintainers
2
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Source code not available
We could not scan this package. Some page functionalities have been disabled

chatmux

Convert between common LLM chat schemas

pipPyPI
Metadata Only
Version
0.1.5
Maintainers
2

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

# Example using Pydantic models (more robust):
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)] # Convert model to dict

Conversion methods to and from other schemas

from chatmux.convert import oai_to_qwen

qwen_messages = oai_to_qwen(openai_messages)
print(qwen_messages)
# Expected Output (structure based on oai_to_qwen):
# [
#     {
#         'role': 'user',
#         'content': [
#             {'type': 'text', 'text': 'Describe this image:'},
#             {'type': 'image', 'image': 'https://example.com/image.jpg'}
#         ]
#     }
# ]

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

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts