You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ModelsParamsTests.cs 1.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using LLama.Common;
  2. namespace LLama.Unittest
  3. {
  4. public class ModelsParamsTests
  5. {
  6. [Fact]
  7. public void SerializeRoundTripSystemTextJson()
  8. {
  9. var expected = new ModelParams("abc/123")
  10. {
  11. BatchSize = 17,
  12. ContextSize = 42,
  13. Seed = 42,
  14. GpuLayerCount = 111
  15. };
  16. var json = System.Text.Json.JsonSerializer.Serialize(expected);
  17. var actual = System.Text.Json.JsonSerializer.Deserialize<ModelParams>(json);
  18. Assert.Equal(expected, actual);
  19. }
  20. [Fact]
  21. public void SerializeRoundTripNewtonsoft()
  22. {
  23. var expected = new ModelParams("abc/123")
  24. {
  25. BatchSize = 17,
  26. ContextSize = 42,
  27. Seed = 42,
  28. GpuLayerCount = 111,
  29. LoraAdapters =
  30. {
  31. new("abc", 1),
  32. new("def", 0)
  33. }
  34. };
  35. var settings = new Newtonsoft.Json.JsonSerializerSettings();
  36. var json = Newtonsoft.Json.JsonConvert.SerializeObject(expected, settings);
  37. var actual = Newtonsoft.Json.JsonConvert.DeserializeObject<ModelParams>(json, settings);
  38. Assert.Equal(expected, actual);
  39. }
  40. }
  41. }