PredictRich is the non-streaming translate path. Returns a fully- populated *pb.Reply: content, tool-call deltas (ChatDeltas), and usage tokens. Implements the optional grpc.AIModelRich interface; the gRPC server prefers this path over Predict when present so tool calls survive the round-trip. Passt
(opts *pb.PredictOptions)
| 144 | // tool calls survive the round-trip. Passthrough mode rejects |
| 145 | // PredictRich — callers must use Forward. |
| 146 | func (c *CloudProxy) PredictRich(opts *pb.PredictOptions) (reply *pb.Reply, err error) { |
| 147 | cfg := c.cfg.Load() |
| 148 | if cfg == nil { |
| 149 | return nil, grpcerrors.ModelNotLoaded("cloud-proxy") |
| 150 | } |
| 151 | if cfg.mode != modeTranslate { |
| 152 | return nil, fmt.Errorf("cloud-proxy: Predict only valid in translate mode (have %s)", cfg.mode) |
| 153 | } |
| 154 | xlog.Info("cloud-proxy: predict", "provider", cfg.provider, "upstream", cfg.upstreamURL, "upstream_model", cfg.upstreamModel) |
| 155 | defer func() { |
| 156 | if err != nil { |
| 157 | xlog.Warn("cloud-proxy: predict failed", "provider", cfg.provider, "error", err) |
| 158 | } |
| 159 | }() |
| 160 | ctx := context.Background() |
| 161 | switch cfg.provider { |
| 162 | case providerOpenAI: |
| 163 | return c.predictOpenAIRich(ctx, cfg, opts) |
| 164 | case providerAnthropic: |
| 165 | return c.predictAnthropicRich(ctx, cfg, opts) |
| 166 | default: |
| 167 | return nil, fmt.Errorf("cloud-proxy: predict not implemented for provider %q", cfg.provider) |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | // PredictStreamRich is the rich streaming counterpart of PredictRich. |
| 172 | // Each emitted Reply carries either a content delta, tool-call deltas, |
no test coverage detected