MetaGPT icon indicating copy to clipboard operation
MetaGPT copied to clipboard

the action_node example do not support chinese

Open wujiren opened this issue 1 year ago • 1 comments
trafficstars

Bug description file: metagpt/actions/action_node.py line 189

    def compile_to(self, i: Dict, schema, kv_sep) -> str:
        if schema == "json":
            return json.dumps(i, indent=4)
        elif schema == "markdown":
            return dict_to_markdown(i, kv_sep=kv_sep)
        else:
            return str(i)

json schema will compile the action_node example Chinese str to unicode, if the input is unicode, LLM has a good chance to output unicode,

Bug solved method i think maybe it could add a parameter “ensure_ascii=False”, just like:

    def compile_to(self, i: Dict, schema, kv_sep) -> str:
        if schema == "json":
            return json.dumps(i, indent=4, ensure_ascii=False)
        elif schema == "markdown":
            return dict_to_markdown(i, kv_sep=kv_sep)
        else:
            return str(i)

Environment information

  • LLM type and model name: OpenAi gpt-4-1106-preview
  • System version:
  • Python version: 3.10.13
  • packages version: 0.6.6
  • installation method: pip

Screenshots or logs

wujiren avatar Jan 30 '24 08:01 wujiren

https://github.com/geekan/MetaGPT/pull/1065 I added this by the way

geekan avatar Mar 21 '24 06:03 geekan