mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-13 16:14:57 +00:00
fix(providers): detect llama.cpp context size overflow in error classifier
This commit is contained in:
1 parent
0fef6ff596
commit
e8d3d4340f
2 files changed
+11
No files matched your search
@@ -170,6 +170,9 @@ func isContextOverflow(lower string) bool {
|
||||
"request_too_large", // Generic
|
||||
"input is too long", // DashScope
|
||||
"exceed_context_size", // Ollama native /api/chat 400
|
||||
// llama.cpp / OpenAI-compat local servers return:
|
||||
// "request (N tokens) exceeds the available context size (M tokens)"
|
||||
"context size", // llama.cpp native /v1/chat/completions 400
|
||||
"请求输入过长", // Chinese generic
|
||||
)
|
||||
}
|
||||
|
||||
@@ -151,6 +151,14 @@ func TestClassifyTooManyTokens(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestClassifyContextOverflowLlamaCpp(t *testing.T) {
|
||||
classifier := NewDefaultClassifier()
|
||||
result := classifier.Classify(nil, 400, `{"error":{"code":400,"message":"request (218678 tokens) exceeds the available context size (204800 tokens), try increasing it","type":"exceed_context_size_error","n_prompt_tokens":218678,"n_ctx":204800}}`)
|
||||
if result.Kind != "context_overflow" {
|
||||
t.Errorf("expected context_overflow for llama.cpp message, got %s", result.Kind)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClassifyNetworkTimeoutError(t *testing.T) {
|
||||
classifier := NewDefaultClassifier()
|
||||
timeoutErr := &net.DNSError{
|
||||
|
||||
Reference in new issue
Block a user