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

Function numericContextLimitValue

coderd/x/chatd/chatloop/chatloop.go:2158–2184  ·  view source on GitHub ↗
(value any)

Source from the content-addressed store, hash-verified

2156}
2157
2158func numericContextLimitValue(value any) (int64, bool) {
2159 switch typed := value.(type) {
2160 case int64:
2161 return positiveInt64(typed)
2162 case int32:
2163 return positiveInt64(int64(typed))
2164 case int:
2165 return positiveInt64(int64(typed))
2166 case float64:
2167 casted := int64(typed)
2168 if typed > 0 && float64(casted) == typed {
2169 return casted, true
2170 }
2171 case string:
2172 parsed, err := strconv.ParseInt(strings.TrimSpace(typed), 10, 64)
2173 if err == nil {
2174 return positiveInt64(parsed)
2175 }
2176 case json.Number:
2177 parsed, err := typed.Int64()
2178 if err == nil {
2179 return positiveInt64(parsed)
2180 }
2181 }
2182
2183 return 0, false
2184}
2185
2186func positiveInt64(value int64) (int64, bool) {
2187 if value <= 0 {

Callers 2

Calls 2

positiveInt64Function · 0.85
Int64Method · 0.80

Tested by 1