graphrag icon indicating copy to clipboard operation
graphrag copied to clipboard

[Feature Request]: <title> The model may generate a json string in markdown format

Open lwdnxu opened this issue 1 year ago • 4 comments

Is your feature request related to a problem? Please describe.

The model may generate a json string in markdown format

Describe the solution you'd like

Solution: Replace markdown syntax with re

import re
if re.match(r'```json\n.*\n```', output, re.DOTALL):
    output = re.search(r'```json\n(.*)\n```', output, re.DOTALL).group(1)
return LLMOutput(output=output)

1721117865192

After use, the entire workflow can be completed, as shown in the figure 1721118013529

Additional context

No response

lwdnxu avatar Jul 16 '24 08:07 lwdnxu

修改一下

try:
    if re.match(r'```json\n.*\n```', output, re.DOTALL):
        output = re.search(r'```json\n(.*)\n```', output, re.DOTALL).group(1)
except:
    pass

lwdnxu avatar Jul 16 '24 08:07 lwdnxu

Suggest submission, the prompt has been modified many times but still cannot be formatted correctly.

kShines avatar Jul 16 '24 10:07 kShines

Suggest submission, the prompt has been modified many times but still cannot be formatted correctly.建议提交,提示已修改多次但仍无法正确格式化。

I also tried to modify the prompt words to make the output more json instead of markdown, but I found that I couldn't do it, so I modified the source code.

lwdnxu avatar Jul 16 '24 10:07 lwdnxu

This issue has been marked stale due to inactivity after repo maintainer or community member responses that request more information or suggest a solution. It will be closed after five additional days.

github-actions[bot] avatar Jul 26 '24 01:07 github-actions[bot]

We have resolved several issues related to text encoding and JSON parsing that are rolled up into version 0.2.2. Please try again with that version and re-open if this is still an issue.

natoverse avatar Aug 09 '24 17:08 natoverse