config: allow setting context length through env var (#8938)

* envconfig: allow setting context length through env var
This commit is contained in:
Parth Sareen
2025-02-24 13:26:35 -08:00
committed by GitHub
parent 4604b10306
commit 314573bfe8
4 changed files with 23 additions and 1 deletions

View File

@@ -272,3 +272,19 @@ func TestVar(t *testing.T) {
})
}
}
func TestContextLength(t *testing.T) {
cases := map[string]uint{
"": 2048,
"4096": 4096,
}
for k, v := range cases {
t.Run(k, func(t *testing.T) {
t.Setenv("OLLAMA_CONTEXT_LENGTH", k)
if i := ContextLength(); i != v {
t.Errorf("%s: expected %d, got %d", k, v, i)
}
})
}
}