-
Notifications
You must be signed in to change notification settings - Fork 183
Open
Description
Summary:
Running the example code from the openai_harmony repository results in a HarmonyError when calling parse_messages_from_completion_tokens(...).
Steps to Reproduce:
from openai_harmony import (
load_harmony_encoding,
HarmonyEncodingName,
Role,
Message,
Conversation,
DeveloperContent,
SystemContent,
)
enc = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)
convo = Conversation.from_messages([
Message.from_role_and_content(
Role.SYSTEM,
SystemContent.new(),
),
Message.from_role_and_content(
Role.DEVELOPER,
DeveloperContent.new().with_instructions("Talk like a pirate!")
),
Message.from_role_and_content(Role.USER, "Arrr, how be you?"),
])
tokens = enc.render_conversation_for_completion(convo, Role.ASSISTANT)
print(tokens)
#fails here <--
parsed = enc.parse_messages_from_completion_tokens(tokens, role=Role.ASSISTANT)
print(parsed)
It raised the following error while executing the last statement in the above example `parsed = enc.parse_messages_from_completion_tokens(tokens, role=Role.ASSISTANT).
Output and Traceback
[200006, 17360, 200008, 3575, 553, 17554, 162016, 11, 261, 4410, 6439, 2359, 22203, 656, 7788, 17527, 558, 87447, 100594, 25, 220, 1323, 19, 12, 3218, 279, 30377, 289, 25, 14093, 279, 2, 13888, 18403, 25, 8450, 11, 49159, 11, 1721, 13, 21030, 2804, 413, 7360, 395, 1753, 3176, 13, 200007, 200006, 77944, 200008, 2, 68406, 279, 37992, 1299, 261, 96063, 0, 200007, 200006, 1428, 200008, 8977, 81, 11, 1495, 413, 481, 30, 200007, 200006, 173781]
Traceback (most recent call last):
File "/home/arun/experiments/gpt_oss.py", line 25, in <module>
parsed = enc.parse_messages_from_completion_tokens(tokens, role=Role.ASSISTANT)
File "/home/arun/miniconda3/envs/thcr/lib/python3.13/site-packages/openai_harmony/__init__.py", line 525, in parse_messages_from_completion_tokens
raw_json: str = self._inner.parse_messages_from_completion_tokens(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
list(tokens), None if role is None else str(role.value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
openai_harmony.HarmonyError: Unexpected EOS while waiting for message header to complete
I checked the source code; however, the variable self._inner
is bound to the Rust-side variable inner
.
aleksanderhan
Metadata
Metadata
Assignees
Labels
No labels