MCPcopy Create free account
hub / github.com/diillson/chatcli / contextRagTopK

Function contextRagTopK

cli/plugins/builtin_context.go:388–407  ·  view source on GitHub ↗

contextRagTopK reads the rag flag, which the model may send as a bool (true → default top-K, encoded here as -1 meaning "mode default on") or an int (explicit K). 0 / absent / false means "no override".

(raw map[string]json.RawMessage)

Source from the content-addressed store, hash-verified

386// (true → default top-K, encoded here as -1 meaning "mode default on") or an
387// int (explicit K). 0 / absent / false means "no override".
388func contextRagTopK(raw map[string]json.RawMessage) int {
389 v, ok := raw["rag"]
390 if !ok {
391 v, ok = raw["retrieve"]
392 }
393 if !ok || len(v) == 0 {
394 return 0
395 }
396 var b bool
397 if err := json.Unmarshal(v, &b); err == nil {
398 if b {
399 return contextDefaultRagTopK
400 }
401 return 0
402 }
403 if n := jsonInt(raw, "rag", "retrieve"); n > 0 {
404 return n
405 }
406 return 0
407}
408
409// contextDefaultRagTopK is the top-K applied when rag is requested as a bare
410// boolean. Mirrors ctxmgr.DefaultRetrievalTopK without importing it here.

Callers 2

TestContextRagTopKFunction · 0.85
ExecuteWithStreamMethod · 0.85

Calls 1

jsonIntFunction · 0.85

Tested by 1

TestContextRagTopKFunction · 0.68