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

Method test_tokenize_string

backend/python/mlx/test.py:243–260  ·  view source on GitHub ↗

TokenizeString should return a non-empty token list for a known prompt.

(self)

Source from the content-addressed store, hash-verified

241
242
243 def test_tokenize_string(self):
244 """TokenizeString should return a non-empty token list for a known prompt."""
245 try:
246 self.setUp()
247 with grpc.insecure_channel("localhost:50051") as channel:
248 stub = backend_pb2_grpc.BackendStub(channel)
249 response = stub.LoadModel(
250 backend_pb2.ModelOptions(Model="mlx-community/Llama-3.2-1B-Instruct-4bit")
251 )
252 self.assertTrue(response.success)
253 resp = stub.TokenizeString(backend_pb2.PredictOptions(Prompt="Hello, world"))
254 self.assertGreater(resp.length, 0)
255 self.assertEqual(len(list(resp.tokens)), resp.length)
256 except Exception as err:
257 print(err)
258 self.fail("TokenizeString service failed")
259 finally:
260 self.tearDown()
261
262 def test_free(self):
263 """Free should release the model and not crash on subsequent calls."""

Callers

nothing calls this directly

Calls 4

setUpMethod · 0.95
tearDownMethod · 0.95
LoadModelMethod · 0.65
TokenizeStringMethod · 0.65

Tested by

no test coverage detected