Skip to content

Commit 220cd9c

Browse files
committed
tests
1 parent d63199b commit 220cd9c

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Microsoft.SemanticKernel;
2+
3+
namespace MLXSharp.SemanticKernel;
4+
5+
public sealed class MlxPromptExecutionSettings : PromptExecutionSettings
6+
{
7+
public int? MaxTokens { get; set; }
8+
public float? Temperature { get; set; }
9+
public float? TopP { get; set; }
10+
}

src/MLXSharp.Tests/MlxIntegrationTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ namespace MLXSharp.Tests;
1717

1818
public class MlxIntegrationTests(ITestOutputHelper output)
1919
{
20-
private readonly ITestOutputHelper _output = output;
2120
[Fact]
2221
public async Task ChatClientGeneratesResponse()
2322
{
@@ -45,7 +44,7 @@ public async Task ChatClientGeneratesResponse()
4544

4645
Assert.NotEmpty(response.Messages);
4746
Assert.NotEmpty(response.Messages[0].Text);
48-
_output.WriteLine($"Response: {response.Messages[0].Text}");
47+
output.WriteLine($"Response: {response.Messages[0].Text}");
4948
}
5049

5150
[Fact]
@@ -75,7 +74,7 @@ public async Task MultipleRequestsWorkCorrectly()
7574
CancellationToken.None);
7675

7776
Assert.NotEmpty(response1.Messages);
78-
_output.WriteLine($"Response 1: {response1.Messages[0].Text}");
77+
output.WriteLine($"Response 1: {response1.Messages[0].Text}");
7978

8079
// Second request
8180
var response2 = await chatClient.GetResponseAsync(
@@ -84,7 +83,7 @@ public async Task MultipleRequestsWorkCorrectly()
8483
CancellationToken.None);
8584

8685
Assert.NotEmpty(response2.Messages);
87-
_output.WriteLine($"Response 2: {response2.Messages[0].Text}");
86+
output.WriteLine($"Response 2: {response2.Messages[0].Text}");
8887
}
8988

9089
[Fact]
@@ -111,13 +110,14 @@ public async Task SemanticKernelIntegrationWorks()
111110

112111
var result = await chat.GetChatMessageContentsAsync(
113112
history,
114-
new PromptExecutionSettings { MaxTokens = 50 },
113+
new MlxPromptExecutionSettings { MaxTokens = 50 },
115114
kernel,
116115
CancellationToken.None);
117116

118117
Assert.NotEmpty(result);
119-
Assert.NotEmpty(result[0].Content);
120-
_output.WriteLine($"SK Response: {result[0].Content}");
118+
Assert.NotNull(result[0].Content);
119+
Assert.False(string.IsNullOrEmpty(result[0].Content));
120+
output.WriteLine($"SK Response: {result[0].Content}");
121121
}
122122

123123
[Fact]
@@ -126,8 +126,8 @@ public async Task LongerConversationWithContext()
126126
var modelPath = GetRequiredModelPath();
127127
var nativeLibPath = GetRequiredNativeLibraryPath();
128128

129-
_output.WriteLine($"Model: {modelPath}");
130-
_output.WriteLine($"Library: {nativeLibPath}");
129+
output.WriteLine($"Model: {modelPath}");
130+
output.WriteLine($"Library: {nativeLibPath}");
131131

132132
var services = new ServiceCollection();
133133
services.AddMlx(builder =>
@@ -158,7 +158,7 @@ public async Task LongerConversationWithContext()
158158
Assert.NotEmpty(response.Messages);
159159
Assert.NotEmpty(response.Messages[0].Text);
160160

161-
_output.WriteLine($"Response ({stopwatch.ElapsedMilliseconds}ms): {response.Messages[0].Text}");
161+
output.WriteLine($"Response ({stopwatch.ElapsedMilliseconds}ms): {response.Messages[0].Text}");
162162
}
163163

164164
private static string GetRequiredModelPath()

0 commit comments

Comments
 (0)