tokenizeTokenCount returns the number of tokens in a backend response, treating a nil response as zero. The gRPC client returns (nil, err) on failure, and the tracing block below runs before that error is returned — so the count must be read nil-safely here. Reading resp.Tokens on a nil resp previou
(resp *pb.TokenizationResponse)
| 18 | // resp previously panicked the whole HTTP handler when tracing was enabled |
| 19 | // (e.g. a transient tokenize failure during router probe-budget sizing). |
| 20 | func tokenizeTokenCount(resp *pb.TokenizationResponse) int { |
| 21 | if resp == nil { |
| 22 | return 0 |
| 23 | } |
| 24 | return len(resp.Tokens) |
| 25 | } |
| 26 | |
| 27 | func ModelTokenize(s string, loader *model.ModelLoader, modelConfig config.ModelConfig, appConfig *config.ApplicationConfig) (schema.TokenizeResponse, error) { |
| 28 |
no outgoing calls
no test coverage detected