-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
convert : fix Norway problem when parsing YAML #12114
Conversation
The problem seems to be fixed on yaml 1.2 specs, but |
gguf-py/gguf/metadata.py
Outdated
yaml_content += "\n" | ||
yaml_content = yaml_content.replace("- no\n", "- \"no\"\n") | ||
|
||
if yaml_content: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now this if
is always true
, because of the extra new line.
Maybe the extra \n
should be added only when joining the lines?
diff --git a/gguf-py/gguf/metadata.py b/gguf-py/gguf/metadata.py
index 0629306bb..e807f4346 100644
--- a/gguf-py/gguf/metadata.py
+++ b/gguf-py/gguf/metadata.py
@@ -139,11 +139,10 @@ class Metadata:
break # End of frontmatter
else:
lines_yaml.append(line)
- yaml_content = "\n".join(lines_yaml)
+ yaml_content = "\n".join(lines_yaml) + "\n"
# Quick hack to fix the Norway problem
# https://hitchdev.com/strictyaml/why/implicit-typing-removed/
- yaml_content += "\n"
yaml_content = yaml_content.replace("- no\n", "- \"no\"\n")
if yaml_content:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes thanks, implemented in bd40850
* convert : fix Norway problem when parsing YAML * Update gguf-py/gguf/metadata.py * add newline at correct place
Related to #12091 (comment)
The problem is:
- no
The YAML above will be interpreted as "yes/no", which is translated into true/false boolean value.
The fix? Do a replace
no
-->"no"
CC @mofosyne @compilade if you have a better solution