using System; using LLama.Native; namespace LLama.Exceptions; /// /// Base class for LLamaSharp runtime errors (i.e. errors produced by llama.cpp, converted into exceptions) /// public class RuntimeError : Exception { /// /// Create a new RuntimeError /// /// public RuntimeError(string message) : base(message) { } } /// /// Loading model weights failed /// public class LoadWeightsFailedException : RuntimeError { /// /// The model path which failed to load /// public string ModelPath { get; } /// public LoadWeightsFailedException(string modelPath) : base($"Failed to load model '{modelPath}'") { ModelPath = modelPath; } } /// /// `llama_decode` return a non-zero status code /// public class LLamaDecodeError : RuntimeError { /// /// The return status code /// public DecodeResult ReturnCode { get; } /// public LLamaDecodeError(DecodeResult returnCode) : base($"llama_decode failed: '{returnCode}'") { ReturnCode = returnCode; } }