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

Function tokenClassify

tests/e2e/e2e_pii_ner_test.go:117–127  ·  view source on GitHub ↗

tokenClassify drives core/backend.ModelTokenClassify against the live model with the loader/config the running server uses — the same path the NER detector takes, but at Threshold 0 so we see the raw, unmerged spans.

(text string)

Source from the content-addressed store, hash-verified

115// with the loader/config the running server uses — the same path the NER
116// detector takes, but at Threshold 0 so we see the raw, unmerged spans.
117func tokenClassify(text string) []backend.TokenEntity {
118 GinkgoHelper()
119 cfg, ok := localAIApp.ModelConfigLoader().GetModelConfig(piiNERModel)
120 Expect(ok).To(BeTrue(), "model config %q must be loaded", piiNERModel)
121 fn, err := backend.ModelTokenClassify(text, backend.TokenClassifyOptions{},
122 localAIApp.ModelLoader(), cfg, localAIApp.ApplicationConfig())
123 Expect(err).NotTo(HaveOccurred())
124 ents, err := fn(context.TODO())
125 Expect(err).NotTo(HaveOccurred())
126 return ents
127}
128
129// assertByteCorrectSpan is the shared byte-offset invariant: a half-open byte
130// range within text, aligned to UTF-8 rune boundaries, whose slice equals the

Callers 1

Calls 6

ModelTokenClassifyFunction · 0.92
ModelConfigLoaderMethod · 0.80
ModelLoaderMethod · 0.80
ApplicationConfigMethod · 0.80
GetModelConfigMethod · 0.65
fnFunction · 0.50

Tested by

no test coverage detected