|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using Azure.AI.Projects; |
| 4 | + |
| 5 | +namespace Microsoft.Azure.Samples.ProductionToAdoption |
| 6 | +{ |
| 7 | + public class EvaluationInsights |
| 8 | + { |
| 9 | + private readonly AIProjectClient? _projectClient; |
| 10 | + private readonly string _agentId; |
| 11 | + |
| 12 | + public EvaluationInsights(AIProjectClient? projectClient, string agentId) |
| 13 | + { |
| 14 | + _projectClient = projectClient; |
| 15 | + _agentId = agentId; |
| 16 | + } |
| 17 | + |
| 18 | + // <insight_generation> |
| 19 | + // NOTE: This code is a non-runnable snippet of the larger sample code from which it is taken. |
| 20 | + public Dictionary<string, object> AnalyzeEvaluationResults() |
| 21 | + { |
| 22 | + Helpers.PrintInfo("Analyzing evaluation patterns..."); |
| 23 | + var random = new Random(); |
| 24 | + var insights = new Dictionary<string, object> |
| 25 | + { |
| 26 | + ["failure_patterns"] = new List<Dictionary<string, object>> |
| 27 | + { |
| 28 | + new() { ["pattern"] = "SharePoint connection timeout", ["frequency"] = random.Next(15, 25) } |
| 29 | + }, |
| 30 | + ["quality_trends"] = new Dictionary<string, object> |
| 31 | + { |
| 32 | + ["current_month"] = random.NextDouble() * 0.2 + 0.8, |
| 33 | + ["last_month"] = random.NextDouble() * 0.2 + 0.7 |
| 34 | + }, |
| 35 | + ["recommendations"] = new List<string> { "Address high-impact failure patterns first" } |
| 36 | + }; |
| 37 | + return insights; |
| 38 | + } |
| 39 | + // </insight_generation> |
| 40 | + |
| 41 | + public Dictionary<string, object> Run() |
| 42 | + { |
| 43 | + Helpers.PrintHeader("Evaluation Insights Analysis"); |
| 44 | + var insights = AnalyzeEvaluationResults(); |
| 45 | + Helpers.PrintEvaluationInsights(insights); |
| 46 | + Helpers.SaveJson(insights, "evaluation_insights.json"); |
| 47 | + return insights; |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + public class GatewayIntegration |
| 52 | + { |
| 53 | + private readonly AIProjectClient? _projectClient; |
| 54 | + private readonly string _agentId; |
| 55 | + |
| 56 | + public GatewayIntegration(AIProjectClient? projectClient, string agentId) |
| 57 | + { |
| 58 | + _projectClient = projectClient; |
| 59 | + _agentId = agentId; |
| 60 | + } |
| 61 | + |
| 62 | + // <apim_policies> |
| 63 | + // NOTE: This code is a non-runnable snippet of the larger sample code from which it is taken. |
| 64 | + public Dictionary<string, object> ConfigureGatewayPolicies() |
| 65 | + { |
| 66 | + Helpers.PrintInfo("Configuring API Management policies..."); |
| 67 | + var config = new Dictionary<string, object> |
| 68 | + { |
| 69 | + ["configuration"] = new Dictionary<string, object> |
| 70 | + { |
| 71 | + ["endpoint"] = "https://your-apim.azure-api.net/agents/workplace", |
| 72 | + ["rate_limit"] = "100 requests per minute per user", |
| 73 | + ["caching_enabled"] = true |
| 74 | + } |
| 75 | + }; |
| 76 | + return config; |
| 77 | + } |
| 78 | + // </apim_policies> |
| 79 | + |
| 80 | + public Dictionary<string, object> Run() |
| 81 | + { |
| 82 | + Helpers.PrintHeader("AI Gateway Integration"); |
| 83 | + var config = ConfigureGatewayPolicies(); |
| 84 | + Helpers.PrintGatewaySummary(config); |
| 85 | + Helpers.SaveJson(config, "gateway_config.json"); |
| 86 | + return config; |
| 87 | + } |
| 88 | + } |
| 89 | + |
| 90 | + public class ContinuousMonitoring |
| 91 | + { |
| 92 | + private readonly AIProjectClient? _projectClient; |
| 93 | + private readonly string _agentId; |
| 94 | + |
| 95 | + public ContinuousMonitoring(AIProjectClient? projectClient, string agentId) |
| 96 | + { |
| 97 | + _projectClient = projectClient; |
| 98 | + _agentId = agentId; |
| 99 | + } |
| 100 | + |
| 101 | + // <quality_monitoring> |
| 102 | + // NOTE: This code is a non-runnable snippet of the larger sample code from which it is taken. |
| 103 | + public Dictionary<string, object> SetupMonitoringSchedule() |
| 104 | + { |
| 105 | + Helpers.PrintInfo("Configuring monitoring schedule..."); |
| 106 | + var config = new Dictionary<string, object> |
| 107 | + { |
| 108 | + ["schedule"] = new Dictionary<string, object> |
| 109 | + { |
| 110 | + ["hourly_checks"] = new Dictionary<string, object> { ["enabled"] = true }, |
| 111 | + ["daily_reports"] = new Dictionary<string, object> { ["enabled"] = true } |
| 112 | + }, |
| 113 | + ["alerts"] = new List<Dictionary<string, object>> |
| 114 | + { |
| 115 | + new() { ["name"] = "Quality Degradation", ["severity"] = "high" } |
| 116 | + } |
| 117 | + }; |
| 118 | + return config; |
| 119 | + } |
| 120 | + // </quality_monitoring> |
| 121 | + |
| 122 | + public Dictionary<string, object> Run() |
| 123 | + { |
| 124 | + Helpers.PrintHeader("Continuous Monitoring Setup"); |
| 125 | + var config = SetupMonitoringSchedule(); |
| 126 | + Helpers.PrintMonitoringSummary(config); |
| 127 | + Helpers.SaveJson(config, "monitoring_schedule.json"); |
| 128 | + return config; |
| 129 | + } |
| 130 | + } |
| 131 | + |
| 132 | + public class FleetGovernance |
| 133 | + { |
| 134 | + private readonly AIProjectClient? _projectClient; |
| 135 | + private readonly string _agentId; |
| 136 | + |
| 137 | + public FleetGovernance(AIProjectClient? projectClient, string agentId) |
| 138 | + { |
| 139 | + _projectClient = projectClient; |
| 140 | + _agentId = agentId; |
| 141 | + } |
| 142 | + |
| 143 | + // <compliance_reporting> |
| 144 | + // NOTE: This code is a non-runnable snippet of the larger sample code from which it is taken. |
| 145 | + public Dictionary<string, object> GenerateGovernanceReport() |
| 146 | + { |
| 147 | + Helpers.PrintInfo("Generating fleet governance report..."); |
| 148 | + var random = new Random(); |
| 149 | + var report = new Dictionary<string, object> |
| 150 | + { |
| 151 | + ["statistics"] = new Dictionary<string, object> |
| 152 | + { |
| 153 | + ["total_agents"] = random.Next(12, 18), |
| 154 | + ["active_users"] = random.Next(120, 180), |
| 155 | + ["compliance_rate"] = random.NextDouble() * 0.05 + 0.95 |
| 156 | + }, |
| 157 | + ["recommendations"] = new List<string> { "All agents meet compliance standards" } |
| 158 | + }; |
| 159 | + return report; |
| 160 | + } |
| 161 | + // </compliance_reporting> |
| 162 | + |
| 163 | + public Dictionary<string, object> Run() |
| 164 | + { |
| 165 | + Helpers.PrintHeader("Fleet-Wide Governance"); |
| 166 | + var report = GenerateGovernanceReport(); |
| 167 | + Helpers.PrintGovernanceSummary(report); |
| 168 | + Helpers.SaveJson(report, "governance_report.json"); |
| 169 | + return report; |
| 170 | + } |
| 171 | + } |
| 172 | + |
| 173 | + public class CostOptimization |
| 174 | + { |
| 175 | + private readonly AIProjectClient? _projectClient; |
| 176 | + private readonly string _agentId; |
| 177 | + |
| 178 | + public CostOptimization(AIProjectClient? projectClient, string agentId) |
| 179 | + { |
| 180 | + _projectClient = projectClient; |
| 181 | + _agentId = agentId; |
| 182 | + } |
| 183 | + |
| 184 | + // <cost_analysis> |
| 185 | + // NOTE: This code is a non-runnable snippet of the larger sample code from which it is taken. |
| 186 | + public Dictionary<string, object> AnalyzeCosts() |
| 187 | + { |
| 188 | + Helpers.PrintInfo("Analyzing agent costs..."); |
| 189 | + var random = new Random(); |
| 190 | + var totalCost = random.NextDouble() * 700 + 2800; |
| 191 | + var report = new Dictionary<string, object> |
| 192 | + { |
| 193 | + ["totals"] = new Dictionary<string, object> |
| 194 | + { |
| 195 | + ["total_cost"] = totalCost, |
| 196 | + ["period"] = "Last 30 days" |
| 197 | + }, |
| 198 | + ["projected_savings"] = totalCost * 0.3 |
| 199 | + }; |
| 200 | + return report; |
| 201 | + } |
| 202 | + // </cost_analysis> |
| 203 | + |
| 204 | + public Dictionary<string, object> Run() |
| 205 | + { |
| 206 | + Helpers.PrintHeader("Cost Monitoring & Optimization"); |
| 207 | + var report = AnalyzeCosts(); |
| 208 | + Helpers.PrintCostSummary(report); |
| 209 | + Helpers.SaveJson(report, "cost_report.json"); |
| 210 | + return report; |
| 211 | + } |
| 212 | + } |
| 213 | +} |
0 commit comments