test_srt_backend.py 1.59 KB
Newer Older
Lianmin Zheng's avatar
Lianmin Zheng committed
1
2
3
"""
python3 -m sglang.launch_server --model-path meta-llama/Llama-2-7b-chat-hf --port 30000
"""
4

Lianmin Zheng's avatar
Lianmin Zheng committed
5
6
7
8
9
import json
import unittest

from sglang.test.test_programs import (
    test_decode_int,
10
    test_decode_json_regex,
Lianmin Zheng's avatar
Lianmin Zheng committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
    test_expert_answer,
    test_few_shot_qa,
    test_mt_bench,
    test_parallel_decoding,
    test_parallel_encoding,
    test_react,
    test_regex,
    test_select,
    test_stream,
    test_tool_use,
)

import sglang as sgl


class TestSRTBackend(unittest.TestCase):
    backend = None

    def setUp(self):
        cls = type(self)

        if cls.backend is None:
            cls.backend = sgl.RuntimeEndpoint(base_url="http://localhost:30000")
            sgl.set_default_backend(cls.backend)

    def test_few_shot_qa(self):
        test_few_shot_qa()

    def test_mt_bench(self):
        test_mt_bench()

    def test_select(self):
        test_select(check_answer=False)

    def test_decode_int(self):
        test_decode_int()

48
49
50
    def test_decode_json_regex(self):
        test_decode_json_regex()

Lianmin Zheng's avatar
Lianmin Zheng committed
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
    def test_expert_answer(self):
        test_expert_answer()

    def test_tool_use(self):
        test_tool_use()

    def test_parallel_decoding(self):
        test_parallel_decoding()

    def test_stream(self):
        test_stream()

    def test_regex(self):
        test_regex()

    # def test_parallel_encoding(self):
    #     test_parallel_encoding(check_answer=False)


if __name__ == "__main__":
    unittest.main(warnings="ignore")

    # from sglang.global_config import global_config

    # global_config.verbosity = 2
    # t = TestSRTBackend()
    # t.setUp()
    # t.test_regex()