返回 DeepSeek-Reasonix
provider_context_window.go
根目录 / internal / cli / provider_context_window.go
1 package cli
2
3 import (
4 "bufio"
5 "io"
6 "strconv"
7 "strings"
8
9 "reasonix/internal/i18n"
10 )
11
12 // defaultCustomContextWindow is the fallback for a relay whose window we cannot
13 // know. It is deliberately conservative: too small only wastes context, while
14 // too large makes the provider reject the request outright.
15 const defaultCustomContextWindow = 128000
16
17 // askContextWindow prompts for the model's context window. An OpenAI-compatible
18 // endpoint does not report it, and a value below the real window is what makes
19 // compaction fire long before it needs to, so the wizard asks instead of
20 // recording an assumption the user never sees.
21 func askContextWindow(in *bufio.Scanner, w io.Writer) int {
22 raw := ask(in, w, i18n.M.CustomPromptWindow, strconv.Itoa(defaultCustomContextWindow))
23 n, err := strconv.Atoi(strings.TrimSpace(raw))
24 if err != nil || n <= 0 {
25 return defaultCustomContextWindow
26 }
27 return n
28 }
29
29 lines GO