| 2064 | } |
| 2065 | |
| 2066 | func 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 | |
| 2106 | func normalizeMetadataKey(key string) string { |
| 2107 | var b strings.Builder |