}
@code {
[Parameter] public string SessionId { get; set; }
private class FormStep
{
public string Prompt { get; set; } = string.Empty;
public string Explanation { get; set; } = string.Empty;
public string Value { get; set; } = string.Empty;
}
private List formSteps = new()
{
new FormStep { Prompt = "What is your full name?", Explanation = "Please enter your legal full name as it appears on official documents." },
new FormStep { Prompt = "What is your email address?", Explanation = "We'll use this to send you updates and confirmations." },
new FormStep { Prompt = "What is your home address?", Explanation = "This is needed for official correspondence." },
new FormStep { Prompt = "Describe your work experience.", Explanation = "Provide a summary of your relevant job history." },
new FormStep { Prompt = "What is your preferred method of contact?", Explanation = "Phone, email, or other? Please specify why you prefer it." }
};
private int currentStep = 0;
private string aiReview = string.Empty;
private string aiClarification = string.Empty;
private void NextStep()
{
if (currentStep < formSteps.Count - 1)
{
currentStep++;
aiClarification = string.Empty; // Reset AI response when moving to the next question
}
else
{
ValidateWithAI();
}
}
private void PreviousStep()
{
if (currentStep > 0)
{
currentStep--;
aiClarification = string.Empty; // Reset AI response when going back
}
}
private async void AskForClarification()
{
aiClarification = "AI is thinking...";
aiClarification = await AiService.GetSimpleChatGPTResponse(SessionId, "Provide additional clarification for the following question:", formSteps[currentStep].Prompt);
}
private async void ValidateWithAI()
{
string formData = string.Join("\n", formSteps.Select(s => $"{s.Prompt} {s.Value}"));
aiReview = await AiService.GetSimpleChatGPTResponse(SessionId, "Review the form for completeness and correctness:", formData);
}
private void RestartForm()
{
currentStep = 0;
aiReview = string.Empty;
aiClarification = string.Empty;
formSteps.ForEach(step => step.Value = string.Empty);
}
}