Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
LLM Text-to-Chart Demo for MySQL (twitter.com/xcsme)
3 points by XCSme on Nov 5, 2024 | hide | past | favorite | 1 comment


In this Twitter thread I also describe how it works, here's it copy-pasted:

How it works:

    - The system prompt describes the database structure and in which format to respond
    - You ask a question
    - The AI generates a MySQL query
    - The query is executed locally, on your server
    - The results are displayed in your dashboard
    - For the charts, the AI also generates a Chart.js config 
    - (actually it's trickier than that, it makes the MySQL query generate a Chart.js config, that includes all chart settings AND the data)
    - The Chart.js config is used to display the chart in the React application
As you can see, at no point does OpenAI see any of your data or query results. It only knows the DB structure and your question.

For the history (so you can ask follow-up questions), only the history of your questions + AI-generated responses are included, none of the query results.

Implementing it like this it works better than I expected, you can not only ask the AI questions about the data, but you can also ask it to stylize the chart, or change the chart type, or change colours.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: