mirror of
https://github.com/vxcontrol/langchaingo.git
synced 2026-08-25 11:10:02 -04:00
058e344d90
WithMaxTokens above MaxInt32 wrapped: 3_000_000_000 became -1294967296 on the Vertex generation config (max output tokens, candidate count and top-k) and on the Converse inference config. The googleai adapter already saturated, so the same call succeeded there and failed on the sibling doors. The saturating conversion moves to internal/numutil so the three doors share one implementation. The Vertex generation config is extracted into a function so the conversion has a seam a test can reach. Not changed: the thinking-budget conversion in googleai, where GetTokens is already clamped to MaxReasoningTokens and cannot overflow. PAGI-132
15 lines
205 B
Go
15 lines
205 B
Go
package numutil
|
|
|
|
import "math"
|
|
|
|
func SaturateInt32(i int) int32 {
|
|
switch {
|
|
case i > math.MaxInt32:
|
|
return math.MaxInt32
|
|
case i < math.MinInt32:
|
|
return math.MinInt32
|
|
default:
|
|
return int32(i)
|
|
}
|
|
}
|