Display Logic¶
This section guides you through setting up the display logic for structured output generated by Azure OpenAI in the PromptDialog page of your Project Planning Copilot.
1. Define Generation Logic¶
First, implement the GenerateProjectPlan procedure on your "GPT Copilot Project Proposal" page. This procedure will interact with Azure OpenAI to convert text responses into structured data.
- Location: Add this procedure in the
"GPT Copilot Project Proposal"page. - Implementation:
local procedure GenerateProjectPlan() var ProjectPlanCopilotImpl: Codeunit "GPT Project Plan Copilot Impl."; CopilotJobProposal: Record "GPT Copilot Job Proposal"; begin // Generate project data using Azure OpenAI ProjectPlanCopilotImpl.Generate(JobDescription, JobFullDescription, CopilotJobProposal, InputProjectDescription); // Load the generated data into the page for user interaction CurrPage.ProposalDetails.Page.Load(CopilotJobProposal); end;
This procedure calls the AI implementation to generate project details, which are then passed to the part page (subpart of the PromptDialog) to display. Notice that we return not only the filled CopilotJobProposal records but also the JobDescription and JobFullDescription fields, which are shown in the header of the PromptDialog Content (Output) mode.
2. Implement Load Procedure¶
Next, modify the part page to handle the loading of structured data into the UI. This will ensure the data is presented in a user-friendly format.
- Location: Edit the
"\src\2-PlanningCopilot\PromptDialog\CopilotJobProposalSubpart.Page.al"file. - Implementation:
internal procedure Load(var CopilotJobProposal: Record "GPT Copilot Job Proposal") begin Rec.Reset(); Rec.DeleteAll(); // Load each generated proposal into the temporary buffer for display CopilotJobProposal.Reset(); if CopilotJobProposal.FindSet() then repeat CopilotJobProposal.CalcFields("Action Description"); Rec.Copy(CopilotJobProposal, false); Rec."Action Description" := CopilotJobProposal."Action Description"; Rec.Insert(); until CopilotJobProposal.Next() = 0; CurrPage.Update(false); end;
This function ensures each item from the generated project proposals is displayed accurately on the part page.
Testing Your Copilot¶
With the functionalities set up, test the Project Planning Copilot by initiating it within the main application to plan various project types, such as conferences or workshops.
- Experiment with Different Inputs: Test various project descriptions to evaluate how the AI interprets them and how those interpretations are structured and displayed.
- Review and Adjust: Monitor the alignment of AI responses with your expectations and adjust the system messages, generation logic, or UI interactions accordingly to enhance performance and user experience.
Next Steps¶
Proceed to the final step to learn how to save and manage the proposed project plans within Dynamics 365 Business Central for further action and tracking.