909a88c5c0
Many model crashes are masked behind "An existing connection was forcibly closed by the remote host" This captures that common error message and wires in any detected errors from the log. This also adds the deepseek context shift error to the known errors we capture.
45 lines
889 B
Go
45 lines
889 B
Go
package llm
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
)
|
|
|
|
// StatusWriter is a writer that captures error messages from the llama runner process
|
|
type StatusWriter struct {
|
|
LastErrMsg string
|
|
out *os.File
|
|
}
|
|
|
|
func NewStatusWriter(out *os.File) *StatusWriter {
|
|
return &StatusWriter{
|
|
out: out,
|
|
}
|
|
}
|
|
|
|
// TODO - regex matching to detect errors like
|
|
// libcublasLt.so.11: cannot open shared object file: No such file or directory
|
|
|
|
var errorPrefixes = []string{
|
|
"error:",
|
|
"CUDA error",
|
|
"cudaMalloc failed",
|
|
"\"ERR\"",
|
|
"error loading model",
|
|
"GGML_ASSERT",
|
|
"Deepseek2 does not support K-shift",
|
|
}
|
|
|
|
func (w *StatusWriter) Write(b []byte) (int, error) {
|
|
var errMsg string
|
|
for _, prefix := range errorPrefixes {
|
|
if _, after, ok := bytes.Cut(b, []byte(prefix)); ok {
|
|
errMsg = prefix + string(bytes.TrimSpace(after))
|
|
}
|
|
}
|
|
if errMsg != "" {
|
|
w.LastErrMsg = errMsg
|
|
}
|
|
|
|
return w.out.Write(b)
|
|
}
|