MCPcopy Create free account
hub / github.com/Bytez-com/docs / TestTextGeneration

Class TestTextGeneration

sdk/python/test.py:14–94  ·  view source on GitHub ↗

Tests for text generation models in a fixed order.

Source from the content-addressed store, hash-verified

12print("Running tests")
13
14class TestTextGeneration(unittest.IsolatedAsyncioTestCase):
15 """Tests for text generation models in a fixed order."""
16
17 def test_creates_model_class(self):
18 """Test that the correct model ID is loaded."""
19 self.assertEqual(model.id, modelId, "loads the right model")
20
21 def test_list_models(self):
22 """Test listing models."""
23 result = bytez.list.models()
24
25 self.assertIsNone(result.error)
26 self.assertIsInstance(result.output, list, "should return an array of models")
27 self.assertNotEqual(len(result.output), 0, "array should not be empty")
28
29 def test_runs_a_model(self):
30 """Test running a model."""
31 result = model.run("Jack and jill")
32
33 self.assertIsNone(result.error)
34 self.assertIsInstance(result.output, str, "returns output")
35
36 def test_params_with_kwargs(self):
37 """Test running a model with parameters."""
38 input_text = "Jack and Jill "
39 result = model.run(
40 input_text, params={"min_new_tokens": 1, "max_new_tokens": 1}
41 )
42
43 self.assertIsNone(result.error)
44 self.assertIsInstance(result.output, str, "returns output")
45 self.assertEqual(
46 len(result.output.split(" ")),
47 len(input_text.strip().split(" ")) + 1,
48 "returns output",
49 )
50 def test_params(self):
51 """Test running a model with parameters."""
52 input_text = "Jack and Jill "
53 result = model.run(
54 input_text, {"min_new_tokens": 1, "max_new_tokens": 1}
55 )
56
57 self.assertIsNone(result.error)
58 self.assertIsInstance(result.output, str, "returns output")
59 self.assertEqual(
60 len(result.output.split(" ")),
61 len(input_text.strip().split(" ")) + 1,
62 "returns output",
63 )
64 def test_stream_kwargs(self):
65 """Test streaming text."""
66 stream = model.run("Jack and jill", stream=True)
67
68 for chunk in stream:
69 self.assertIsInstance(chunk, str, "streams output")
70 def test_stream(self):
71 """Test streaming text."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected