# AI-Supported EUD for Data Visualization: An Exploratory Case Study
## 4 Phase 2: Answering RQ2
### The AI-Supported Data Visualization Prototype  
The design probe is a prototype web application that follows the client-server paradigm. Specifically, PostgreSQL is employed as the database management system. To leverage its LLM capabilities, the API provided by OpenAI is used, exploiting one of the most advanced models currently available, i.e., _GPT-4o_. The LLM is responsible for (i) generating the extraction SQL query based on the user's intent, and (ii) recommending the most suitable visualization for the requested data and user profile. To instantiate the model, a dynamic prompt engineering approach was adopted to ensure adaptability to individual users. The prompt structure consists of a fixed part that provides general system instructions about the task (i.e., _\"generate a SQL query and provide a suggested data visualization type\"_). At the same time, user-specific information is dynamically injected at runtime based on the logged user. These adaptive elements include user preferences, such as commonly used visualization types and interaction patterns, as well as the schema of the database relevant to the user's daily activity. After the SQL query generation, the system undergoes a formal syntax validation to confirm adherence to SQL standards. Additionally, this validation ensures that the query is limited to data retrieval operations (_SELECT_ statements) and does not include modification or deletion commands (_UPDATE_ or _DELETE_ statements), thereby mitigating potential security risks. To ensure response consistency, minimizing the model temperature parameter, which controls response variability, is crucial. A lower temperature setting enhances determinism, ensuring that identical inputs yield consistent outputs. For this case study, a temperature equal to 0.2 has been chosen. \begin{table}
\begin{tabular}{l l l l} \hline \hline
**Common Challenges to the Three Profiles** & **Technology** & **Literacy** & **Business** \\ \hline Heavily rely on manual work with Excel & BI Tools & IT skills & Routine and Task \\ Identify data viz for audience with different expertise is complex & Visualization & Education & Context \\ Tendence to simplify data viz and visual analytics & Visualization & Education & Context \\ BI tools are too rigid, thus Excel is preferred & BI Tools & IT skills & Routine and Task \\ Manual checking for data consistency is due to avoid poor decisions & BI tools & Engagement & Routine and Task \\ More dynamic solutions are complex and time is a barrier & BI Tools & IT skills & Routine and Task \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Common challenges for the three key user profiles, anchored to dimensions of the theoretical framework. The proposed solution enhances users' data management by leveraging an end-to-end workflow that integrates query generation (Text-to-SQL) and visualization suggestions (Text-to-Vis). The main objective is to simplify user interaction, ensuring that individuals without programming expertise can easily retrieve and analyze data related to their work practices. In particular, the user initiates an interaction by submitting a natural language request. The user request, the model initialization instructions, the history of the previous messages in the same conversation, the user profile, and the database structure are processed and forwarded to the LLM. Having been instructed with contextual information about the database structure and application domain, the model generates the SQL query to extract the requested data and a suggested visualization format. After its validation, the SQL query is executed and the relevant data is extracted. It is important to note that it is not the LLM that executes the query but the backend of our web-based prototype, thus avoiding privacy and security issues regarding data dissemination. Without a specified user preference for data representation, the model autonomously selects the most appropriate visualization based on the requested data and the user profile.