Update M.E.AI and MCP versions (#992)

But not yet M.E.AI.OpenAI, which depends on the latest OpenAI, which conflicts with the latest Azure.AI.OpenAI.
This commit is contained in:
Stephen Toub
2025-09-30 03:17:59 -04:00
committed by GitHub
Unverified
parent b8df0cd03f
commit fc4fce7973
13 changed files with 25 additions and 786 deletions
@@ -3,6 +3,7 @@
// This sample shows how to create and use a simple AI agent with Azure OpenAI as the backend, to produce structured output using JSON schema from a class.
using System;
using System.ComponentModel;
using System.Text.Json;
using System.Text.Json.Serialization;
using Azure.AI.OpenAI;
@@ -20,10 +21,7 @@ ChatClientAgentOptions agentOptions = new(name: "HelpfulAssistant", instructions
{
ChatOptions = new()
{
ResponseFormat = ChatResponseFormat.ForJsonSchema(
schema: AIJsonUtilities.CreateJsonSchema(typeof(PersonInfo)),
schemaName: "PersonInfo",
schemaDescription: "Information about a person including their name, age, and occupation")
ResponseFormat = ChatResponseFormat.ForJsonSchema<PersonInfo>()
}
};
@@ -62,6 +60,7 @@ namespace SampleApp
/// <summary>
/// Represents information about a person, including their name, age, and occupation, matched to the JSON schema used in the agent.
/// </summary>
[Description("Information about a person including their name, age, and occupation")]
public class PersonInfo
{
[JsonPropertyName("name")]
@@ -15,7 +15,7 @@ var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? th
var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME") ?? "gpt-4o-mini";
// Create an MCPClient for the GitHub server
await using var mcpClient = await McpClientFactory.CreateAsync(new StdioClientTransport(new()
await using var mcpClient = await McpClient.CreateAsync(new StdioClientTransport(new()
{
Name = "MCPServer",
Command = "npx",
@@ -32,20 +32,20 @@ var consoleLoggerFactory = LoggerFactory.Create(builder => builder.AddConsole())
// Create SSE client transport for the MCP server
var serverUrl = "http://localhost:7071/";
var transport = new SseClientTransport(new()
var transport = new HttpClientTransport(new()
{
Endpoint = new Uri(serverUrl),
Name = "Secure Weather Client",
OAuth = new()
{
ClientName = "ProtectedMcpClient",
ClientId = "ProtectedMcpClient",
RedirectUri = new Uri("http://localhost:1179/callback"),
AuthorizationRedirectDelegate = HandleAuthorizationUrlAsync,
}
}, httpClient, consoleLoggerFactory);
// Create an MCPClient for the protected MCP server
await using var mcpClient = await McpClientFactory.CreateAsync(transport, loggerFactory: consoleLoggerFactory);
await using var mcpClient = await McpClient.CreateAsync(transport, loggerFactory: consoleLoggerFactory);
// Retrieve the list of tools available on the GitHub server
var mcpTools = await mcpClient.ListToolsAsync().ConfigureAwait(false);
@@ -128,7 +128,7 @@ internal sealed class SloganWriterExecutor
{
ChatOptions = new()
{
ResponseFormat = ChatResponseFormat.ForJsonSchema(AIJsonUtilities.CreateJsonSchema(typeof(SloganResult)))
ResponseFormat = ChatResponseFormat.ForJsonSchema<SloganResult>()
}
};
@@ -199,7 +199,7 @@ internal sealed class FeedbackExecutor : ReflectingExecutor<FeedbackExecutor>, I
{
ChatOptions = new()
{
ResponseFormat = ChatResponseFormat.ForJsonSchema(AIJsonUtilities.CreateJsonSchema(typeof(FeedbackResult)))
ResponseFormat = ChatResponseFormat.ForJsonSchema<FeedbackResult>()
}
};
@@ -92,7 +92,7 @@ public static class Program
{
ChatOptions = new()
{
ResponseFormat = ChatResponseFormat.ForJsonSchema(AIJsonUtilities.CreateJsonSchema(typeof(DetectionResult)))
ResponseFormat = ChatResponseFormat.ForJsonSchema<DetectionResult>()
}
});
@@ -105,7 +105,7 @@ public static class Program
{
ChatOptions = new()
{
ResponseFormat = ChatResponseFormat.ForJsonSchema(AIJsonUtilities.CreateJsonSchema(typeof(EmailResponse)))
ResponseFormat = ChatResponseFormat.ForJsonSchema<EmailResponse>()
}
});
}
@@ -107,7 +107,7 @@ public static class Program
{
ChatOptions = new()
{
ResponseFormat = ChatResponseFormat.ForJsonSchema(AIJsonUtilities.CreateJsonSchema(typeof(DetectionResult)))
ResponseFormat = ChatResponseFormat.ForJsonSchema<DetectionResult>()
}
});
@@ -120,7 +120,7 @@ public static class Program
{
ChatOptions = new()
{
ResponseFormat = ChatResponseFormat.ForJsonSchema(AIJsonUtilities.CreateJsonSchema(typeof(EmailResponse)))
ResponseFormat = ChatResponseFormat.ForJsonSchema<EmailResponse>()
}
});
}
@@ -148,7 +148,7 @@ public static class Program
{
ChatOptions = new()
{
ResponseFormat = ChatResponseFormat.ForJsonSchema(AIJsonUtilities.CreateJsonSchema(typeof(AnalysisResult)))
ResponseFormat = ChatResponseFormat.ForJsonSchema<AnalysisResult>()
}
});
@@ -161,7 +161,7 @@ public static class Program
{
ChatOptions = new()
{
ResponseFormat = ChatResponseFormat.ForJsonSchema(AIJsonUtilities.CreateJsonSchema(typeof(EmailResponse)))
ResponseFormat = ChatResponseFormat.ForJsonSchema<EmailResponse>()
}
});
@@ -174,7 +174,7 @@ public static class Program
{
ChatOptions = new()
{
ResponseFormat = ChatResponseFormat.ForJsonSchema(AIJsonUtilities.CreateJsonSchema(typeof(EmailSummary)))
ResponseFormat = ChatResponseFormat.ForJsonSchema<EmailSummary>()
}
});
}