Dafeigy / ChartsGPT

使用GPT生成ECharts图表/Using GPT to generate Echarts Figures
22 stars 1 forks source link

报错 #5

Closed ccccler closed 7 months ago

ccccler commented 11 months ago

大神啊,我照你的教程,在根目录建了一个config,然后把api替换成了自己的api,但是运行网页之后就是报错啊。这是怎么回事呢? image image

Dafeigy commented 11 months ago

Hello, thanks for your issue report. This bug is related to the return data from ChatGPT in un-formatted json, which means the return data should be satisfied json format but failed.

I am not a expert in prompt enginerting, so I can't actually make some influence on leading ChatGPT returns a formatted json data. However, if you have some skill in prompt engineering, you can change the prompt in utils.py

self.messages = [
            {"role": "system", 
             "content": 
                """根据需求,直接返回提供兼容5.2.1版本的ECharts options符合格式的JSON字符串,回复格式如下:{
                "title": {
                "left": 'center'
                },
                "tooltip": {
                },
                "legend": {
                "orient": 'vertical',
                "left": 'left'
                },
                "series": [],
                ...
                },不需要说明解释返回内容,请严格遵循json语法返回。"""}
        ]

You can perform your prompt skill and change the prompt to make ChatGPT outputs data result that strictly satisfied json format. I am sorry that urrently I am not going to fix that until Chinese New Year holiday due to my heavy burden on other projects.

By the way, your ChatGPT API key is EXPOSED and ANYONE who see this issue may USE it.

Please be careful of your privacy leak when reporting your issue.