src/Private/Report/AI/Get-MCSMetroAICxEnvironmentData.ps1

function Get-MCSMetroAICxEnvironmentData {
    Param(
        $CustomerName,
        $WorkloadName,
        $MetroAgent,
        $ExtraRequest,
        $Debug
    )

    if ($Debug.IsPresent) {
        $DebugPreference = "Continue"
    } else {
        $DebugPreference = "SilentlyContinue"
    }

    Write-Debug ((get-date -Format 'yyyy-MM-dd HH_mm_ss')+' - '+"Getting Cx Environment Details by AI")

    $Conversation = New-MetroAIConversation

    $Prompt = @"
Just rewrite the following text 'The following services and subscriptions have been identified as a part of the $CustomerName - $WorkloadName and will receive the elevated experience provided by the Mission Critical Services for Azure Workload'.
 
Answering rules:
- Produce only the final explanation text, suitable for insertion into a PowerPoint table cell.
- The explanation must be between 20 and 25 words.
- The explanation must absolutely not look it was written by AI and should not contain anything besides the requested answer.
- Do not include references, source titles, URLs, citations, or "Official reference" by default.
- Do not include markdown formatting.
- Do not use bullet points.
- Do not include phrases such as "Understood", "I searched", "looked sources", "did not find", "if you wish", "if you prefer", or apologies.
- Do not offer to search again.
 
$ExtraRequest
"@


    try
        {
            $turn  = Invoke-MetroAIConversation -AgentId $MetroAgent.id -ConversationId $Conversation.id -UserInput $Prompt -Debug:$false
            Write-Debug ((get-date -Format 'yyyy-MM-dd HH_mm_ss')+' - '+"AI Response ID: $($turn.ResponseId)")
            Start-Sleep -Milliseconds 500
        }
    catch
        {
            Write-Warning "Error invoking AI conversation for Cx environment details. Error: $_"
            $turn = @{ AssistantText = "The identified services and subscriptions within the $CustomerName - $WorkloadName will benefit from the enhanced support and expertise offered by Mission Critical Services for Azure Workload." }
        }

    return $turn.AssistantText
}