From 8416cb866acd367c0600cb90a3dc51906e45b61e Mon Sep 17 00:00:00 2001 From: Martin Evans Date: Sat, 6 Jan 2024 17:59:36 +0000 Subject: [PATCH] Improved exceptions in IModelParams for unknown KV override types. --- LLama/Abstractions/IModelParams.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/LLama/Abstractions/IModelParams.cs b/LLama/Abstractions/IModelParams.cs index c4f96c37f..902a37d2a 100644 --- a/LLama/Abstractions/IModelParams.cs +++ b/LLama/Abstractions/IModelParams.cs @@ -2,6 +2,7 @@ using System.Buffers; using System.Collections; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text.Json; using System.Text.Json.Serialization; @@ -272,11 +273,11 @@ internal void WriteValue(ref LLamaModelMetadataOverride dest) dest.BoolValue = _valueBool ? -1L : 0; break; default: - throw new ArgumentOutOfRangeException(); + throw new InvalidEnumArgumentException($"Unknown {nameof(LLamaModelKvOverrideType)} value: {Type}"); } } - internal void WriteValue(Utf8JsonWriter writer, JsonSerializerOptions options) + internal void WriteValue(Utf8JsonWriter writer) { switch (Type) { @@ -290,7 +291,7 @@ internal void WriteValue(Utf8JsonWriter writer, JsonSerializerOptions options) writer.WriteBooleanValue(_valueBool); break; default: - throw new ArgumentOutOfRangeException(); + throw new InvalidEnumArgumentException($"Unknown {nameof(LLamaModelKvOverrideType)} value: {Type}"); } } } @@ -323,7 +324,7 @@ public override void Write(Utf8JsonWriter writer, MetadataOverride value, JsonSe writer.WriteNumber("Type", (int)value.Type); writer.WriteString("Key", value.Key); writer.WritePropertyName("Value"); - value.WriteValue(writer, options); + value.WriteValue(writer); } writer.WriteEndObject(); }