MCPcopy Index your code
hub / github.com/coder/coder / isContextLimitKey

Function isContextLimitKey

coderd/x/chatd/chatloop/chatloop.go:2066–2104  ·  view source on GitHub ↗
(key string)

Source from the content-addressed store, hash-verified

2064}
2065
2066func isContextLimitKey(key string) bool {
2067 normalized := normalizeMetadataKey(key)
2068 if normalized == "" {
2069 return false
2070 }
2071
2072 switch normalized {
2073 case
2074 "contextlimit",
2075 "contextwindow",
2076 "contextlength",
2077 "maxcontext",
2078 "maxcontexttokens",
2079 "maxinputtokens",
2080 "maxinputtoken",
2081 "inputtokenlimit":
2082 return true
2083 }
2084
2085 words := metadataKeyWords(key)
2086 if !slices.Contains(words, "context") {
2087 return false
2088 }
2089
2090 if slices.Contains(words, "limit") {
2091 return true
2092 }
2093
2094 if slices.Contains(words, "window") {
2095 return slices.Contains(words, "size") || slices.Contains(words, "max")
2096 }
2097
2098 if slices.Contains(words, "length") {
2099 return slices.Contains(words, "max")
2100 }
2101
2102 return (slices.Contains(words, "token") || slices.Contains(words, "tokens")) &&
2103 (slices.Contains(words, "max") || slices.Contains(words, "limit"))
2104}
2105
2106func normalizeMetadataKey(key string) string {
2107 var b strings.Builder

Callers 2

TestIsContextLimitKeyFunction · 0.85

Calls 3

normalizeMetadataKeyFunction · 0.85
metadataKeyWordsFunction · 0.85
ContainsMethod · 0.45

Tested by 1

TestIsContextLimitKeyFunction · 0.68