tokenClassifyTrace assembles the Traces-UI row for one NER call: the input preview, the threshold, and every detected entity (group, byte range, confidence, matched text). Split out from the closure so the Data assembly is unit-testable without a live backend.
(modelConfig config.ModelConfig, text string, threshold float32, entities []TokenEntity, start time.Time, callErr error)
| 106 | // confidence, matched text). Split out from the closure so the Data assembly |
| 107 | // is unit-testable without a live backend. |
| 108 | func tokenClassifyTrace(modelConfig config.ModelConfig, text string, threshold float32, entities []TokenEntity, start time.Time, callErr error) trace.BackendTrace { |
| 109 | errStr := "" |
| 110 | if callErr != nil { |
| 111 | errStr = callErr.Error() |
| 112 | } |
| 113 | return trace.BackendTrace{ |
| 114 | Timestamp: start, |
| 115 | Duration: time.Since(start), |
| 116 | Type: trace.BackendTraceTokenClassify, |
| 117 | ModelName: modelConfig.Name, |
| 118 | Backend: modelConfig.Backend, |
| 119 | Summary: trace.TruncateString(text, 200), |
| 120 | Error: errStr, |
| 121 | Data: map[string]any{ |
| 122 | "input_chars": len(text), |
| 123 | "threshold": threshold, |
| 124 | "entities": entities, |
| 125 | }, |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | // tokenClassifyResponseToEntities converts the wire-format response into |
| 130 | // the value type consumed by callers. Extracted so the conversion can be |
no test coverage detected