MCPcopy
hub / github.com/mudler/LocalAI / tokenClassifyResponseToEntities

Function tokenClassifyResponseToEntities

core/backend/token_classify.go:132–150  ·  view source on GitHub ↗

tokenClassifyResponseToEntities converts the wire-format response into the value type consumed by callers. Extracted so the conversion can be unit-tested without a real backend (see token_classify_test.go).

(resp *pb.TokenClassifyResponse)

Source from the content-addressed store, hash-verified

130// the value type consumed by callers. Extracted so the conversion can be
131// unit-tested without a real backend (see token_classify_test.go).
132func tokenClassifyResponseToEntities(resp *pb.TokenClassifyResponse) []TokenEntity {
133 if resp == nil {
134 return nil
135 }
136 out := make([]TokenEntity, 0, len(resp.Entities))
137 for _, e := range resp.Entities {
138 if e == nil {
139 continue
140 }
141 out = append(out, TokenEntity{
142 Group: e.EntityGroup,
143 Start: int(e.Start),
144 End: int(e.End),
145 Score: e.Score,
146 Text: e.Text,
147 })
148 }
149 return out
150}

Callers 2

ModelTokenClassifyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected