From f413111f0894a49afeb04d3b6cde8fb7e94f837f Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Feb 2026 13:51:21 +0000 Subject: [PATCH] docs: archive completed backend-result-type plan Move backend-result-type plan to docs/plans/completed/ with summary. Unified Result struct now used across all ML backends. Co-Authored-By: Claude Opus 4.6 --- ...026-02-22-backend-result-type-original.md} | 0 docs/plans/completed/backend-result-type.md | 38 +++++++++++++++++++ 2 files changed, 38 insertions(+) rename docs/plans/{2026-02-22-backend-result-type.md => completed/2026-02-22-backend-result-type-original.md} (100%) create mode 100644 docs/plans/completed/backend-result-type.md 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.