Update M.E.AI to latest version (#241)
Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
This commit is contained in:
parent
dfafebd8fe
commit
0c502c43af
4 changed files with 76 additions and 1147 deletions
|
|
@ -213,7 +213,7 @@ public class McpClientExtensionsTests : ClientServerTestBase
|
|||
var tools = await client.ListToolsAsync(cancellationToken: TestContext.Current.CancellationToken);
|
||||
Assert.Equal(12, tools.Count);
|
||||
var echo = tools.Single(t => t.Name == "Method4");
|
||||
var result = await echo.InvokeAsync(new Dictionary<string, object?>() { ["i"] = 42 }, TestContext.Current.CancellationToken);
|
||||
var result = await echo.InvokeAsync(new() { ["i"] = 42 }, TestContext.Current.CancellationToken);
|
||||
Assert.Contains("Method4 Result 42", result?.ToString());
|
||||
|
||||
var valuesSetViaAttr = tools.Single(t => t.Name == "ValuesSetViaAttr");
|
||||
|
|
@ -240,7 +240,7 @@ public class McpClientExtensionsTests : ClientServerTestBase
|
|||
{
|
||||
if (tool.Name == "Method4")
|
||||
{
|
||||
var result = await tool.InvokeAsync(new Dictionary<string, object?>() { ["i"] = 42 }, TestContext.Current.CancellationToken);
|
||||
var result = await tool.InvokeAsync(new() { ["i"] = 42 }, TestContext.Current.CancellationToken);
|
||||
Assert.Contains("Method4 Result 42", result?.ToString());
|
||||
return;
|
||||
}
|
||||
|
|
@ -277,7 +277,7 @@ public class McpClientExtensionsTests : ClientServerTestBase
|
|||
IMcpClient client = await CreateMcpClientForServer();
|
||||
|
||||
var tool = (await client.ListToolsAsync(emptyOptions, TestContext.Current.CancellationToken)).First();
|
||||
await Assert.ThrowsAsync<NotSupportedException>(() => tool.InvokeAsync(new Dictionary<string, object?> { ["i"] = 42 }, TestContext.Current.CancellationToken));
|
||||
await Assert.ThrowsAsync<NotSupportedException>(async () => await tool.InvokeAsync(new() { ["i"] = 42 }, TestContext.Current.CancellationToken));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public class ClientIntegrationTests : LoggedTest, IClassFixture<ClientIntegratio
|
|||
await using var client = await _fixture.CreateClientAsync(clientId);
|
||||
var aiFunctions = await client.ListToolsAsync(cancellationToken: TestContext.Current.CancellationToken);
|
||||
var echo = aiFunctions.Single(t => t.Name == "echo");
|
||||
var result = await echo.InvokeAsync([new KeyValuePair<string, object?>("message", "Hello MCP!")], TestContext.Current.CancellationToken);
|
||||
var result = await echo.InvokeAsync(new() { ["message"] = "Hello MCP!" }, TestContext.Current.CancellationToken);
|
||||
|
||||
// assert
|
||||
Assert.NotNull(result);
|
||||
|
|
@ -495,7 +495,7 @@ public class ClientIntegrationTests : LoggedTest, IClassFixture<ClientIntegratio
|
|||
var mappedTools = await client.ListToolsAsync(cancellationToken: TestContext.Current.CancellationToken);
|
||||
|
||||
// Create the chat client.
|
||||
using IChatClient chatClient = new OpenAIClient(s_openAIKey).AsChatClient("gpt-4o-mini")
|
||||
using IChatClient chatClient = new OpenAIClient(s_openAIKey).GetChatClient("gpt-4o-mini").AsIChatClient()
|
||||
.AsBuilder()
|
||||
.UseFunctionInvocation()
|
||||
.Build();
|
||||
|
|
@ -518,8 +518,8 @@ public class ClientIntegrationTests : LoggedTest, IClassFixture<ClientIntegratio
|
|||
[Fact(Skip = "Requires OpenAI API Key", SkipWhen = nameof(NoOpenAIKeySet))]
|
||||
public async Task SamplingViaChatClient_RequestResponseProperlyPropagated()
|
||||
{
|
||||
var samplingHandler = new OpenAIClient(s_openAIKey)
|
||||
.AsChatClient("gpt-4o-mini")
|
||||
var samplingHandler = new OpenAIClient(s_openAIKey).GetChatClient("gpt-4o-mini")
|
||||
.AsIChatClient()
|
||||
.CreateSamplingHandler();
|
||||
await using var client = await McpClientFactory.CreateAsync(new StdioClientTransport(_fixture.EverythingServerTransportOptions), new()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class DiagnosticTests
|
|||
Assert.NotEmpty(tools);
|
||||
|
||||
var tool = tools.First(t => t.Name == "DoubleValue");
|
||||
await tool.InvokeAsync(new Dictionary<string, object?>() { ["amount"] = 42 }, TestContext.Current.CancellationToken);
|
||||
await tool.InvokeAsync(new() { ["amount"] = 42 }, TestContext.Current.CancellationToken);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ public class McpServerToolTests
|
|||
Assert.NotNull(McpServerTool.Create(typeof(DisposableToolType).GetMethod(nameof(DisposableToolType.InstanceMethod))!, new DisposableToolType()));
|
||||
Assert.NotNull(McpServerTool.Create(typeof(DisposableToolType).GetMethod(nameof(DisposableToolType.StaticMethod))!));
|
||||
Assert.Throws<ArgumentNullException>("target", () => McpServerTool.Create(typeof(DisposableToolType).GetMethod(nameof(DisposableToolType.InstanceMethod))!, target: null!));
|
||||
Assert.Throws<ArgumentException>("target", () => McpServerTool.Create(typeof(DisposableToolType).GetMethod(nameof(DisposableToolType.StaticMethod))!, new DisposableToolType()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
Loading…
Reference in a new issue