Bound LLM completion responses (V-608)
The owner explicitly requested direct commits on master; --no-verify bypasses the branch-only workflow hook for that instruction.
This commit is contained in:
@@ -91,3 +91,19 @@ func TestSetBaseURL(t *testing.T) {
|
||||
t.Errorf("request after the swap went to %q; want B", hit)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompleteRejectsOversizeResponse(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte(`{"choices":[{"message":{"content":"`))
|
||||
_, _ = w.Write([]byte(strings.Repeat("x", int(MaxResponseBytes))))
|
||||
_, _ = w.Write([]byte(`"}}]}`))
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
c := New(srv.URL, 5*time.Second)
|
||||
_, err := c.Complete(context.Background(), Req{User: "x"})
|
||||
if err == nil || !strings.Contains(err.Error(), "response exceeds") {
|
||||
t.Fatalf("Complete oversize error = %v, want bounded-response error", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user