mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-10 21:47:21 +00:00
Adopted further C# 14 and .NET 10 features (#1158)
This commit is contained in:
1 parent
f649febf88
commit
f0fa1411c8
40 files changed
+545
-56
No files matched your search
@@ -0,0 +1,46 @@
|
||||
using AIStudio.Provider;
|
||||
|
||||
namespace AIStudio.Tests.Provider;
|
||||
|
||||
/// <summary>
|
||||
/// Checks how the additional API parameters of a provider are read.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The dialog for providers refuses a parameter named twice, but a configuration plugin brings its
|
||||
/// providers past the dialog. Read anyway, such parameters would leave it open which of the values
|
||||
/// reaches the provider, and they used to break every request with an exception nobody caught.
|
||||
/// </remarks>
|
||||
[TestFixture]
|
||||
public sealed class AdditionalApiParametersParserTests
|
||||
{
|
||||
[Test]
|
||||
public void TheParametersAreRead()
|
||||
{
|
||||
var isRead = AdditionalApiParametersParser.TryParse("""
|
||||
"temperature": 0.5,
|
||||
"reasoning": { "effort": "low" }
|
||||
""", out var parameters, out var errorMessage);
|
||||
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(isRead, Is.True);
|
||||
Assert.That(errorMessage, Is.Null);
|
||||
Assert.That(parameters["temperature"], Is.EqualTo(0.5));
|
||||
Assert.That(parameters["reasoning"], Is.EqualTo(new Dictionary<string, object> { ["effort"] = "low" }));
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase("\"temperature\": 0.5, \"temperature\": 0.7", "temperature", TestName = "A parameter named twice")]
|
||||
[TestCase("\"reasoning\": { \"effort\": \"low\", \"effort\": \"high\" }", "effort", TestName = "A field named twice inside a parameter")]
|
||||
public void AParameterNamedTwiceIsRefused(string additionalParameters, string repeatedName)
|
||||
{
|
||||
var isRead = AdditionalApiParametersParser.TryParse(additionalParameters, out var parameters, out var errorMessage);
|
||||
|
||||
using (Assert.EnterMultipleScope())
|
||||
{
|
||||
Assert.That(isRead, Is.False);
|
||||
Assert.That(parameters, Is.Empty);
|
||||
Assert.That(errorMessage, Does.Contain($"'{repeatedName}'"), "The log names the parameter to correct.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using AIStudio.Provider;
|
||||
|
||||
namespace AIStudio.Tests.Provider;
|
||||
|
||||
/// <summary>
|
||||
/// Checks the order in which the dialogs for providers list the models, newest first.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Compared digit by digit, "gpt-4.9" would come before "gpt-4.10" and "o3" before "o10", so an older
|
||||
/// model would be on top of the list.
|
||||
/// </remarks>
|
||||
[TestFixture]
|
||||
public sealed class ModelIdOrderTests
|
||||
{
|
||||
[TestCase(new[] { "gpt-4.9", "gpt-4.10", "gpt-4.1" }, new[] { "gpt-4.10", "gpt-4.9", "gpt-4.1" }, TestName = "Version numbers after a dot")]
|
||||
[TestCase(new[] { "o3", "o10", "o1" }, new[] { "o10", "o3", "o1" }, TestName = "Numbers after a letter")]
|
||||
[TestCase(new[] { "llama3.1:8b", "llama3.1:70b" }, new[] { "llama3.1:70b", "llama3.1:8b" }, TestName = "Sizes of a model")]
|
||||
[TestCase(new[] { "mistral-large-2407", "mistral-large-2411", "mistral-large-latest" }, new[] { "mistral-large-latest", "mistral-large-2411", "mistral-large-2407" }, TestName = "Dates of a model")]
|
||||
public void TheNewestModelsComeFirst(string[] modelIds, string[] expectedOrder)
|
||||
{
|
||||
var ordered = modelIds.OrderByDescending(id => id, Model.ID_ORDER);
|
||||
|
||||
Assert.That(ordered, Is.EqualTo(expectedOrder));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user