diff --git a/docs/plans/2026-02-22-backend-result-type.md b/docs/plans/completed/2026-02-22-backend-result-type-original.md similarity index 100% rename from docs/plans/2026-02-22-backend-result-type.md rename to docs/plans/completed/2026-02-22-backend-result-type-original.md diff --git a/docs/plans/completed/backend-result-type.md b/docs/plans/completed/backend-result-type.md new file mode 100644 index 0000000..6f96eda --- /dev/null +++ b/docs/plans/completed/backend-result-type.md @@ -0,0 +1,38 @@ +# Backend Result Type — Completion Summary + +**Completed:** 22 February 2026 +**Module:** `forge.lthn.ai/core/go-ml` +**Status:** Complete — unified Result struct across all backends + +## What Was Built + +Refactored Generate/Chat return types across all ML backends (HTTP, Llama, +MLX adapter) to use a unified `Result` struct carrying both generated text +and inference metrics. + +### Result struct + +```go +type Result struct { + Text string + Metrics Metrics +} + +type Metrics struct { + PromptTokens int + CompletionTokens int + TotalTokens int + LatencyMs float64 + TokensPerSecond float64 +} +``` + +### Backends updated + +- HTTP backend (Ollama, OpenAI-compatible endpoints) +- Llama backend (llama.cpp via CGo) +- MLX adapter (delegates to go-mlx) + +All tests updated to use the new return type. No breaking changes to the +public `ml.Generate()` / `ml.Chat()` API — the Result struct is returned +where previously only a string was.