Browse Source

Merge pull request #416 from martindevans/IModelParams_better_exception

Improved exceptions in IModelParams for unknown KV override types.
tags/v0.10.0
Martin Evans GitHub 1 year ago
parent
commit
c696cda44b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions
  1. +5
    -4
      LLama/Abstractions/IModelParams.cs

+ 5
- 4
LLama/Abstractions/IModelParams.cs View File

@@ -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 @@ namespace LLama.Abstractions
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 @@ namespace LLama.Abstractions
writer.WriteBooleanValue(_valueBool);
break;
default:
throw new ArgumentOutOfRangeException();
throw new InvalidEnumArgumentException($"Unknown {nameof(LLamaModelKvOverrideType)} value: {Type}");
}
}
}
@@ -323,7 +324,7 @@ namespace LLama.Abstractions
writer.WriteNumber("Type", (int)value.Type);
writer.WriteString("Key", value.Key);
writer.WritePropertyName("Value");
value.WriteValue(writer, options);
value.WriteValue(writer);
}
writer.WriteEndObject();
}


Loading…
Cancel
Save