Skip to content

Possible fix to rare JSON decode error #42

@Coelacanthiform

Description

@Coelacanthiform

I believe some models occasionally use smart quotes in their text - particularly when compressing memories. Kimi-K2 seems to be doing this regularly. These appear to be translated as straight quotes, which breaks JSON formatting. Substituting them for apostrophes would get around the issue.

In bin/lua/infra/HTTP/json.lua we replace line 554-555:

  -- Replace left double quotation mark and right double quotation mark with standard quotes
  str = str:gsub("\226\128\156", '"') -- left double quotation mark
  str = str:gsub("\226\128\157", '"') -- right double quotation mark

With:

  -- Replace left double quotation mark and right double quotation mark with standard apostrophes
  str = str:gsub("\226\128\156", "'") -- left double quotation mark
  str = str:gsub("\226\128\157", "'") -- right double quotation mark

Could also be a good idea to add some more entries to the CYRILIFIER, currently some missing entry errors end up as garbage characters like superscript "TM" and "B", but they won't break the JSON. I added these for now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions