Skip to content

Conversation

amirhosseinghanipour
Copy link
Contributor

The Python wrapper called the Rust binding with keyword arguments, but the Rust binding expected positional arguments. That's why #52 reported the call to encoding.render(msg, render_options=...). So, I changed the Python method to pass positional arguments instead of keyword arguments when calling the binding.

Copy link

@chris-monardo chris-monardo left a comment

Choose a reason for hiding this comment

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

Thanks!

@jryanhaber
Copy link

This is one of the 30 or so substantive challenges I am working through, quite a grind, on getting the 120B actually running in this system. It is a ton of work.

I think I have the harmony conversion done, the weight mapping done, have def sorted the keys on both sides for the weight mapping, but getting them patched in is still a grind. I'm on it. Not sure if the authors prefer I fork or run a pull request here, let me know.

@dkundel-openai
Copy link
Collaborator

I don't see an issue with this PR but I can't replicate the issue this is meaning to fix. Do you have a test or an example to reproduce the fix? I tried to encoding.render both with a message and no options and with a message and options and both worked fine.

@chris-monardo
Copy link

chris-monardo commented Aug 16, 2025

Python 3.13.5
maturin 1.9.3
cargo 1.88.0 (873a06493 2025-05-10)

pytest -vvv tests/test_harmony.py::test_render_and_render_conversation_roundtrip
==================================================================================== test session starts =====================================================================================
platform linux -- Python 3.13.5, pytest-8.4.1, pluggy-1.6.0 -- /workspaces/harmony/.venv/bin/python
cachedir: .pytest_cache
rootdir: /workspaces/harmony
configfile: pyproject.toml
collected 1 item                                                                                                                                                                             

tests/test_harmony.py::test_render_and_render_conversation_roundtrip FAILED                                                                                                            [100%]

========================================================================================== FAILURES ==========================================================================================
_______________________________________________________________________ test_render_and_render_conversation_roundtrip ________________________________________________________________________

    def test_render_and_render_conversation_roundtrip():
        encoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)
    
        msg = Message.from_role_and_content(Role.USER, "Hello")
        convo = Conversation.from_messages([msg])
    
>       tokens_msg = encoding.render(msg)
                     ^^^^^^^^^^^^^^^^^^^^

tests/test_harmony.py:811: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <openai_harmony.HarmonyEncoding object at 0x7fd7ca25d940>
message = Message(author=Author(role=<Role.USER: 'user'>, name=None), content=[TextContent(text='Hello')], channel=None, recipient=None, content_type=None), render_options = None

    def render(
        self, message: Message, render_options: Optional[RenderOptions] = None
    ) -> List[int]:
        """Render a single message into tokens."""
        if render_options is None:
            render_options_dict = {"conversation_has_function_tools": False}
        else:
            render_options_dict = {
                "conversation_has_function_tools": render_options.conversation_has_function_tools
            }
    
>       return self._inner.render(
            message_json=message.to_json(), render_options=render_options_dict
        )
E       TypeError: PyHarmonyEncoding.render() got an unexpected keyword argument 'render_options'

python/openai_harmony/__init__.py:516: TypeError
================================================================================== short test summary info ===================================================================================
FAILED tests/test_harmony.py::test_render_and_render_conversation_roundtrip - TypeError: PyHarmonyEncoding.render() got an unexpected keyword argument 'render_options'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants