Texera / texera

Collaborative Machine-Learning-Centric Data Analytics Using Workflows
https://texera.github.io
Apache License 2.0
161 stars 68 forks source link

Enhancing Report Generation by Adding Story-teller Ai based on Ai flag #2816

Open xudongwu-0 opened 2 weeks ago

xudongwu-0 commented 2 weeks ago

This PR enhances the report generation functionality by addingStory-teller Ai based on Ai flag. This PR is a continuation and enhancement of the previous PR: Adding a button to generate a report for a workflow: #2770 Enhancing Report Generation by adding Operator Results: #2792 Enhancing Report Generation by Adding Operator Json and Comments Section : #2807 Ai Flag: https://github.com/Texera/texera/pull/2818 and https://github.com/Texera/texera/pull/2808

New Methods: checkAiAssistantEnabled(): Validates whether the AI Assistant feature is enabled by checking the availability of the required API key. This function ensures that subsequent AI-based functionalities are executed only when the AI Assistant is available.

generateComment(operatorInfo: any): Generates insightful comments for each operator using OpenAI’s GPT model, tailored for a highly educated audience but one that might not have deep statistical knowledge. The comments are plain text, enhancing the overall readability and value of the report.

generateSummaryComment(operatorInfo: any): Produces a concise, insightful summary comment that highlights key findings, trends, and areas of improvement across the workflow, focusing particularly on UDFs. This function is crucial for providing a comprehensive understanding of the workflow to users.

Enhanced Methods: retrieveOperatorInfoReport(operatorId: string, allResults: { operatorId: string; html: string }[]): Implements the checkAiAssistantEnabled, generateComment, and generateSummaryComment functions to enrich the operator information section in the generated reports. The function now adds a "Toggle Detail" button beneath each operator, allowing users to expand and view the operator’s corresponding JSON, formatted using a JSON viewer. Additionally, a comments section is added below each operator, enabling users to leave or view AI-generated comments.

generateReportAsHtml(workflowSnapshot: string, allResults: string[], workflowName: string): Generates a comprehensive HTML file containing the workflow snapshot, all operator results, operator details, and comments. This method integrates AI-generated comments and a summary section at the end of the report. It also introduces a "Download Workflow JSON" button, allowing users to download the entire workflow JSON file directly from the report.

Operation Process: Click the button below to generate the report with detailed operator results and the workflow snapshot. image

To turn on the ai feature, you need to modify the following sections in application.udf image

For example, to turn on the openai: image

Here is a part of the example report. image image